2019-05-10 21:19:34 -04:00
|
|
|
; Parse string in (HL) and return its numerical value whether its a number
|
|
|
|
; literal or a symbol. Returns value in IX.
|
|
|
|
; Sets Z if number or symbol is valid, unset otherwise.
|
|
|
|
parseNumberOrSymbol:
|
2019-05-14 13:53:12 -04:00
|
|
|
call parseLiteral
|
2019-05-10 21:19:34 -04:00
|
|
|
ret z
|
2019-10-04 20:26:21 -04:00
|
|
|
; Not a number.
|
|
|
|
; Is str a single char? If yes, maybe it's a special symbol.
|
|
|
|
call strIs1L
|
|
|
|
jr nz, .symbol ; nope
|
|
|
|
ld a, (hl)
|
|
|
|
cp '$'
|
2019-05-20 09:17:50 -04:00
|
|
|
jr z, .returnPC
|
2019-10-04 20:26:21 -04:00
|
|
|
cp '@'
|
|
|
|
jr nz, .symbol
|
|
|
|
; last val
|
|
|
|
ld ix, (DIREC_LASTVAL)
|
|
|
|
ret
|
|
|
|
.symbol:
|
2019-07-20 18:07:52 -04:00
|
|
|
push de ; --> lvl 1
|
|
|
|
call symFindVal ; --> DE
|
2019-05-19 13:22:14 -04:00
|
|
|
jr nz, .notfound
|
2019-05-13 16:53:52 -04:00
|
|
|
; value in DE. We need it in IX
|
2019-05-18 19:59:58 -04:00
|
|
|
push de \ pop ix
|
2019-07-20 18:07:52 -04:00
|
|
|
pop de ; <-- lvl 1
|
2019-05-13 16:53:52 -04:00
|
|
|
cp a ; ensure Z
|
2019-05-09 15:55:29 -04:00
|
|
|
ret
|
2019-05-19 13:22:14 -04:00
|
|
|
.notfound:
|
2019-07-20 18:07:52 -04:00
|
|
|
pop de ; <-- lvl 1
|
2019-05-19 13:22:14 -04:00
|
|
|
; If not found, check if we're in first pass. If we are, it doesn't
|
|
|
|
; matter that we didn't find our symbol. Return success anyhow.
|
|
|
|
; Otherwise return error. Z is already unset, so in fact, this is the
|
|
|
|
; same as jumping to zasmIsFirstPass
|
2019-11-13 21:14:29 -05:00
|
|
|
; however, before we do, load IX with zero. Returning dummy non-zero
|
|
|
|
; values can have weird consequence (such as false overflow errors).
|
|
|
|
ld ix, 0
|
2019-05-19 13:22:14 -04:00
|
|
|
jp zasmIsFirstPass
|
2019-05-20 09:17:50 -04:00
|
|
|
|
|
|
|
.returnPC:
|
|
|
|
push hl
|
|
|
|
call zasmGetPC
|
|
|
|
push hl \ pop ix
|
|
|
|
pop hl
|
|
|
|
ret
|