From 9cfddea9403bf15c218af52eebed54411e7b823b Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sat, 28 Mar 2020 15:33:14 -0400 Subject: [PATCH] forth: Forth-ify "+" --- emul/forth/z80c.bin | Bin 1098 -> 1114 bytes forth/forth.asm | 18 ++---------------- forth/icore.fs | 10 +++++----- forth/z80c.fs | 8 ++++++++ 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index 86b28776e310d0dc4e208e049ee61d29c12814b2..913ef961915687cda539b910db1bac0f9e31adba 100644 GIT binary patch delta 359 zcmX@baf@TZ5+Q9N21ap)hZoPvGDto>EXAP9yK&hTM#lS-qnRYN!Z;n7Gzy9`^GY;D z8QA$4!r6p5!r2b9+-Krouw=7jb7Yd^RA69an8rSN9+R?n11Cs>vyKb{6CcAxR#i4; z4iE`ZagkL3s6IT{UYdcKk3oS!k%0}W_b`hiQ;2`Ke~^m=0~;U1OqOuA7n6CIi&EnYb9<0Zr{-_UEc+y7k|Y$=Vd8Pl3UaiG#V90~9#%{0xi$ D4?#-# delta 343 zcmcb`af)NY5++@tjoY>`GM=BD%_OPi#_7nUQBahbSE4D(z|O}I&c@6U&UTpPJ`)Fn zC7UIiBNHE|0s|w%Ot#7En3TN>I6)embz~Tr_!us-s>cfNWr5Tv{ z7!(*38NP8qWDc`9GKKhu`vjS;!0wHSvQS6oDF258{0In6Yc}$r?GP|@8SfhxDR%Ur(cL` zP(YAth&=-*AA`{31I!*lv$-6ZtYjG)`4}R(6d3pzIGBaFYJlDq1A2WK2gutU%=Jtx qK=FDeE{1nNvpSgVx$2p2{dZ)tHU;TZU~pvOV6No=1x`Fa10w);&`22o diff --git a/forth/forth.asm b/forth/forth.asm index f31284b..b76d4c0 100644 --- a/forth/forth.asm +++ b/forth/forth.asm @@ -967,24 +967,10 @@ OVER: jp next -.fill 31 +.fill 112 -; ( a b -- c ) A + B - .db "+" - .dw $-OVER - .db 1 -PLUS: - .dw nativeWord - pop hl - pop de - call chkPS - add hl, de - push hl - jp next - -.fill 65 .db "_bend" - .dw $-PLUS + .dw $-OVER .db 5 ; Offset: 06ee .out $ diff --git a/forth/icore.fs b/forth/icore.fs index 663c843..072f4ca 100644 --- a/forth/icore.fs +++ b/forth/icore.fs @@ -65,7 +65,7 @@ ( exit if null ) DUP NOT IF DROP DROP EXIT THEN _c EMIT ( a ) - 1 + ( a+1 ) + 1 _c + ( a+1 ) AGAIN ; @@ -75,13 +75,13 @@ : C, HERE @ _c C! - HERE @ 1 + HERE ! + HERE @ 1 _c + HERE ! ; ( The NOT is to normalize the negative/positive numbers to 1 or 0. Hadn't we wanted to normalize, we'd have written: 32 CMP 1 - ) -: WS? 33 _c CMP 1 + NOT ; +: WS? 33 _c CMP 1 _c + NOT ; : TOWORD BEGIN @@ -99,7 +99,7 @@ ( We take advantage of the fact that char MSB is always zero to pre-write our null-termination ) OVER ! ( a ) - 1 + ( a+1 ) + 1 _c + ( a+1 ) C< ( a c ) DUP _c WS? UNTIL @@ -111,7 +111,7 @@ : LITN ( JTBL+24 == NUMBER ) - JTBL 24 + , + JTBL 24 _c + , , ; diff --git a/forth/z80c.fs b/forth/z80c.fs index edf882c..d1809a5 100644 --- a/forth/z80c.fs +++ b/forth/z80c.fs @@ -111,6 +111,14 @@ CODE XOR HL PUSHqq, ;CODE +CODE + + HL POPqq, + DE POPqq, + chkPS, + DE ADDHLss, + HL PUSHqq, +;CODE + CODE - DE POPqq, HL POPqq,