1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-09 13:33:26 +00:00

faster, smaller code, and a bugfix

conio: faster grcolor, branchless smaller grplot, smaller a3textmode
etherip: bugfix: add missing '+' to avoid stack corruption
hgr1test: faster smaller draw_scan
rod: faster grcolor, branchless smaller grplot
a1cmd: faster call, memset, lookuptbl, branchless uword_isge,
uword_isle, smaller toupper, lookuptbl
cmd: faster memset, prstr, lookuptbl, branchless uword_isge, uword_isle,
smaller modtosym, lookuptbl
cmdstub: smaller vminit
plvm01: smaller vminit
plvm02: smaller interp init
soscmd: faster memset, lookuptbl, branchless uword_isge, uword_isle,
smaller modtosym, lookuptbl
This commit is contained in:
Peter Ferrie 2015-09-16 14:43:34 -07:00
parent 4ef760f0e4
commit 46b74e2799
10 changed files with 134 additions and 132 deletions

View File

@ -102,12 +102,12 @@ asm grcolor
GRCLR = $30
LDA #$0F
AND ESTKL,X
STA ESTKL,X
STA GRCLR
ASL
ASL
ASL
ASL
ORA ESTKL,X
ORA GRCLR
STA GRCLR
RTS
end
@ -119,23 +119,22 @@ asm grplot
LDA ESTKL,X
AND #$FE
TAY
LDA (GRSCRN),Y
LDA (GRSCRN),Y
STA DSTL
INY
LDA (GRSCRN),Y
STA DSTH
LDY ESTKL+1,X
LDA GRCLR
LDA #$FF
LSR ESTKL,X
BCS +
AND #$0F
ADC #$00
EOR #$F0
TAY
AND GRCLR
STA TMPL
LDA #$F0
BCC ++
+ AND #$F0
STA TMPL
LDA #$0F
++ AND (DST),Y
TYA
EOR #$FF
LDY ESTKL+1,X
AND (DST),Y
ORA TMPL
STA (DST),Y
LDY IPY
@ -277,11 +276,10 @@ end
def a3texttype(type)
end
def a3textmode(columns)
puts(@textbwmode)
if columns > 40
puts(@textbwmode)
a3viewport(0, 0, 80, 24)
else
puts(@textbwmode)
a3viewport(0, 0, 40, 24)
fin
return putc(28)

View File

@ -226,7 +226,7 @@ asm sum1
STA ESTKL,X
BEQ +
INC ESTKH,X
BCC CHKLP
+ BCC CHKLP
INC ESTKH,X
CLC
CHKLP LDA (SRC),Y

View File

@ -92,13 +92,12 @@ PIX = $83
STA (TMP),Y
+ ASL PIX
BPL +
LDA #$01
STA PIX
SEC
ROL PIX
INY
CPY #36
BEQ ++
+ LDA ESTKL+1,X
CLC
ADC WFIXL
STA WFIXL
LDA ESTKH+1,X

View File

@ -88,12 +88,12 @@ asm grcolor
GRCLR = $30
LDA #$0F
AND ESTKL,X
STA ESTKL,X
STA GRCLR
ASL
ASL
ASL
ASL
ORA ESTKL,X
ORA GRCLR
STA GRCLR
RTS
end
@ -105,23 +105,22 @@ asm grplot
LDA ESTKL,X
AND #$FE
TAY
LDA (GRSCRN),Y
LDA (GRSCRN),Y
STA DSTL
INY
LDA (GRSCRN),Y
STA DSTH
LDY ESTKL+1,X
LDA GRCLR
LDA #$FF
LSR ESTKL,X
BCS +
AND #$0F
ADC #$00
EOR #$F0
TAY
AND GRCLR
STA TMPL
LDA #$F0
BCC ++
+ AND #$F0
STA TMPL
LDA #$0F
++ AND (DST),Y
TYA
EOR #$FF
LDY ESTKL+1,X
AND (DST),Y
ORA TMPL
STA (DST),Y
LDY IPY

View File

