diff --git a/emul/Makefile b/emul/Makefile index 6f92073..17e6991 100644 --- a/emul/Makefile +++ b/emul/Makefile @@ -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 diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index 5bd02a5..227d7c5 100644 Binary files a/emul/forth/z80c.bin and b/emul/forth/z80c.bin differ diff --git a/forth/forth.asm b/forth/forth.asm index 865ec23..53c53be 100644 --- a/forth/forth.asm +++ b/forth/forth.asm @@ -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: diff --git a/forth/z80a.fs b/forth/z80a.fs index 331e86d..46b58d6 100644 --- a/forth/z80a.fs +++ b/forth/z80a.fs @@ -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, ; diff --git a/forth/z80c.fs b/forth/z80c.fs index 1e8c078..5770e07 100644 --- a/forth/z80c.fs +++ b/forth/z80c.fs @@ -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