diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index 50e7d95..accf951 100644 Binary files a/emul/forth/z80c.bin and b/emul/forth/z80c.bin differ diff --git a/forth/forth.asm b/forth/forth.asm index 9161f2e..873880c 100644 --- a/forth/forth.asm +++ b/forth/forth.asm @@ -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 diff --git a/forth/icore.fs b/forth/icore.fs index 56b621e..f2f8882 100644 --- a/forth/icore.fs +++ b/forth/icore.fs @@ -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