Skip to content

Commit

Permalink
Forth: SP now returns ToS addr (before running SP)
Browse files Browse the repository at this point in the history
  • Loading branch information
adumont committed Feb 1, 2022
1 parent 13a5655 commit bcd2a62
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions forth.s
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,8 @@ defword "ROT",,
defword "SP",,
; Put Data Stack Pointer on the stack
TXA
INA
INA
STA 0,X
STZ 1,X
JMP DEX2_NEXT
Expand Down Expand Up @@ -2786,9 +2788,9 @@ BOOT_PRG:

; some more stack words
.BYTE " : NIP SWAP DROP ; " ; ( x1 x0 -- x0 ) removes second on stack
.BYTE " : PICK 2+ 2* SP + @ ; " ; ( xn ... x1 x0 n -- xn ... x1 x0 xn ) , removes n, push copy of xn on top. n>=0
.BYTE " : PICK 1+ 2* SP + @ ; " ; ( xn ... x1 x0 n -- xn ... x1 x0 xn ) , removes n, push copy of xn on top. n>=0
.BYTE " : DEPTH "
.BYTE .sprintf("%X", DTOP-2)
.BYTE .sprintf("%X", DTOP)
.BYTE " SP - 2/ ; "
.BYTE " : .S DEPTH DUP IF 1+ DUP 1 DO DUP I - PICK . LOOP CR THEN DROP ; " ; print stack, leave cells on stack

Expand Down

0 comments on commit bcd2a62

Please sign in to comment.