Pārlūkot izejas kodu

forth: Forth-ify ";"!!!

Ain't that not self-bootstrapping enough to your taste? Whoa, I'm
getting dizzy...
pull/95/head
Virgil Dupras pirms 4 gadiem
vecāks
revīzija
1e7e696e4a
3 mainītis faili ar 36 papildinājumiem un 16 dzēšanām
  1. Binārs
      emul/forth/z80c.bin
  2. +5
    -16
      forth/forth.asm
  3. +31
    -0
      forth/icore.fs

Binārs
emul/forth/z80c.bin Parādīt failu


+ 5
- 16
forth/forth.asm Parādīt failu

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

+ 31
- 0
forth/icore.fs Parādīt failu

@@ -19,6 +19,37 @@
by the full interpreter. 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 : INTERPRET
BEGIN BEGIN
WORD WORD


Notiek ielāde…
Atcelt
Saglabāt