forth: add a stable ABI

This commit is contained in:
Virgil Dupras 2020-03-24 23:02:06 -04:00
parent f0ab57c8cc
commit 3a08fa7e74
4 changed files with 15 additions and 13 deletions

Binary file not shown.

View File

@ -55,7 +55,7 @@ LITN n -- Write number n as a literal.
[LITN] n -- *I* Immediate version of LITN.
ROUTINE x -- a Push the addr of the specified core routine
C=cellWord L=compiledWord V=nativeWord N=next S=LIT
N=NUMBER Y=sysvarWord D=doesWord
M=NUMBER Y=sysvarWord D=doesWord
VARIABLE c -- Creates cell x with 2 bytes allocation.
Compilation vs meta-compilation. When you compile a word with "[COMPILE] foo",

View File

@ -108,6 +108,14 @@
; At the end of every compiledWord is an EXIT. This pops RS, sets IP to it, and
; continues.
; *** Stable ABI ***
; Those jumps below are supposed to stay at these offsets, always. If they
; change bootstrap binaries have to be adjusted because they rely on them.
.fill 0x1a-$
JUMPTBL:
jp next
jp chkPS
; *** Code ***
forthMain:
; STACK OVERFLOW PROTECTION:
@ -185,12 +193,6 @@ INTERPRET:
.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
@ -815,7 +817,7 @@ ROUTINE:
ld de, nativeWord
cp 'V'
jr z, .end
ld de, next
ld de, JUMPTBL
cp 'N'
jr z, .end
ld de, sysvarWord
@ -828,9 +830,9 @@ ROUTINE:
cp 'S'
jr z, .end
ld de, NUMBER
cp 'N'
cp 'M'
jr z, .end
ld de, chkPS
ld de, JUMPTBL+3
cp 'P'
jr nz, .notgood
; continue to end on match

View File

@ -34,7 +34,7 @@ CODE ROT
CODE 2DUP
HL POPqq, ( B )
DE POPqq, ( A )
ROUTINE P CALLnn,
chkPS,
DE PUSHqq, ( A )
HL PUSHqq, ( B )
DE PUSHqq, ( A )
@ -48,7 +48,7 @@ CODE 2OVER
DE POPqq, ( C )
BC POPqq, ( B )
IY POPqq, ( A )
ROUTINE P CALLnn,
chkPS,
IY PUSHqq, ( A )
BC PUSHqq, ( B )
DE PUSHqq, ( C )
@ -64,7 +64,7 @@ CODE 2SWAP
DE POPqq, ( C )
BC POPqq, ( B )
IY POPqq, ( A )
ROUTINE P CALLnn,
chkPS,
DE PUSHqq, ( C )
HL PUSHqq, ( D )
IY PUSHqq, ( A )