Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b95f4c8

Browse files
author
Virgil Dupras
committed
zasm: remove SYM_CTX_PTR
1 parent f4f91eb commit b95f4c8

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

apps/zasm/symbol.asm

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
.equ SYM_LOC_VALUES SYM_NAMES+SYM_BUFSIZE
3737
.equ SYM_LOC_NAMES SYM_LOC_VALUES+SYM_LOC_MAXCOUNT*2
3838

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
4240

4341
; *** Registries ***
4442
; A symbol registry is a 6 bytes record with points to names and values of
@@ -149,12 +147,12 @@ symRegisterLocal:
149147
; If successful, Z is set and A is the symbol index. Otherwise, Z is unset and
150148
; A is an error code (ERR_*).
151149
symRegister:
152-
call _symFind
153-
jr z, .alreadyThere
154-
155150
push hl ; --> lvl 1. it's the symbol to add
156151
push de ; --> lvl 2. it's our value.
157152

153+
call _symFind
154+
jr z, .alreadyThere
155+
158156

159157
; First, let's get our strlen
160158
call strlen
@@ -227,25 +225,24 @@ symRegister:
227225

228226
call zasmIsFirstPass
229227
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
234230
call writeHLinDE
235231
pop hl ; <-- lvl 1
236232
cp a ; ensure Z
237233
ret
238234
.duplicateError:
235+
pop de ; <-- lvl 2
236+
pop hl ; <-- lvl 1
239237
ld a, ERR_DUPSYM
240238
jp unsetZ ; return
241239

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.
244242
; If we find something, Z is set, otherwise unset.
245243
_symFind:
246244
push iy
247245
push hl
248-
push de
249246

250247
ex de, hl ; it's easier if HL is haystack and DE is
251248
; needle.
@@ -269,11 +266,10 @@ _symFind:
269266
call unsetZ
270267
jr .end
271268
.match:
272-
push iy \ pop hl
273-
ld (SYM_CTX_PTR), hl
269+
push iy \ pop de
270+
; DE has our result
274271
cp a ; ensure Z
275272
.end:
276-
pop de
277273
pop hl
278274
pop iy
279275
ret
@@ -293,8 +289,7 @@ symFindVal:
293289
call _symFind
294290
jr nz, .end
295291
; 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
298293
call intoDE
299294
.end:
300295
pop ix

tools/emul/zasm/zasm.bin

-11 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)