From f89e7bd5039a26d73a04862f8b4d91a5cca01fd8 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 11 Mar 2020 22:11:54 -0400 Subject: [PATCH] forth: add words "C@" and "C!" --- apps/forth/dict.asm | 27 +++++++++++++++++++++++++-- apps/forth/dictionary.txt | 2 ++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/apps/forth/dict.asm b/apps/forth/dict.asm index 2f501fc..e555f65 100644 --- a/apps/forth/dict.asm +++ b/apps/forth/dict.asm @@ -389,10 +389,21 @@ STORE: ld (iy+1), h jp exit +; ( n a -- ) + .db "C!" + .fill 6 + .dw STORE +CSTORE: + .dw nativeWord + pop hl + pop de + ld (hl), e + jp exit + ; ( a -- n ) .db "@" .fill 7 - .dw STORE + .dw CSTORE FETCH: .dw nativeWord pop hl @@ -400,10 +411,22 @@ FETCH: push hl 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 ) .db "LIT@" .fill 4 - .dw FETCH + .dw CFETCH LITFETCH: .dw nativeWord call readLITTOS diff --git a/apps/forth/dictionary.txt b/apps/forth/dictionary.txt index d8296a2..061bb55 100644 --- a/apps/forth/dictionary.txt +++ b/apps/forth/dictionary.txt @@ -60,6 +60,8 @@ SWAP a b -- b a ! n a -- Store n in address a ? a -- Print value of addr a +! 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. HERE -- a Push HERE's address