2019-05-10 21:19:34 -04:00
|
|
|
; Parse string in (HL) and return its numerical value whether its a number
|
2019-12-29 17:37:04 -05:00
|
|
|
; literal or a symbol. Returns value in DE.
|
2019-12-30 19:24:53 -05:00
|
|
|
; HL is advanced to the character following the last successfully read char.
|
2019-05-10 21:19:34 -04:00
|
|
|
; Sets Z if number or symbol is valid, unset otherwise.
|
|
|
|
parseNumberOrSymbol:
|
2019-12-30 19:24:53 -05:00
|
|
|
call isLiteralPrefix
|
|
|
|
jp z, parseLiteral
|
|
|
|
; Not a number. try symbol
|
2019-10-04 20:26:21 -04:00
|
|
|
ld a, (hl)
|
|
|
|
cp '$'
|
2019-12-30 19:24:53 -05:00
|
|
|
jr z, .PC
|
2019-10-04 20:26:21 -04:00
|
|
|
cp '@'
|
2019-12-30 19:24:53 -05:00
|
|
|
jr z, .lastVal
|
|
|
|
call symParse
|
|
|
|
ret nz
|
|
|
|
; HL at end of symbol name, DE at tmp null-terminated symname.
|
|
|
|
push hl ; --> lvl 1
|
|
|
|
ex de, hl
|
2019-07-20 18:07:52 -04:00
|
|
|
call symFindVal ; --> DE
|
2019-12-30 19:24:53 -05:00
|
|
|
pop hl ; <-- lvl 1
|
|
|
|
ret z
|
|
|
|
; not found
|
|
|
|
; When not found, check if we're in first pass. If we are, it doesn't
|
2019-05-19 13:22:14 -04:00
|
|
|
; 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-29 17:37:04 -05:00
|
|
|
; however, before we do, load DE with zero. Returning dummy non-zero
|
2019-11-13 21:14:29 -05:00
|
|
|
; values can have weird consequence (such as false overflow errors).
|
2019-12-29 17:37:04 -05:00
|
|
|
ld de, 0
|
2019-05-19 13:22:14 -04:00
|
|
|
jp zasmIsFirstPass
|
2019-05-20 09:17:50 -04:00
|
|
|
|
2019-12-30 19:24:53 -05:00
|
|
|
.PC:
|
|
|
|
ex de, hl
|
|
|
|
call zasmGetPC ; --> HL
|
2019-12-29 17:37:04 -05:00
|
|
|
ex de, hl ; result in DE
|
2019-12-30 19:24:53 -05:00
|
|
|
inc hl ; char after last read
|
|
|
|
; Z already set from cp '$'
|
|
|
|
ret
|
|
|
|
|
|
|
|
.lastVal:
|
|
|
|
; last val
|
|
|
|
ld de, (DIREC_LASTVAL)
|
|
|
|
inc hl ; char after last read
|
|
|
|
; Z already set from cp '@'
|
2019-05-20 09:17:50 -04:00
|
|
|
ret
|