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

This commit is contained in:
Virgil Dupras 2020-03-10 13:00:57 -04:00
parent e95614755b
commit aac0a57a68
2 changed files with 26 additions and 1 deletions

View File

@ -211,10 +211,33 @@ EMIT:
call stdioPutC call stdioPutC
jp exit jp exit
; ( c port -- )
.db "PC!"
.fill 5
.dw EMIT
PSTORE:
.dw nativeWord
pop bc
pop hl
out (c), l
jp exit
; ( port -- c )
.db "PC@"
.fill 5
.dw PSTORE
PFETCH:
.dw nativeWord
pop bc
ld h, 0
in l, (c)
push hl
jp exit
; ( addr -- ) ; ( addr -- )
.db "EXECUTE" .db "EXECUTE"
.db 0 .db 0
.dw EMIT .dw PFETCH
EXECUTE: EXECUTE:
.dw nativeWord .dw nativeWord
pop iy ; is a wordref pop iy ; is a wordref

View File

@ -70,4 +70,6 @@ HERE -- a Push HERE's address
. n -- Print n in its decimal form . n -- Print n in its decimal form
EMIT c -- Spit char c to stdout EMIT c -- Spit char c to stdout
KEY -- c Get char c from stdin KEY -- c Get char c from stdin
PC! c a -- Spit c to port a
PC@ a -- c Fetch c from port a