diff --git a/apps/zasm/parse.asm b/apps/zasm/parse.asm index 7d2f1aa..c4c2732 100644 --- a/apps/zasm/parse.asm +++ b/apps/zasm/parse.asm @@ -120,14 +120,18 @@ parseNumber: parseNumberOrSymbol: call parseNumber ret z + call zasmIsFirstPass + ret z ; first pass? we don't care about the value, + ; return success. ; Not a number. Try symbol + call symFind + ret nz ; not found + ; Found! index in A, let's fetch value push de call symGetVal - jr nz, .notfound ; Z already unset - ; Found! value in DE. We need it in IX + ; value in DE. We need it in IX ld ixh, d ld ixl, e - ; Z already set -.notfound: pop de + cp a ; ensure Z ret diff --git a/apps/zasm/symbol.asm b/apps/zasm/symbol.asm index 9a4677d..5c77da3 100644 --- a/apps/zasm/symbol.asm +++ b/apps/zasm/symbol.asm @@ -1,4 +1,11 @@ ; 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 *** ; Duplicate symbol in registry @@ -166,14 +173,9 @@ symFind: pop hl 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. 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 push hl ld hl, SYM_VALUES