mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 23:18:05 +11:00
forth: Forth-ify "R>" and ">R"
This commit is contained in:
parent
1e7e696e4a
commit
005dd98fc2
Binary file not shown.
@ -54,7 +54,7 @@ IMMEDIATE -- Flag the latest defined word as immediate.
|
|||||||
LITN n -- Write number n as a literal.
|
LITN n -- Write number n as a literal.
|
||||||
[LITN] n -- *I* Immediate version of LITN.
|
[LITN] n -- *I* Immediate version of LITN.
|
||||||
ROUTINE x -- a Push the addr of the specified core routine
|
ROUTINE x -- a Push the addr of the specified core routine
|
||||||
C=cellWord L=compiledWord V=nativeWord N=next S=LIT
|
C=cellWord J=JUMPTBL V=nativeWord N=next S=LIT
|
||||||
M=NUMBER Y=sysvarWord D=doesWord
|
M=NUMBER Y=sysvarWord D=doesWord
|
||||||
VARIABLE c -- Creates cell x with 2 bytes allocation.
|
VARIABLE c -- Creates cell x with 2 bytes allocation.
|
||||||
|
|
||||||
|
@ -113,8 +113,10 @@
|
|||||||
; change bootstrap binaries have to be adjusted because they rely on them.
|
; change bootstrap binaries have to be adjusted because they rely on them.
|
||||||
; We're at 0 here
|
; We're at 0 here
|
||||||
jp forthMain
|
jp forthMain
|
||||||
.fill 0x17-$
|
.fill 0x11-$
|
||||||
JUMPTBL:
|
JUMPTBL:
|
||||||
|
jp pushRS
|
||||||
|
jp popRS
|
||||||
jp nativeWord
|
jp nativeWord
|
||||||
jp next
|
jp next
|
||||||
jp chkPS
|
jp chkPS
|
||||||
@ -782,13 +784,13 @@ ROUTINE:
|
|||||||
ld de, cellWord
|
ld de, cellWord
|
||||||
cp 'C'
|
cp 'C'
|
||||||
jr z, .end
|
jr z, .end
|
||||||
ld de, compiledWord
|
|
||||||
cp 'L'
|
|
||||||
jr z, .end
|
|
||||||
ld de, JUMPTBL
|
ld de, JUMPTBL
|
||||||
|
cp 'J'
|
||||||
|
jr z, .end
|
||||||
|
ld de, JUMPTBL+6
|
||||||
cp 'V'
|
cp 'V'
|
||||||
jr z, .end
|
jr z, .end
|
||||||
ld de, JUMPTBL+3
|
ld de, JUMPTBL+9
|
||||||
cp 'N'
|
cp 'N'
|
||||||
jr z, .end
|
jr z, .end
|
||||||
ld de, sysvarWord
|
ld de, sysvarWord
|
||||||
@ -803,7 +805,7 @@ ROUTINE:
|
|||||||
ld de, NUMBER
|
ld de, NUMBER
|
||||||
cp 'M'
|
cp 'M'
|
||||||
jr z, .end
|
jr z, .end
|
||||||
ld de, JUMPTBL+6
|
ld de, JUMPTBL+12
|
||||||
cp 'P'
|
cp 'P'
|
||||||
jr nz, .notgood
|
jr nz, .notgood
|
||||||
; continue to end on match
|
; continue to end on match
|
||||||
@ -1300,28 +1302,12 @@ OVER:
|
|||||||
push de
|
push de
|
||||||
jp next
|
jp next
|
||||||
|
|
||||||
.db ">R"
|
|
||||||
.dw $-OVER
|
|
||||||
.db 2
|
|
||||||
P2R:
|
|
||||||
.dw nativeWord
|
|
||||||
pop hl
|
|
||||||
call chkPS
|
|
||||||
call pushRS
|
|
||||||
jp next
|
|
||||||
|
|
||||||
.db "R>"
|
.fill 31
|
||||||
.dw $-P2R
|
|
||||||
.db 2
|
|
||||||
R2P:
|
|
||||||
.dw nativeWord
|
|
||||||
call popRS
|
|
||||||
push hl
|
|
||||||
jp next
|
|
||||||
|
|
||||||
; ( a b -- c ) A + B
|
; ( a b -- c ) A + B
|
||||||
.db "+"
|
.db "+"
|
||||||
.dw $-R2P
|
.dw $-OVER
|
||||||
.db 1
|
.db 1
|
||||||
PLUS:
|
PLUS:
|
||||||
.dw nativeWord
|
.dw nativeWord
|
||||||
|
@ -41,15 +41,6 @@
|
|||||||
, ( write! )
|
, ( write! )
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
|
|
||||||
: X ( can't have its real name now )
|
|
||||||
['] EXIT ,
|
|
||||||
R> DROP ( exit COMPILE )
|
|
||||||
R> DROP ( exit : )
|
|
||||||
; IMMEDIATE
|
|
||||||
|
|
||||||
( Give ";" its real name )
|
|
||||||
';' CURRENT @ 4 - C!
|
|
||||||
|
|
||||||
: INTERPRET
|
: INTERPRET
|
||||||
BEGIN
|
BEGIN
|
||||||
WORD
|
WORD
|
||||||
@ -63,3 +54,14 @@
|
|||||||
THEN
|
THEN
|
||||||
AGAIN
|
AGAIN
|
||||||
;
|
;
|
||||||
|
|
||||||
|
( ; has to be defined last because it can't be executed now )
|
||||||
|
: X ( can't have its real name now )
|
||||||
|
['] EXIT ,
|
||||||
|
_c R> DROP ( exit COMPILE )
|
||||||
|
_c R> DROP ( exit : )
|
||||||
|
; IMMEDIATE
|
||||||
|
|
||||||
|
( Give ";" its real name )
|
||||||
|
';' CURRENT @ 4 - C!
|
||||||
|
|
||||||
|
@ -207,3 +207,16 @@ CODE J
|
|||||||
H 3 IX- LDrIXY,
|
H 3 IX- LDrIXY,
|
||||||
HL PUSHqq,
|
HL PUSHqq,
|
||||||
;CODE
|
;CODE
|
||||||
|
|
||||||
|
CODE >R
|
||||||
|
HL POPqq,
|
||||||
|
chkPS,
|
||||||
|
( JUMPTBL+0 == pushRS )
|
||||||
|
ROUTINE J CALLnn,
|
||||||
|
;CODE
|
||||||
|
|
||||||
|
CODE R>
|
||||||
|
( JUMPTBL+3 == popRS )
|
||||||
|
ROUTINE J 3 + CALLnn,
|
||||||
|
HL PUSHqq,
|
||||||
|
;CODE
|
||||||
|
Loading…
Reference in New Issue
Block a user