forth: Forth-ify ";"!!!

Ain't that not self-bootstrapping enough to your taste? Whoa, I'm
getting dizzy...
This commit is contained in:
Virgil Dupras 2020-03-27 09:32:03 -04:00
parent dad0081123
commit 1e7e696e4a
3 changed files with 36 additions and 16 deletions

Binary file not shown.

View File

@ -839,22 +839,9 @@ EXECUTE:
jp (hl) ; go!
.db ";"
.dw $-EXECUTE
.db 0x81 ; IMMEDIATE
ENDDEF:
.dw compiledWord
.dw NUMBER
.dw EXIT
.dw WR
.dw R2P ; exit COMPILE
.dw DROP
.dw R2P ; exit DEFINE
.dw DROP
.dw EXIT
.fill 22
.db ":"
.dw $-ENDDEF
.dw $-EXECUTE
.db 0x81 ; IMMEDIATE
DEFINE:
.dw compiledWord
@ -1269,6 +1256,7 @@ FETCH:
.db "DROP"
.dw $-FETCH
.db 4
; STABLE ABI
DROP:
.dw nativeWord
pop hl
@ -1485,5 +1473,6 @@ BBR:
; To allow dict binaries to "hook themselves up", we always end such binary
; with a dummy, *empty* entry. Therefore, we can have a predictable place for
; getting a prev label.
.db "_bend"
.dw $-BBR
.db 0
.db 5

View File

@ -19,6 +19,37 @@
by the full interpreter.
)
( When referencing words from native defs or this very unit,
use this compiling word, which subtract the proper offset
from the compiled word. That proper offset is:
1. Take ROT-header addr, the first native def.
2. Subtract _bend, boot's last word.
3. That will give us the offset to subtract to get the addr
of our word at runtime.
This means, of course, that any word compiling a _c word
can't be executed immediately.
)
: _c
['] ROT
6 - ( header )
['] _bend
- ( our offset )
' ( get word )
-^ ( apply offset )
, ( write! )
; 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
BEGIN
WORD