Browse Source

forth: make "(parsed)" support negative literals

This limitation was becoming annoying...
pull/95/head
Virgil Dupras 4 years ago
parent
commit
cb3e6469b8
2 changed files with 17 additions and 2 deletions
  1. +15
    -0
      forth/forth.asm
  2. +2
    -2
      forth/z80c.fs

+ 15
- 0
forth/forth.asm View File

@@ -296,6 +296,8 @@ strskip:
parseDecimal:
; First char is special: it has to succeed.
ld a, (hl)
cp '-'
jr z, .negative
; Parse the decimal char at A and extract it's 0-9 numerical value. Put the
; result in A.
; On success, the carry flag is reset. On error, it is set.
@@ -349,6 +351,19 @@ parseDecimal:
cp a ; ensure Z
ret

.negative:
inc hl
call parseDecimal
ret nz
push hl ; --> lvl 1
or a ; clear carry
ld hl, 0
sbc hl, de
ex de, hl
pop hl ; <-- lvl 1
xor a ; set Z
ret

; *** Support routines ***
; Find the entry corresponding to word where (HL) points to and sets DE to
; point to that entry.


+ 2
- 2
forth/z80c.fs View File

@@ -130,7 +130,7 @@ CODE *
DE INCss,
( noinc )
A DECr,
0 12 - JRNZe, ( loop )
-12 JRNZe, ( loop )
HL PUSHqq,
;CODE

@@ -154,7 +154,7 @@ CODE /MOD
DE ADDHLss,
C DECr,
( skip )
0 12 - DJNZe, ( loop )
-12 DJNZe, ( loop )
B A LDrr,
HL PUSHqq,
BC PUSHqq,


Loading…
Cancel
Save