1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 12:48:07 +11:00

forth: Forth-ify "I", "I'", "J"

This commit is contained in:
Virgil Dupras 2020-03-26 14:11:22 -04:00
parent cf2f6703bb
commit e82f13acf1
4 changed files with 47 additions and 35 deletions

Binary file not shown.

View File

@ -1313,39 +1313,9 @@ R2P:
push hl
jp next
.db "I"
.dw $-R2P
.db 1
I:
.dw nativeWord
ld l, (ix)
ld h, (ix+1)
push hl
jp next
.db "I'"
.dw $-I
.db 2
IPRIME:
.dw nativeWord
ld l, (ix-2)
ld h, (ix-1)
push hl
jp next
.db "J"
.dw $-IPRIME
.db 1
J:
.dw nativeWord
ld l, (ix-4)
ld h, (ix-3)
push hl
jp next
; ( a b -- c ) A + B
.db "+"
.dw $-J
.dw $-R2P
.db 1
PLUS:
.dw nativeWord

View File

@ -26,6 +26,12 @@
extra 0xdd / 0xfd and then spit the equivalent of HL )
: IX 0xdd A, HL ;
: IY 0xfd A, HL ;
: _ix+- 0xff AND 0xdd A, (HL) ;
: _iy+- 0xff AND 0xfd A, (HL) ;
: IX+ _ix+- ;
: IX- 0 -^ _ix+- ;
: IY+ _iy+- ;
: IY- 0 -^ _iy+- ;
( -- )
: OP1 CREATE C, DOES> C@ A, ;
@ -77,17 +83,35 @@
0x03 OP1qq INCss,
0x09 OP1qq ADDHLss,
( rd rr )
: OP1rr
CREATE C,
DOES>
: _1rr
C@ ( rd rr op )
ROT ( rr op rd )
8 * ( rr op rd<<3 )
OR OR A,
;
( rd rr )
: OP1rr
CREATE C,
DOES>
_1rr
;
0x40 OP1rr LDrr,
( ixy+- HL rd )
: LDIXYr,
( dd/fd has already been spit )
LDrr, ( ixy+- )
A,
;
( rd ixy+- HL )
: LDrIXY,
ROT ( ixy+- HL rd )
SWAP ( ixy+- rd HL )
LDIXYr,
;
( n -- )
: OP2n
CREATE C,

View File

@ -168,3 +168,21 @@ CODE PC@
L INr(C),
HL PUSHqq,
;CODE
CODE I
L 0 IX+ LDrIXY,
H 1 IX+ LDrIXY,
HL PUSHqq,
;CODE
CODE I'
L 2 IX- LDrIXY,
H 1 IX- LDrIXY,
HL PUSHqq,
;CODE
CODE J
L 4 IX- LDrIXY,
H 3 IX- LDrIXY,
HL PUSHqq,
;CODE