Skip to content

Commit

Permalink
Optimize EXIT, C!, C@ and 0= (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
KarolS authored Apr 21, 2022
1 parent 597162e commit b6d4654
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions control.asm
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ EXIT
lda HERE_LSB
sec
sbc #3
sta .instr_ptr
tay
lda HERE_MSB
sbc #0
sta .instr_ptr + 1
lda #OP_JMP
.instr_ptr = * + 1
sta PLACEHOLDER_ADDRESS ; replaced with instruction pointer
sta PLACEHOLDER_ADDRESS,y ; replaced with instruction pointer
rts
+
lda #OP_RTS
Expand Down
14 changes: 6 additions & 8 deletions core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ EQUAL
+BACKLINK "0=", 2
ZEQU
ldy #0
lda MSB, x
bne +
lda LSB, x
bne +
lda MSB, x
bne +
dey
+ sty MSB, x
sty LSB, x
Expand Down Expand Up @@ -179,23 +179,21 @@ FETCH

+BACKLINK "c!", 2
STOREBYTE
lda LSB,x
sta + + 1
ldy LSB,x
lda MSB,x
sta + + 2
lda LSB+1,x
+ sta PLACEHOLDER_ADDRESS ; replaced with addr
+ sta PLACEHOLDER_ADDRESS,y ; replaced with addr
inx
inx
rts

+BACKLINK "c@", 2
FETCHBYTE
lda LSB,x
sta + + 1
ldy LSB,x
lda MSB,x
sta + + 2
+ lda PLACEHOLDER_ADDRESS ; replaced with addr
+ lda PLACEHOLDER_ADDRESS,y ; replaced with addr
sta LSB,x
lda #0
sta MSB,x
Expand Down
3 changes: 2 additions & 1 deletion durexforth.asm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ K_CLRSCR = $93
K_SPACE = ' '

; PLACEHOLDER_ADDRESS instances are overwritten using self-modifying code.
PLACEHOLDER_ADDRESS = $1234
; It must end in 00 for situations where the Y register is used as the LSB of the address.
PLACEHOLDER_ADDRESS = $1200

!ct pet

Expand Down

0 comments on commit b6d4654

Please sign in to comment.