forth: a little house cleaning

This commit is contained in:
Virgil Dupras 2020-03-19 16:36:54 -04:00
parent af5a97243a
commit f420db135d
2 changed files with 16 additions and 50 deletions

View File

@ -402,13 +402,13 @@ DOES:
; 2. Leave 2 bytes for regular cell variable. ; 2. Leave 2 bytes for regular cell variable.
; 3. Write down IP+2 to entry. ; 3. Write down IP+2 to entry.
; 3. exit. we're done here. ; 3. exit. we're done here.
ld iy, (CURRENT) ld hl, (CURRENT)
ld hl, doesWord ld de, doesWord
call wrCompHL call DEinHL
inc iy \ inc iy ; cell variable space inc hl \ inc hl ; cell variable space
ld hl, (IP) ld de, (IP)
call wrCompHL call DEinHL
ld (HERE), iy ld (HERE), hl
jp EXIT+2 jp EXIT+2

View File

@ -251,12 +251,6 @@ parseDecimal:
ret ret
; *** Forth-specific part *** ; *** Forth-specific part ***
; Return address of scratchpad in HL
pad:
ld hl, (HERE)
ld a, PADDING
jp addHL
; Advance (INPUTPOS) until a non-whitespace is met. If needed, ; Advance (INPUTPOS) until a non-whitespace is met. If needed,
; call fetchline. ; call fetchline.
; Set HL to newly set (INPUTPOS) ; Set HL to newly set (INPUTPOS)
@ -315,41 +309,21 @@ HLPointsDE:
cp d ; Z has our answer cp d ; Z has our answer
ret ret
HLPointsNUMBER:
push de
ld de, NUMBER
call HLPointsDE
pop de
ret
HLPointsLIT:
push de
ld de, LIT
call HLPointsDE
pop de
ret
HLPointsBR:
push de
ld de, FBR
call HLPointsDE
jr z, .end
ld de, BBR
call HLPointsDE
.end:
pop de
ret
; Skip the compword where HL is currently pointing. If it's a regular word, ; Skip the compword where HL is currently pointing. If it's a regular word,
; it's easy: we inc by 2. If it's a NUMBER, we inc by 4. If it's a LIT, we skip ; it's easy: we inc by 2. If it's a NUMBER, we inc by 4. If it's a LIT, we skip
; to after null-termination. ; to after null-termination.
compSkip: compSkip:
call HLPointsNUMBER ld de, NUMBER
call HLPointsDE
jr z, .isNum jr z, .isNum
call HLPointsBR ld de, FBR
call HLPointsDE
jr z, .isBranch jr z, .isBranch
call HLPointsLIT ld de, BBR
call HLPointsDE
jr z, .isBranch
ld de, LIT
call HLPointsDE
jr nz, .isWord jr nz, .isWord
; We have a literal ; We have a literal
inc hl \ inc hl inc hl \ inc hl
@ -409,14 +383,6 @@ find:
; Z will be set if DE is zero ; Z will be set if DE is zero
ret ret
; Write compiled data from HL into IY, advancing IY at the same time.
wrCompHL:
ld (iy), l
inc iy
ld (iy), h
inc iy
ret
; Spit name + prev in (HERE) and adjust (HERE) and (CURRENT) ; Spit name + prev in (HERE) and adjust (HERE) and (CURRENT)
; HL points to new (HERE) ; HL points to new (HERE)
entryhead: entryhead: