1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-30 22:08:08 +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 push hl
jp next 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 ; ( a b -- c ) A + B
.db "+" .db "+"
.dw $-J .dw $-R2P
.db 1 .db 1
PLUS: PLUS:
.dw nativeWord .dw nativeWord

View File

@ -26,6 +26,12 @@
extra 0xdd / 0xfd and then spit the equivalent of HL ) extra 0xdd / 0xfd and then spit the equivalent of HL )
: IX 0xdd A, HL ; : IX 0xdd A, HL ;
: IY 0xfd 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, ; : OP1 CREATE C, DOES> C@ A, ;
@ -77,17 +83,35 @@
0x03 OP1qq INCss, 0x03 OP1qq INCss,
0x09 OP1qq ADDHLss, 0x09 OP1qq ADDHLss,
( rd rr ) : _1rr
: OP1rr
CREATE C,
DOES>
C@ ( rd rr op ) C@ ( rd rr op )
ROT ( rr op rd ) ROT ( rr op rd )
8 * ( rr op rd<<3 ) 8 * ( rr op rd<<3 )
OR OR A, OR OR A,
; ;
( rd rr )
: OP1rr
CREATE C,
DOES>
_1rr
;
0x40 OP1rr LDrr, 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 -- ) ( n -- )
: OP2n : OP2n
CREATE C, CREATE C,

View File

@ -168,3 +168,21 @@ CODE PC@
L INr(C), L INr(C),
HL PUSHqq, HL PUSHqq,
;CODE ;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