2019-05-11 11:19:34 +10:00
|
|
|
; Parse string in (HL) and return its numerical value whether its a number
|
2019-12-30 09:37:04 +11:00
|
|
|
; literal or a symbol. Returns value in DE.
|
2019-05-11 11:19:34 +10:00
|
|
|
; Sets Z if number or symbol is valid, unset otherwise.
|
|
|
|
parseNumberOrSymbol:
|
2019-05-15 03:53:12 +10:00
|
|
|
call parseLiteral
|
2019-05-11 11:19:34 +10:00
|
|
|
ret z
|
2019-10-05 10:26:21 +10: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 23:17:50 +10:00
|
|
|
jr z, .returnPC
|
2019-10-05 10:26:21 +10:00
|
|
|
cp '@'
|
|
|
|
jr nz, .symbol
|
|
|
|
; last val
|
2019-12-30 09:37:04 +11:00
|
|
|
ld de, (DIREC_LASTVAL)
|
2019-10-05 10:26:21 +10:00
|
|
|
ret
|
|
|
|
.symbol:
|
2019-07-21 08:07:52 +10:00
|
|
|
call symFindVal ; --> DE
|
2019-05-20 03:22:14 +10:00
|
|
|
jr nz, .notfound
|
2019-05-10 05:55:29 +10:00
|
|
|
ret
|
2019-05-20 03:22:14 +10:00
|
|
|
.notfound:
|
|
|
|
; 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-12-30 09:37:04 +11:00
|
|
|
; however, before we do, load DE with zero. Returning dummy non-zero
|
2019-11-14 13:14:29 +11:00
|
|
|
; values can have weird consequence (such as false overflow errors).
|
2019-12-30 09:37:04 +11:00
|
|
|
ld de, 0
|
2019-05-20 03:22:14 +10:00
|
|
|
jp zasmIsFirstPass
|
2019-05-20 23:17:50 +10:00
|
|
|
|
|
|
|
.returnPC:
|
|
|
|
push hl
|
|
|
|
call zasmGetPC
|
2019-12-30 09:37:04 +11:00
|
|
|
ex de, hl ; result in DE
|
2019-05-20 23:17:50 +10:00
|
|
|
pop hl
|
|
|
|
ret
|