Browse Source

forth: Forth-ify "DUP"

pull/95/head
Virgil Dupras 4 years ago
parent
commit
cc4700e389
4 changed files with 16 additions and 20 deletions
  1. BIN
      emul/forth/z80c.bin
  2. +2
    -14
      forth/forth.asm
  3. +6
    -6
      forth/icore.fs
  4. +8
    -0
      forth/z80c.fs

BIN
emul/forth/z80c.bin View File


+ 2
- 14
forth/forth.asm View File

@@ -940,22 +940,10 @@ SWAP:
push hl
jp next

; ( a -- a a )
.db "DUP"
.dw $-SWAP
.db 3
DUP:
.dw nativeWord
pop hl
call chkPS
push hl
push hl
jp next

.fill 132
.fill 149

.db "_bend"
.dw $-DUP
.dw $-SWAP
.db 5
; Offset: 06ee
.out $

+ 6
- 6
forth/icore.fs View File

@@ -60,10 +60,10 @@
( a -- )
: (print)
BEGIN
DUP ( a a )
_c DUP ( a a )
_c C@ ( a c )
( exit if null )
DUP NOT IF DROP DROP EXIT THEN
_c DUP NOT IF DROP DROP EXIT THEN
_c EMIT ( a )
1 _c + ( a+1 )
AGAIN
@@ -85,7 +85,7 @@

: TOWORD
BEGIN
C< DUP _c WS? NOT IF EXIT THEN DROP
C< _c DUP _c WS? NOT IF EXIT THEN DROP
AGAIN
;

@@ -101,7 +101,7 @@
_c OVER ! ( a )
1 _c + ( a+1 )
C< ( a c )
DUP _c WS?
_c DUP _c WS?
UNTIL
( a this point, PS is: a WS )
( null-termination is already written )
@@ -121,7 +121,7 @@
SCPY ( h )
( Adjust HERE -1 because SCPY copies the null )
HERE @ 1 _c - ( h h' )
DUP HERE ! ( h h' )
_c DUP HERE ! ( h h' )
SWAP _c - ( sz )
( write prev value )
HERE @ CURRENT @ _c - ,
@@ -162,7 +162,7 @@
_c WORD
(find)
( is word )
IF DUP _c IMMED? IF EXECUTE ELSE , THEN
IF _c DUP _c IMMED? IF EXECUTE ELSE , THEN
( maybe number )
ELSE (parse*) @ EXECUTE _c LITN THEN
AGAIN


+ 8
- 0
forth/z80c.fs View File

@@ -31,6 +31,14 @@ CODE ROT
BC PUSHqq, ( A )
;CODE

( a -- a a )
CODE DUP
HL POPqq, ( A )
chkPS,
HL PUSHqq, ( A )
HL PUSHqq, ( A )
;CODE

( a b -- a b a )
CODE OVER
HL POPqq, ( B )


Loading…
Cancel
Save