mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-30 22:38:09 +11:00
forth: Forth-ify "+"
This commit is contained in:
parent
a2c258afba
commit
9cfddea940
Binary file not shown.
@ -967,24 +967,10 @@ OVER:
|
|||||||
jp next
|
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"
|
.db "_bend"
|
||||||
.dw $-PLUS
|
.dw $-OVER
|
||||||
.db 5
|
.db 5
|
||||||
; Offset: 06ee
|
; Offset: 06ee
|
||||||
.out $
|
.out $
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
( exit if null )
|
( exit if null )
|
||||||
DUP NOT IF DROP DROP EXIT THEN
|
DUP NOT IF DROP DROP EXIT THEN
|
||||||
_c EMIT ( a )
|
_c EMIT ( a )
|
||||||
1 + ( a+1 )
|
1 _c + ( a+1 )
|
||||||
AGAIN
|
AGAIN
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -75,13 +75,13 @@
|
|||||||
|
|
||||||
: C,
|
: C,
|
||||||
HERE @ _c C!
|
HERE @ _c C!
|
||||||
HERE @ 1 + HERE !
|
HERE @ 1 _c + HERE !
|
||||||
;
|
;
|
||||||
|
|
||||||
( The NOT is to normalize the negative/positive numbers to 1
|
( The NOT is to normalize the negative/positive numbers to 1
|
||||||
or 0. Hadn't we wanted to normalize, we'd have written:
|
or 0. Hadn't we wanted to normalize, we'd have written:
|
||||||
32 CMP 1 - )
|
32 CMP 1 - )
|
||||||
: WS? 33 _c CMP 1 + NOT ;
|
: WS? 33 _c CMP 1 _c + NOT ;
|
||||||
|
|
||||||
: TOWORD
|
: TOWORD
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -99,7 +99,7 @@
|
|||||||
( We take advantage of the fact that char MSB is
|
( We take advantage of the fact that char MSB is
|
||||||
always zero to pre-write our null-termination )
|
always zero to pre-write our null-termination )
|
||||||
OVER ! ( a )
|
OVER ! ( a )
|
||||||
1 + ( a+1 )
|
1 _c + ( a+1 )
|
||||||
C< ( a c )
|
C< ( a c )
|
||||||
DUP _c WS?
|
DUP _c WS?
|
||||||
UNTIL
|
UNTIL
|
||||||
@ -111,7 +111,7 @@
|
|||||||
|
|
||||||
: LITN
|
: LITN
|
||||||
( JTBL+24 == NUMBER )
|
( JTBL+24 == NUMBER )
|
||||||
JTBL 24 + ,
|
JTBL 24 _c + ,
|
||||||
,
|
,
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -111,6 +111,14 @@ CODE XOR
|
|||||||
HL PUSHqq,
|
HL PUSHqq,
|
||||||
;CODE
|
;CODE
|
||||||
|
|
||||||
|
CODE +
|
||||||
|
HL POPqq,
|
||||||
|
DE POPqq,
|
||||||
|
chkPS,
|
||||||
|
DE ADDHLss,
|
||||||
|
HL PUSHqq,
|
||||||
|
;CODE
|
||||||
|
|
||||||
CODE -
|
CODE -
|
||||||
DE POPqq,
|
DE POPqq,
|
||||||
HL POPqq,
|
HL POPqq,
|
||||||
|
Loading…
Reference in New Issue
Block a user