36
36
. equ SYM_LOC_VALUES SYM_NAMES + SYM_BUFSIZE
37
37
. equ SYM_LOC_NAMES SYM_LOC_VALUES + SYM_LOC_MAXCOUNT * 2
38
38
39
- ; Pointer, in the value list, to the result of the last _symFind
40
- . equ SYM_CTX_PTR SYM_LOC_NAMES + SYM_LOC_BUFSIZE
41
- . equ SYM_RAMEND SYM_CTX_PTR + 2
39
+ . equ SYM_RAMEND SYM_LOC_NAMES + SYM_LOC_BUFSIZE
42
40
43
41
; *** Registries ***
44
42
; A symbol registry is a 6 bytes record with points to names and values of
@@ -149,12 +147,12 @@ symRegisterLocal:
149
147
; If successful, Z is set and A is the symbol index. Otherwise, Z is unset and
150
148
; A is an error code (ERR_*).
151
149
symRegister:
152
- call _symFind
153
- jr z , .alreadyThere
154
-
155
150
push hl ; --> lvl 1. it's the symbol to add
156
151
push de ; --> lvl 2. it's our value.
157
152
153
+ call _symFind
154
+ jr z , .alreadyThere
155
+
158
156
159
157
; First, let's get our strlen
160
158
call strlen
@@ -227,25 +225,24 @@ symRegister:
227
225
228
226
call zasmIsFirstPass
229
227
jr z , .duplicateError
230
- ; Second pass. Don't error out, just update value
231
- push hl ; --> lvl 1
232
- ld hl , (SYM_CTX_PTR)
233
- ex de , hl
228
+ ; Second pass. Don't error out, just update value, which DE points to.
229
+ pop hl ; <-- lvl 2, the value to register
234
230
call writeHLinDE
235
231
pop hl ; <-- lvl 1
236
232
cp a ; ensure Z
237
233
ret
238
234
.duplicateError:
235
+ pop de ; <-- lvl 2
236
+ pop hl ; <-- lvl 1
239
237
ld a , ERR_DUPSYM
240
238
jp unsetZ ; return
241
239
242
- ; Assuming that IX points to a register context , find name HL in its names and
243
- ; make the context pointer point to the corresponding entry in its values.
240
+ ; Assuming that IX points to a registry , find name HL in its names and make DE
241
+ ; point to the corresponding entry in its values.
244
242
; If we find something, Z is set, otherwise unset.
245
243
_symFind:
246
244
push iy
247
245
push hl
248
- push de
249
246
250
247
ex de , hl ; it's easier if HL is haystack and DE is
251
248
; needle.
@@ -269,11 +266,10 @@ _symFind:
269
266
call unsetZ
270
267
jr .end
271
268
.match:
272
- push iy \ pop hl
273
- ld (SYM_CTX_PTR) , hl
269
+ push iy \ pop de
270
+ ; DE has our result
274
271
cp a ; ensure Z
275
272
.end:
276
- pop de
277
273
pop hl
278
274
pop iy
279
275
ret
@@ -293,8 +289,7 @@ symFindVal:
293
289
call _symFind
294
290
jr nz , .end
295
291
; Found! let's fetch value
296
- ; Return value that (SYM_CTX_PTR) is pointing at in DE.
297
- ld de , (SYM_CTX_PTR)
292
+ ; DE is pointing to our result
298
293
call intoDE
299
294
.end:
300
295
pop ix
0 commit comments