Browse Source

forth: Forth-ify "(entry)"

pull/95/head
Virgil Dupras 4 years ago
parent
commit
49101915fb
3 changed files with 18 additions and 40 deletions
  1. BIN
      emul/forth/z80c.bin
  2. +2
    -39
      forth/forth.asm
  3. +16
    -1
      forth/icore.fs

BIN
emul/forth/z80c.bin View File


+ 2
- 39
forth/forth.asm View File

@@ -1063,50 +1063,13 @@ PARSED:
jp next


.fill 51

; Spit name (in (HL)) + prev in (HERE) and adjust (HERE) and (CURRENT)
; HL points to new (HERE)
.db "(entry)"
.dw $-PARSED
.db 7
ENTRYHEAD:
.dw compiledWord
.dw WORD
.dw .private
.dw EXIT

.private:
.dw nativeWord
pop hl
ld de, (HERE)
call strcpy
; DE point to char after null, rewind.
dec de
; B counts the null, adjust
dec b
ld a, b
ex de, hl ; HL points to new HERE
ld de, (CURRENT)
push hl ; --> lvl 1
or a ; clear carry
sbc hl, de
ex de, hl
pop hl ; <-- lvl 1
call DEinHL
; Save size
ld (hl), b
inc hl
ld (CURRENT), hl
ld (HERE), hl
jp next

.fill 107

; STABLE ABI (every sysvars)
; Offset: 05ca
.out $
.db "HERE"
.dw $-ENTRYHEAD
.dw $-PARSED
.db 4
HERE_: ; Caution: conflicts with actual variable name
.dw sysvarWord


+ 16
- 1
forth/icore.fs View File

@@ -81,12 +81,27 @@
AGAIN
;

: (entry)
HERE @ ( h )
WORD ( h s )
SCPY ( h )
( Adjust HERE -1 because SCPY copies the null )
HERE @ 1 _c - ( h h' )
DUP HERE ! ( h h' )
SWAP _c - ( sz )
( write prev value )
HERE @ CURRENT @ _c - ,
( write size )
C,
HERE @ CURRENT !
;

( : and ; have to be defined last because it can't be
executed now also, they can't have their real name
right away )

: X
(entry)
_c (entry)
( JUMPTBL+0 == compiledWord )
[ ROUTINE J LITN ] ,
BEGIN


Loading…
Cancel
Save