forth: Forth-ify "AND"

This commit is contained in:
Virgil Dupras 2020-03-24 22:09:52 -04:00
parent 6c5f39806b
commit f0ab57c8cc
5 changed files with 38 additions and 32 deletions

View File

@ -44,7 +44,7 @@ forth/stage1dbg: forth/stage.c $(OBJS) forth/forth0-bin.h
forth/core.bin: $(FORTHSRC_PATHS) forth/stage1
cat $(FORTHSRC_PATHS) | ./forth/stage1 | tee $@ > /dev/null
forth/forth1.bin: forth/stage1.asm forth/forth0.bin $(ZASMBIN)
forth/forth1.bin: forth/stage1.asm forth/forth0.bin forth/core.bin $(ZASMBIN)
$(ZASMBIN) $(KERNEL) ../forth forth/z80c.bin forth/core.bin forth/stagec.asm < forth/stage1.asm | tee $@ > /dev/null
forth/forth1-bin.h: forth/forth1.bin

Binary file not shown.

View File

@ -166,30 +166,31 @@ INTERPRET:
.dw FIND_
.dw CSKIP
.dw FBR
.db 32
.db 18
; It's a word, execute it
.dw FLAGS_
.dw FETCH
; For now, we only have one flag, let's take advantage of
; this to keep code simple.
.dw ONE ; Bit 0 on
.dw OR
.dw FLAGS_
.dw STORE
.dw EXECUTE
.dw FLAGS_
.dw FETCH
.dw NUMBER
.dw 0xfffe ; Bit 0 off
.dw AND
.dw ZERO ; Bit 0 off
.dw FLAGS_
.dw STORE
.dw BBR
.db 39
.db 25
; FBR mark, try number
.dw PARSEI
.dw BBR
.db 44
.db 30
; infinite loop
; Oops, I forgot to create a stable ABI before starting to rely on stability...
; I'll fix this soon, but for now, I need to offset a recent simplification
; I've made in INTERPRET above. If we don't, z80c.bin doesn't refer to proper
; routine addresses...
.fill 14
; *** Collapse OS lib copy ***
; In the process of Forth-ifying Collapse OS, apps will be slowly rewritten to
; Forth and the concept of ASM libs will become obsolete. To facilitate this
@ -1559,27 +1560,9 @@ DIVMOD:
jp next
.db "AND"
.fill 4
.dw $-DIVMOD
.db 0
AND:
.dw nativeWord
pop hl
pop de
call chkPS
ld a, e
and l
ld l, a
ld a, d
and h
ld h, a
push hl
jp next
.db "OR"
.fill 5
.dw $-AND
.dw $-DIVMOD
.db 0
OR:
.dw nativeWord
@ -1764,4 +1747,3 @@ BBR:
.db "_______"
.dw $-BBR
.db 0
LATEST:

View File

@ -45,6 +45,15 @@
0x46 OP1r LDr(HL),
0x70 OP1r LD(HL)r,
( r -- )
: OP1r0
CREATE C,
DOES>
C@ ( r op )
OR A,
;
0xa0 OP1r0 ANDr,
( qq -- also works for ss )
: OP1qq
CREATE C,
@ -138,3 +147,6 @@
: ;CODE JPNEXT, ;
( Routines )
: chkPS, ROUTINE P [LITN] CALLnn, ;

View File

@ -71,3 +71,15 @@ CODE 2SWAP
BC PUSHqq, ( B )
;CODE
CODE AND
HL POPqq,
DE POPqq,
chkPS,
A E LDrr,
L ANDr,
L A LDrr,
A D LDrr,
H ANDr,
H A LDrr,
HL PUSHqq,
;CODE