forth: add words "C@" and "C!"

This commit is contained in:
Virgil Dupras 2020-03-11 22:11:54 -04:00
parent 80f63cd185
commit f89e7bd503
2 changed files with 27 additions and 2 deletions

View File

@ -389,10 +389,21 @@ STORE:
ld (iy+1), h ld (iy+1), h
jp exit jp exit
; ( n a -- )
.db "C!"
.fill 6
.dw STORE
CSTORE:
.dw nativeWord
pop hl
pop de
ld (hl), e
jp exit
; ( a -- n ) ; ( a -- n )
.db "@" .db "@"
.fill 7 .fill 7
.dw STORE .dw CSTORE
FETCH: FETCH:
.dw nativeWord .dw nativeWord
pop hl pop hl
@ -400,10 +411,22 @@ FETCH:
push hl push hl
jp exit jp exit
; ( a -- c )
.db "C@"
.fill 6
.dw FETCH
CFETCH:
.dw nativeWord
pop hl
ld l, (hl)
ld h, 0
push hl
jp exit
; ( -- a ) ; ( -- a )
.db "LIT@" .db "LIT@"
.fill 4 .fill 4
.dw FETCH .dw CFETCH
LITFETCH: LITFETCH:
.dw nativeWord .dw nativeWord
call readLITTOS call readLITTOS

View File

@ -60,6 +60,8 @@ SWAP a b -- b a
! n a -- Store n in address a ! n a -- Store n in address a
? a -- Print value of addr a ? a -- Print value of addr a
+! n a -- Increase value of addr a by n +! n a -- Increase value of addr a by n
C@ a -- c Set c to byte at address a
C! c a -- Store byte c in address a
CURRENT -- n Set n to wordref of last added entry. CURRENT -- n Set n to wordref of last added entry.
HERE -- a Push HERE's address HERE -- a Push HERE's address