1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 16:38:05 +11:00

forth: Forth-ify "NOT"

This commit is contained in:
Virgil Dupras 2020-03-30 17:26:51 -04:00
parent 4756fb7763
commit de3da19333
4 changed files with 20 additions and 27 deletions

Binary file not shown.

View File

@ -743,30 +743,10 @@ FIND_:
push de push de
jp next jp next
.fill 41 .fill 427
.db "NOT"
.dw $-FIND_
.db 3
NOT:
.dw nativeWord
pop hl
call chkPS
ld a, l
or h
ld hl, 0
jr nz, .skip ; true, keep at 0
; false, make 1
inc hl
.skip:
push hl
jp next
.fill 362
.db "_bend" .db "_bend"
.dw $-NOT .dw $-FIND_
.db 5 .db 5
; Offset: 0647 ; Offset: 0647
.out $ .out $

View File

@ -85,7 +85,7 @@
( This is only the "early parser" in earlier stages. No need ( This is only the "early parser" in earlier stages. No need
for an abort message ) for an abort message )
: (parse) : (parse)
_c (parsed) NOT IF _c ABORT THEN _c (parsed) _c NOT IF _c ABORT THEN
; ;
( a -- ) ( a -- )
@ -94,7 +94,7 @@
_c DUP ( a a ) _c DUP ( a a )
_c C@ ( a c ) _c C@ ( a c )
( exit if null ) ( exit if null )
_c DUP NOT IF _c 2DROP EXIT THEN _c DUP _c NOT IF _c 2DROP EXIT THEN
_c EMIT ( a ) _c EMIT ( a )
1 _c + ( a+1 ) 1 _c + ( a+1 )
AGAIN AGAIN
@ -117,11 +117,11 @@
( 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 _c + NOT ; : WS? 33 _c CMP 1 _c + _c NOT ;
: TOWORD : TOWORD
BEGIN BEGIN
_c C< _c DUP _c WS? NOT IF EXIT THEN _c DROP _c C< _c DUP _c WS? _c NOT IF EXIT THEN _c DROP
AGAIN AGAIN
; ;
@ -176,7 +176,7 @@
: BOOT : BOOT
LIT< (parse) (find) _c DROP _c (parse*) _c ! LIT< (parse) (find) _c DROP _c (parse*) _c !
LIT< (c<) (find) NOT IF LIT< KEY (find) _c DROP THEN LIT< (c<) (find) _c NOT IF LIT< KEY (find) _c DROP THEN
( 48 == CINPTR ) ( 48 == CINPTR )
[ 48 @ LITN ] _c ! [ 48 @ LITN ] _c !
LIT< (c<$) (find) IF EXECUTE ELSE _c DROP THEN LIT< (c<$) (find) IF EXECUTE ELSE _c DROP THEN

View File

@ -149,6 +149,19 @@ CODE XOR
HL PUSHqq, HL PUSHqq,
;CODE ;CODE
CODE NOT
HL POPqq,
chkPS,
A L LDrr,
H ORr,
HL 0 LDddnn,
3 JRNZe, ( skip)
( false, make 1 )
HL INCss,
( skip )
HL PUSHqq,
;CODE
CODE + CODE +
HL POPqq, HL POPqq,
DE POPqq, DE POPqq,