From 005dd98fc2b309afbca2b5d2857eec941d428606 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Fri, 27 Mar 2020 11:27:40 -0400 Subject: [PATCH] forth: Forth-ify "R>" and ">R" --- emul/forth/z80c.bin | Bin 509 -> 620 bytes forth/dictionary.txt | 2 +- forth/forth.asm | 34 ++++++++++------------------------ forth/icore.fs | 20 +++++++++++--------- forth/z80c.fs | 13 +++++++++++++ 5 files changed, 35 insertions(+), 34 deletions(-) diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index accf95172cdc0811a486456f93f8bc3b16efc965..532dc5ad02ef8e761d8fb3235e4a1b8353ff522d 100644 GIT binary patch delta 209 zcmey%{Dx&iI-{Ch5FZ1RIK#uUvJ7Vh84gP^1lfTF&WbQR1@bgfb2Cdc`6uTwYSbr5 zC@`=wtYiykQ($0V)Ra_UU|}eNlLhR^GOS=35cz@=p`Hya3L@)~MA^ZjAd-XGk;&69 z#5E`&$Tg&xf%6sPca|EKcWid-VhRkCZ!^kCS?e$~zG75haAe|Oe#>FW2EvX^@xly@ E0JXg-asU7T delta 83 zcmaFE@|Sr-IwQMAYHntUrqJYGMh&wJ2?Yi=hLvmz3R" - .dw $-OVER - .db 2 -P2R: - .dw nativeWord - pop hl - call chkPS - call pushRS - jp next - .db "R>" - .dw $-P2R - .db 2 -R2P: - .dw nativeWord - call popRS - push hl - jp next +.fill 31 ; ( a b -- c ) A + B .db "+" - .dw $-R2P + .dw $-OVER .db 1 PLUS: .dw nativeWord diff --git a/forth/icore.fs b/forth/icore.fs index f2f8882..d7ab7ba 100644 --- a/forth/icore.fs +++ b/forth/icore.fs @@ -41,15 +41,6 @@ , ( write! ) ; IMMEDIATE -: X ( can't have its real name now ) - ['] EXIT , - R> DROP ( exit COMPILE ) - R> DROP ( exit : ) -; IMMEDIATE - -( Give ";" its real name ) -';' CURRENT @ 4 - C! - : INTERPRET BEGIN WORD @@ -63,3 +54,14 @@ THEN AGAIN ; + +( ; has to be defined last because it can't be executed now ) +: X ( can't have its real name now ) + ['] EXIT , + _c R> DROP ( exit COMPILE ) + _c R> DROP ( exit : ) +; IMMEDIATE + +( Give ";" its real name ) +';' CURRENT @ 4 - C! + diff --git a/forth/z80c.fs b/forth/z80c.fs index 183d848..e55364d 100644 --- a/forth/z80c.fs +++ b/forth/z80c.fs @@ -207,3 +207,16 @@ CODE J H 3 IX- LDrIXY, HL PUSHqq, ;CODE + +CODE >R + HL POPqq, + chkPS, + ( JUMPTBL+0 == pushRS ) + ROUTINE J CALLnn, +;CODE + +CODE R> + ( JUMPTBL+3 == popRS ) + ROUTINE J 3 + CALLnn, + HL PUSHqq, +;CODE