forth: make "(parsed)" support negative literals

This limitation was becoming annoying...
This commit is contained in:
Virgil Dupras 2020-03-26 14:47:17 -04:00
parent 40eda1d933
commit cb3e6469b8
2 changed files with 17 additions and 2 deletions

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.

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,