mirror of
https://github.com/hsoft/collapseos.git
synced 2025-04-02 09:18:40 +11:00
zasm: make getSymVal not responsible for calling symFind
With local labels, these two will have to be decoupled.
This commit is contained in:
parent
c9deac599e
commit
746c86cbf8
@ -120,14 +120,18 @@ parseNumber:
|
|||||||
parseNumberOrSymbol:
|
parseNumberOrSymbol:
|
||||||
call parseNumber
|
call parseNumber
|
||||||
ret z
|
ret z
|
||||||
|
call zasmIsFirstPass
|
||||||
|
ret z ; first pass? we don't care about the value,
|
||||||
|
; return success.
|
||||||
; Not a number. Try symbol
|
; Not a number. Try symbol
|
||||||
|
call symFind
|
||||||
|
ret nz ; not found
|
||||||
|
; Found! index in A, let's fetch value
|
||||||
push de
|
push de
|
||||||
call symGetVal
|
call symGetVal
|
||||||
jr nz, .notfound ; Z already unset
|
; value in DE. We need it in IX
|
||||||
; Found! value in DE. We need it in IX
|
|
||||||
ld ixh, d
|
ld ixh, d
|
||||||
ld ixl, e
|
ld ixl, e
|
||||||
; Z already set
|
|
||||||
.notfound:
|
|
||||||
pop de
|
pop de
|
||||||
|
cp a ; ensure Z
|
||||||
ret
|
ret
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
; Manages both constants and labels within a same namespace and registry.
|
; Manages both constants and labels within a same namespace and registry.
|
||||||
|
;
|
||||||
|
; About local labels: They are treated as regular labels except they start with
|
||||||
|
; a dot (example: ".foo"). Because labels are registered in order and because
|
||||||
|
; constants are registered in the second pass, they end up at the end of the
|
||||||
|
; symbol list and don't mix with labels. Therefore, we easily iterate through
|
||||||
|
; local labels of a context by starting from that context's index and iterating
|
||||||
|
; as long as symbol name start with a '.'
|
||||||
|
|
||||||
; *** Constants ***
|
; *** Constants ***
|
||||||
; Duplicate symbol in registry
|
; Duplicate symbol in registry
|
||||||
@ -166,14 +173,9 @@ symFind:
|
|||||||
pop hl
|
pop hl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Return value associated with symbol string in (HL) into DE.
|
; Return value associated with symbol index A into DE
|
||||||
; Sets Z on success, unset on error.
|
; Sets Z on success, unset on error.
|
||||||
symGetVal:
|
symGetVal:
|
||||||
call zasmIsFirstPass
|
|
||||||
ret z ; first pass? we don't care about the value,
|
|
||||||
; return success.
|
|
||||||
call symFind
|
|
||||||
ret nz ; not found
|
|
||||||
; our index is in A. Let's fetch the proper value
|
; our index is in A. Let's fetch the proper value
|
||||||
push hl
|
push hl
|
||||||
ld hl, SYM_VALUES
|
ld hl, SYM_VALUES
|
||||||
|
Loading…
Reference in New Issue
Block a user