mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 21:18:05 +11:00
forth: Forth-ify "AND"
This commit is contained in:
parent
6c5f39806b
commit
f0ab57c8cc
@ -44,7 +44,7 @@ forth/stage1dbg: forth/stage.c $(OBJS) forth/forth0-bin.h
|
|||||||
forth/core.bin: $(FORTHSRC_PATHS) forth/stage1
|
forth/core.bin: $(FORTHSRC_PATHS) forth/stage1
|
||||||
cat $(FORTHSRC_PATHS) | ./forth/stage1 | tee $@ > /dev/null
|
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
|
$(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
|
forth/forth1-bin.h: forth/forth1.bin
|
||||||
|
Binary file not shown.
@ -166,30 +166,31 @@ INTERPRET:
|
|||||||
.dw FIND_
|
.dw FIND_
|
||||||
.dw CSKIP
|
.dw CSKIP
|
||||||
.dw FBR
|
.dw FBR
|
||||||
.db 32
|
.db 18
|
||||||
; It's a word, execute it
|
; It's a word, execute it
|
||||||
.dw FLAGS_
|
; For now, we only have one flag, let's take advantage of
|
||||||
.dw FETCH
|
; this to keep code simple.
|
||||||
.dw ONE ; Bit 0 on
|
.dw ONE ; Bit 0 on
|
||||||
.dw OR
|
|
||||||
.dw FLAGS_
|
.dw FLAGS_
|
||||||
.dw STORE
|
.dw STORE
|
||||||
.dw EXECUTE
|
.dw EXECUTE
|
||||||
.dw FLAGS_
|
.dw ZERO ; Bit 0 off
|
||||||
.dw FETCH
|
|
||||||
.dw NUMBER
|
|
||||||
.dw 0xfffe ; Bit 0 off
|
|
||||||
.dw AND
|
|
||||||
.dw FLAGS_
|
.dw FLAGS_
|
||||||
.dw STORE
|
.dw STORE
|
||||||
.dw BBR
|
.dw BBR
|
||||||
.db 39
|
.db 25
|
||||||
; FBR mark, try number
|
; FBR mark, try number
|
||||||
.dw PARSEI
|
.dw PARSEI
|
||||||
.dw BBR
|
.dw BBR
|
||||||
.db 44
|
.db 30
|
||||||
; infinite loop
|
; 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 ***
|
; *** Collapse OS lib copy ***
|
||||||
; In the process of Forth-ifying Collapse OS, apps will be slowly rewritten to
|
; 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
|
; Forth and the concept of ASM libs will become obsolete. To facilitate this
|
||||||
@ -1559,27 +1560,9 @@ DIVMOD:
|
|||||||
jp next
|
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"
|
.db "OR"
|
||||||
.fill 5
|
.fill 5
|
||||||
.dw $-AND
|
.dw $-DIVMOD
|
||||||
.db 0
|
.db 0
|
||||||
OR:
|
OR:
|
||||||
.dw nativeWord
|
.dw nativeWord
|
||||||
@ -1764,4 +1747,3 @@ BBR:
|
|||||||
.db "_______"
|
.db "_______"
|
||||||
.dw $-BBR
|
.dw $-BBR
|
||||||
.db 0
|
.db 0
|
||||||
LATEST:
|
|
||||||
|
@ -45,6 +45,15 @@
|
|||||||
0x46 OP1r LDr(HL),
|
0x46 OP1r LDr(HL),
|
||||||
0x70 OP1r LD(HL)r,
|
0x70 OP1r LD(HL)r,
|
||||||
|
|
||||||
|
( r -- )
|
||||||
|
: OP1r0
|
||||||
|
CREATE C,
|
||||||
|
DOES>
|
||||||
|
C@ ( r op )
|
||||||
|
OR A,
|
||||||
|
;
|
||||||
|
0xa0 OP1r0 ANDr,
|
||||||
|
|
||||||
( qq -- also works for ss )
|
( qq -- also works for ss )
|
||||||
: OP1qq
|
: OP1qq
|
||||||
CREATE C,
|
CREATE C,
|
||||||
@ -138,3 +147,6 @@
|
|||||||
|
|
||||||
: ;CODE JPNEXT, ;
|
: ;CODE JPNEXT, ;
|
||||||
|
|
||||||
|
|
||||||
|
( Routines )
|
||||||
|
: chkPS, ROUTINE P [LITN] CALLnn, ;
|
||||||
|
@ -71,3 +71,15 @@ CODE 2SWAP
|
|||||||
BC PUSHqq, ( B )
|
BC PUSHqq, ( B )
|
||||||
;CODE
|
;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
|
||||||
|
Loading…
Reference in New Issue
Block a user