(asma) Optimise advancing asma/addr

This commit is contained in:
Andrew Alderwick 2022-06-08 00:38:55 +01:00
parent 9ae2c0b788
commit 02696fa437
1 changed files with 16 additions and 14 deletions

View File

@ -520,21 +520,26 @@
;asma/lit LDA2 ,&present JCN ;asma/lit LDA2 ,&present JCN
,asma-flush-held JSR ,asma-flush-held JSR
POP #01 ;asma/lit STA2 POP #01 ;asma/lit STA2
;asma/addr LDA2k INC2 INC2 SWP2 STA2 #0002 ,asma-advance-addr JMP ( tail call )
JMP2r
&present &present
;asma/addr LDA2k #0002 SUB2 SWP2 STA2 #fffe ,asma-advance-addr JSR
LIT LIT2 ,asma-write-byte/raw JSR LIT LIT2 ,asma-write-byte/raw JSR
,asma-write-byte/raw JSR ,asma-write-byte/raw JSR
,asma-write-byte/raw JSR ,asma-write-byte/raw JSR
#0000 ;asma/lit STA2 #0000 ;asma/lit STA2
JMP2r JMP2r
@asma-advance-addr ( delta* -- )
;asma/addr LDA2k ( delta* ptr* value* )
ROT2 ADD2 ( ptr* new-value* )
SWP2 STA2
JMP2r
@asma-flush-held ( -- ) @asma-flush-held ( -- )
;asma/lit LDA2 ,&lit-present JCN ;asma/lit LDA2 ,&lit-present JCN
POP ,&part2 JMP POP ,&part2 JMP
&lit-present &lit-present
;asma/addr LDA2k #0002 SUB2 SWP2 STA2 #fffe ,asma-advance-addr JSR
LIT LIT ,asma-write-byte/raw JSR LIT LIT ,asma-write-byte/raw JSR
,asma-write-byte/raw JSR ,asma-write-byte/raw JSR
#0000 ;asma/lit STA2 #0000 ;asma/lit STA2
@ -543,7 +548,7 @@
;asma/jsr LDA DUP ,&jsr-present JCN ;asma/jsr LDA DUP ,&jsr-present JCN
POP JMP2r POP JMP2r
&jsr-present &jsr-present
;asma/addr LDA2k #0001 SUB2 SWP2 STA2 #ffff ,asma-advance-addr JSR
,asma-write-byte/raw JSR ,asma-write-byte/raw JSR
#00 ;asma/jsr STA #00 ;asma/jsr STA
JMP2r JMP2r
@ -710,24 +715,22 @@
@asma-pad-absolute @asma-pad-absolute
;asma-flush-held JSR2 ;asma-flush-held JSR2
#0000 ,asma-pad-helper JMP #0000 ;asma/addr STA2
,asma-pad-helper JMP
@asma-pad-relative @asma-pad-relative
;asma-flush-held JSR2 ;asma-flush-held JSR2
;asma/addr LDA2
( fall through ) ( fall through )
@asma-pad-helper ( offset* -- ) @asma-pad-helper ( -- )
#00 ;asma-parse-hex-string JSR2 #00 ;asma-parse-hex-string JSR2
,&valid JCN ,&valid JCN
;asma-msg-hex ;asma/error STA2 ;asma-msg-hex ;asma/error STA2
POP2
JMP2r JMP2r
&valid &valid
ADD2 ;asma/addr STA2 ;asma-advance-addr JMP2 ( tail call )
JMP2r
@asma-raw-char @asma-raw-char
;asma/token LDA2 LDA ;asma/token LDA2 LDA
@ -869,14 +872,13 @@
&hold-jsr &hold-jsr
;asma-flush-held JSR2 ;asma-flush-held JSR2
;asma/jsr STA ;asma/jsr STA
;asma/addr LDA2k INC2 SWP2 STA2 #0001 ;asma-advance-addr JMP2 ( tail call )
JMP2r
&optimise-jsr-jmp2r &optimise-jsr-jmp2r
POP POP
;asma/jsr LDAk #00 SWP2 STA ;asma/jsr LDAk #00 SWP2 STA
#e0 AND [ LIT JMP ] ORA #e0 AND [ LIT JMP ] ORA
;asma/addr LDA2k #0001 SUB2 SWP2 STA2 #ffff ;asma-advance-addr JSR2
,&write-opcode JMP ,&write-opcode JMP
&not-opcode &not-opcode