Skip to content

Commit

Permalink
Forth: fix mishandling of LOCALS
Browse files Browse the repository at this point in the history
  • Loading branch information
adumont committed Mar 29, 2022
1 parent 4a1b5d1 commit cea57a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions bootstrap.f
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@

>ROM

: LOCALS BP @ DUP ROT 2* - DUP -ROT ! BP ! ;
: -LOCALS BP DUP @ @ SWAP ! ; \ ( n -- ) Dellocates n local variables
: LOCALS 1+ BP @ DUP ROT 2* - DUP -ROT ! BP ! ; \ ( n -- ) Allocates n local variables
: -LOCALS BP DUP @ @ SWAP ! ; \ Dellocates n local variables

: L@ BP @ + @ ; \ ; ( n -- value) helper word to get local var n
: L! BP @ + ! ; \ ; ( n -- value) helper word to save to local var n
Expand All @@ -87,7 +87,8 @@

: RECURSIVE REVEAL ; IMMEDIATE

: DUMP SWAP DUP . DO I C@ C. LOOP ; \ ( addr1 addr2 -- ) dumps memory from addr1 to addr2
: DUMP SWAP DUP . ?DO I C@ C. LOOP ; \ ( addr1 addr2 -- ) dumps memory from addr1 to addr2
: .LDUMP BP @ 4000 DUMP ; \ dump local stack

: .NAME DUP 2+ DUP C@ DUP 40 AND >R 1F AND SWAP
1+ SWAP TYPE R> IF SPACE 2A EMIT THEN ;
Expand Down
2 changes: 1 addition & 1 deletion forth.s
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ROW = LINE - 1
COL = ROW - 1

VRAM = $F800
BP = $F000 - 2 ; top of LOCALS stack (grows down). Right below the character memory
BP = $F000 ; top of LOCALS stack (grows down). Right below the character memory

MIN_ROW = 0 ; we can set that any value in [0,28] to split the screen
MAX_ROW = 30 ; Row will go from MIN_ROW to MAX_ROW-1
Expand Down

0 comments on commit cea57a9

Please sign in to comment.