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. [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 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. VARIABLE c -- Creates cell x with 2 bytes allocation.
Compilation vs meta-compilation. When you compile a word with "[COMPILE] foo", 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 ; At the end of every compiledWord is an EXIT. This pops RS, sets IP to it, and
; continues. ; 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 *** ; *** Code ***
forthMain: forthMain:
; STACK OVERFLOW PROTECTION: ; STACK OVERFLOW PROTECTION:
@ -185,12 +193,6 @@ INTERPRET:
.db 30 .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
@ -815,7 +817,7 @@ ROUTINE:
ld de, nativeWord ld de, nativeWord
cp 'V' cp 'V'
jr z, .end jr z, .end
ld de, next ld de, JUMPTBL
cp 'N' cp 'N'
jr z, .end jr z, .end
ld de, sysvarWord ld de, sysvarWord
@ -828,9 +830,9 @@ ROUTINE:
cp 'S' cp 'S'
jr z, .end jr z, .end
ld de, NUMBER ld de, NUMBER
cp 'N' cp 'M'
jr z, .end jr z, .end
ld de, chkPS ld de, JUMPTBL+3
cp 'P' cp 'P'
jr nz, .notgood jr nz, .notgood
; continue to end on match ; continue to end on match

View File

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