Browse Source

forth: Forth-ify "KEY"

pull/95/head
Virgil Dupras 4 years ago
parent
commit
966f6df0c5
4 changed files with 12 additions and 22 deletions
  1. +7
    -0
      emul/forth/emul.fs
  2. +0
    -8
      emul/forth/stagec.asm
  3. BIN
      emul/forth/z80c.bin
  4. +5
    -14
      forth/forth.asm

+ 7
- 0
emul/forth/emul.fs View File

@@ -8,3 +8,10 @@ CODE (emit)
A L LDrr,
0 OUTnA,
;CODE

CODE KEY
0 INAn,
H 0 LDrn,
L A LDrr,
HL PUSHqq,
;CODE

+ 0
- 8
emul/forth/stagec.asm View File

@@ -9,11 +9,3 @@ init:
ld sp, 0xffff
call forthMain
halt

emulGetC:
; Blocks until a char is returned
in a, (STDIO_PORT)
cp a ; ensure Z
ret

.equ GETC emulGetC

BIN
emul/forth/z80c.bin View File


+ 5
- 14
forth/forth.asm View File

@@ -141,7 +141,8 @@ forthMain:
call find
jr z, .skip
; no? then use KEY
ld de, KEY
ld hl, .keyName
call find
.skip:
ld (CINPTR), de
; Set up SYSVNXT
@@ -157,6 +158,8 @@ forthMain:
.db "(c<)", 0
.emitName:
.db "(emit)", 0
.keyName:
.db "KEY", 0

BEGIN:
.dw compiledWord
@@ -985,22 +988,10 @@ FIND_:
push de
jp next

; ( -- c )
.db "KEY"
.dw $-FIND_
.db 3
KEY:
.dw nativeWord
call GETC
ld h, 0
ld l, a
push hl
jp next

; This is an indirect word that can be redirected through "CINPTR"
; code: it is replaced in readln.fs.
.db "C<"
.dw $-KEY
.dw $-FIND_
.db 2
CIN:
.dw compiledWord


Loading…
Cancel
Save