@ -143,8 +143,7 @@ REGVALS = SRC
LDA ESTKL,X
PHA
INX
LDA ESTKL,X
TAY
LDY ESTKL,X
INX
LDA ESTKL+1,X
PHA
@ -187,25 +186,26 @@ asm memset
LDA ESTKH+2,X
STA DSTH
LDY ESTKL,X
BEQ +
BEQ +
INC ESTKH,X
LDY #$00
+ LDA ESTKH,X
BEQ SETMEX
+ LDA ESTKH,X
BEQ SETMEX
SETMLPL CLC
LDA ESTKL+1,X
SETMLPH STA (DST),Y
DEC ESTKL,X
BNE +
DEC ESTKH,X
BEQ SETMEX
+ INY
BNE +
INC DSTH
+ BCS SETMLPL
BEQ ++
- INY
BEQ +
-- BCS SETMLPL
SEC
LDA ESTKH+1,X
BCS SETMLPH
BCS SETMLPH
+ INC DSTH
BNE --
++ DEC ESTKH,X
BNE -
SETMEX INX
INX
RTS
@ -291,15 +291,15 @@ end
// Unsigned word comparisons.
//
asm uword_isge
LDY #$00
LDA ESTKL+1,X
CMP ESTKL,X
LDA ESTKH+1,X
SBC ESTKH,X
BCC +
DEY
+ STY ESTKL+1,X
STY ESTKH+1,X
LDA #$FF
ADC #$00
EOR #$FF
STA ESTKL+1,X
STA ESTKH+1,X
INX
RTS
end
@ -309,9 +309,10 @@ asm uword_isle
CMP ESTKL+1,X
LDA ESTKH,X
SBC ESTKH+1,X
BCC +
DEY
+ STY ESTKL+1,X
LDA #$FF
ADC #$00
EOR #$FF
STY ESTKL+1,X
STY ESTKH+1,X
INX
RTS
@ -436,7 +437,7 @@ asm stodci
end
asm toupper
LDA ESTKL,X
TOUPR AND #$7F
TOUPR AND #$7F
CMP #'a'
BCC +
CMP #'z'+1
@ -476,7 +477,7 @@ asm modtosym
LDY #$00
LDA #'#'+$80
- STA (DST),Y
CMP #$80
ASL
LDA (SRC),Y
INY
BCS -
@ -517,7 +518,7 @@ asm lookuptbl
CMP (SRC),Y
BNE ++
INY
CMP #$80
ASL
BCS -
LDA (DST),Y
PHA
@ -532,9 +533,8 @@ asm lookuptbl
++ LDY #$00
-- LDA (DST),Y
INC DSTL
BNE ++
INC DSTH
++ CMP #$80
BEQ +
--- ASL
BCS --
LDA #$02
ADC DSTL
@ -542,6 +542,8 @@ asm lookuptbl
BCC -
INC DSTH
BCS -
+ INC DSTH
BNE ---
end
//
// CONSOLE I/O

View File

@ -201,25 +201,26 @@ asm memset
LDA ESTKH+2,X
STA DSTH
LDY ESTKL,X
BEQ +
BEQ +
INC ESTKH,X
LDY #$00
+ LDA ESTKH,X
BEQ SETMEX
+ LDA ESTKH,X
BEQ SETMEX
SETMLPL CLC
LDA ESTKL+1,X
SETMLPH STA (DST),Y
DEC ESTKL,X
BNE +
DEC ESTKH,X
BEQ SETMEX
+ INY
BNE +
INC DSTH
+ BCS SETMLPL
BEQ ++
- INY
BEQ +
-- BCS SETMLPL
SEC
LDA ESTKH+1,X
BCS SETMLPH
BCS SETMLPH
+ INC DSTH
BNE --
++ DEC ESTKH,X
BNE -
SETMEX INX
INX
RTS
@ -325,7 +326,7 @@ asm memxcpy
SEC
JSR $C311
BIT LCRDEN+LCBNK2
LDX ESP
LDX ESP
INX
INX
RTS
@ -372,13 +373,13 @@ end
//
asm prstr
LDY #$00
LDA ESTKL,X
STA SRCL
LDA ESTKH,X
STA SRCH
LDA (SRC),Y
STA TMP
BEQ ++
LDA ESTKL,X
STA SRCL
LDA ESTKH,X
STA SRCH
LDA (SRC),Y
BEQ ++
STA TMP
BIT ROMEN
- INY
LDA (SRC),Y
@ -427,20 +428,20 @@ asm rdstr
LDA ESTKL,X
STA $33
STX ESP
BIT ROMEN
BIT ROMEN
JSR $FD6A
STX $01FF
- LDA $01FF,X
AND #$7F
STA $01FF,X
- LDA $01FF,X
AND #$7F
STA $01FF,X
DEX
BPL -
BPL -
TXA
LDX ESP
STA ESTKL,X
LDA #$01
STA ESTKH,X
BIT LCRDEN+LCBNK2
BIT LCRDEN+LCBNK2
RTS
end
asm uword_isge
@ -449,9 +450,10 @@ asm uword_isge
CMP ESTKL,X
LDA ESTKH+1,X
SBC ESTKH,X
BCC +
DEY
+ STY ESTKL+1,X
LDA #$FF
ADC #$00
EOR #$FF
STY ESTKL+1,X
STY ESTKH+1,X
INX
RTS
@ -462,9 +464,10 @@ asm uword_isle
CMP ESTKL+1,X
LDA ESTKH,X
SBC ESTKH+1,X
BCC +
DEY
+ STY ESTKL+1,X
LDA #$FF
ADC #$00
EOR #$FF
STY ESTKL+1,X
STY ESTKH+1,X
INX
RTS
@ -620,7 +623,7 @@ asm modtosym
LDY #$00
LDA #'#'+$80
- STA (DST),Y
CMP #$80
ASL
LDA (SRC),Y
INY
BCS -
@ -661,7 +664,7 @@ asm lookuptbl
CMP (SRC),Y
BNE ++
INY
CMP #$80
ASL
BCS -
LDA (DST),Y
PHA
@ -676,9 +679,8 @@ asm lookuptbl
++ LDY #$00
-- LDA (DST),Y
INC DSTL
BNE ++
INC DSTH
++ CMP #$80
BEQ +
--- ASL
BCS --
LDA #$02
ADC DSTL
@ -686,6 +688,8 @@ asm lookuptbl
BCC -
INC DSTH
BCS -
+ INC DSTH
BNE ---
end
//
// ProDOS routines

View File

@ -1,7 +1,7 @@
INTERP = $03D0
LCRDEN = $C080
LCWTEN = $C081
ROMEN = $C082
ROMEN = $C082
LCRWEN = $C083
LCBNK2 = $00
LCBNK1 = $08
@ -33,15 +33,14 @@ LCBNK1 = $08
;
; INIT VM ENVIRONMENT STACK POINTERS
;
LDA #$00 ; INIT FRAME POINTER
STA PPL
STA IFPL
STY PPL
STY IFPL ; INIT FRAME POINTER
LDA #$BF
STA PPH
STA IFPH
LDX #$FE ; INIT STACK POINTER (YES, $FE. SEE GETS)
TXS
LDX #ESTKSZ/2 ; INIT EVAL STACK INDEX
LDX #ESTKSZ/2 ; INIT EVAL STACK INDEX
JMP $1000
_CMDBEGIN = *
!PSEUDOPC $1000 {

View File

@ -884,13 +884,12 @@ LIFPH INC IFPH
RET RTS
A1CMD !SOURCE "vmsrc/a1cmd.a"
SEGEND = *
VMINIT LDY #$0F ; INSTALL PAGE 0 FETCHOP ROUTINE
- LDA PAGE0,Y
STA DROP,Y
VMINIT LDY #$10 ; INSTALL PAGE 0 FETCHOP ROUTINE
- LDA PAGE0-1,Y
STA DROP-1,Y
DEY
BPL -
LDA #$00 ; INIT FRAME POINTER
STA IFPL
BNE -
STY IFPL ; INIT FRAME POINTER
LDA #$80
STA IFPH
LDA #<SEGEND ; SAVE HEAP START

View File

@ -101,11 +101,10 @@ RAMDONE CLI
STA SRCL
LDA #>VMCORE
STA SRCH
LDA #$00
STA DSTL
LDY #$00
STY DSTL
LDA #$D0
STA DSTH
LDY #$00
- LDA (SRC),Y ; COPY VM+CMD INTO LANGUAGE CARD
STA (DST),Y
INY
@ -118,7 +117,6 @@ RAMDONE CLI
;*
;* MOVE FIRST PAGE OF 'BYE' INTO PLACE
;*
LDY #$00
STY SRCL
LDA #$D1
STA SRCH

View File

@ -188,25 +188,26 @@ asm memset
LDA ESTKH+2,X
STA DSTH
LDY ESTKL,X
BEQ +
BEQ +
INC ESTKH,X
LDY #$00
+ LDA ESTKH,X
BEQ SETMEX
+ LDA ESTKH,X
BEQ SETMEX
SETMLPL CLC
LDA ESTKL+1,X
SETMLPH STA (DST),Y
DEC ESTKL,X
BNE +
DEC ESTKH,X
BEQ SETMEX
+ INY
BNE +
INC DSTH
+ BCS SETMLPL
BEQ ++
- INY
BEQ +
-- BCS SETMLPL
SEC
LDA ESTKH+1,X
BCS SETMLPH
BCS SETMLPH
+ INC DSTH
BNE --
++ DEC ESTKH,X
BNE -
SETMEX INX
INX
RTS
@ -361,9 +362,10 @@ asm uword_isge
CMP ESTKL,X
LDA ESTKH+1,X
SBC ESTKH,X
BCC +
DEY
+ STY ESTKL+1,X
LDA #$FF
ADC #$00
EOR #$FF
STY ESTKL+1,X
STY ESTKH+1,X
INX
RTS
@ -374,9 +376,10 @@ asm uword_isle
CMP ESTKL+1,X
LDA ESTKH,X
SBC ESTKH+1,X
BCC +
DEY
+ STY ESTKL+1,X
LDA #$FF
ADC #$00
EOR #$FF
STY ESTKL+1,X
STY ESTKH+1,X
INX
RTS
@ -541,7 +544,7 @@ asm modtosym
LDY #$00
LDA #'#'+$80
- STA (DST),Y
CMP #$80
ASL
LDA (SRC),Y
INY
BCS -
@ -587,7 +590,7 @@ asm lookuptbl
CMP (SRC),Y
BNE ++
INY
CMP #$80
ASL
BCS -
LDA (DST),Y
PHA
@ -604,9 +607,8 @@ asm lookuptbl
++ LDY #$00
-- LDA (DST),Y
INC DSTL
BNE +
INC DSTH
+ CMP #$80
BEQ +
--- ASL
BCS --
LDA #$02
ADC DSTL
@ -614,6 +616,8 @@ asm lookuptbl
BCC -
INC DSTH
BCS -
+ INC DSTH
BNE ---
end
//
// SOS routines