From b95f4c8c2474aa4e5cbe8749bceab9e39c131cf1 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 22 Jul 2019 16:34:40 -0400 Subject: [PATCH] zasm: remove SYM_CTX_PTR --- apps/zasm/symbol.asm | 31 +++++++++++++------------------ tools/emul/zasm/zasm.bin | Bin 4658 -> 4647 bytes 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/apps/zasm/symbol.asm b/apps/zasm/symbol.asm index cf60f07..6c7de40 100644 --- a/apps/zasm/symbol.asm +++ b/apps/zasm/symbol.asm @@ -36,9 +36,7 @@ .equ SYM_LOC_VALUES SYM_NAMES+SYM_BUFSIZE .equ SYM_LOC_NAMES SYM_LOC_VALUES+SYM_LOC_MAXCOUNT*2 -; Pointer, in the value list, to the result of the last _symFind -.equ SYM_CTX_PTR SYM_LOC_NAMES+SYM_LOC_BUFSIZE -.equ SYM_RAMEND SYM_CTX_PTR+2 +.equ SYM_RAMEND SYM_LOC_NAMES+SYM_LOC_BUFSIZE ; *** Registries *** ; A symbol registry is a 6 bytes record with points to names and values of @@ -149,12 +147,12 @@ symRegisterLocal: ; If successful, Z is set and A is the symbol index. Otherwise, Z is unset and ; A is an error code (ERR_*). symRegister: - call _symFind - jr z, .alreadyThere - push hl ; --> lvl 1. it's the symbol to add push de ; --> lvl 2. it's our value. + call _symFind + jr z, .alreadyThere + ; First, let's get our strlen call strlen @@ -227,25 +225,24 @@ symRegister: call zasmIsFirstPass jr z, .duplicateError - ; Second pass. Don't error out, just update value - push hl ; --> lvl 1 - ld hl, (SYM_CTX_PTR) - ex de, hl + ; Second pass. Don't error out, just update value, which DE points to. + pop hl ; <-- lvl 2, the value to register call writeHLinDE pop hl ; <-- lvl 1 cp a ; ensure Z ret .duplicateError: + pop de ; <-- lvl 2 + pop hl ; <-- lvl 1 ld a, ERR_DUPSYM jp unsetZ ; return -; Assuming that IX points to a register context, find name HL in its names and -; make the context pointer point to the corresponding entry in its values. +; Assuming that IX points to a registry, find name HL in its names and make DE +; point to the corresponding entry in its values. ; If we find something, Z is set, otherwise unset. _symFind: push iy push hl - push de ex de, hl ; it's easier if HL is haystack and DE is ; needle. @@ -269,11 +266,10 @@ _symFind: call unsetZ jr .end .match: - push iy \ pop hl - ld (SYM_CTX_PTR), hl + push iy \ pop de + ; DE has our result cp a ; ensure Z .end: - pop de pop hl pop iy ret @@ -293,8 +289,7 @@ symFindVal: call _symFind jr nz, .end ; Found! let's fetch value - ; Return value that (SYM_CTX_PTR) is pointing at in DE. - ld de, (SYM_CTX_PTR) + ; DE is pointing to our result call intoDE .end: pop ix diff --git a/tools/emul/zasm/zasm.bin b/tools/emul/zasm/zasm.bin index 89cdc3c4f16339f554eec2e07167c8b4000448e5..7c5a6faa8ac6fa35f61ed6bc1b987e8db747825e 100644 GIT binary patch delta 422 zcmX9)O-lk%6n$^}j3}GLbapc`(BM+k%!Sk@nvzz5^9sUp69uj$B&b&LXgxonMN3IH zL4=j7C)|aB%UO&t5Qqdp5Rqd~+g$EF_nyN!x1rvtp7zMN_h5{xrVnRvrJ2WLLF^l{ zzh~Lq7VEYv#DUA^j#t8bd+fUqf)%2z^d{gi@Zsk~YrcTb%|vJoSIpDUcfjdE!_d;^ z$wDT=Zv!^Okj3UT}_C6L6yipi0s7% zEe65unu|M6#1%R(=A$SbREZYm_O<0{4xTs+V-l05SvWi;&hmeefemFt7U~Q_h(SS5 csHJ#@PJQwO+}|~WLp_n9akVsY%fS}=1N#oK?EnA( delta 409 zcmW+yJxjw-6n!tXHY(c2qNbBc2^cbll9mWXH@^_K_UT}C62(>8K{}O(bNml(R;|tv zyZDNCsL(M(gn%MN90Ua$ea&*Y=iGZP=iCeJMvJvYavj4M*PS>n;99GQ{{-o+tc>IXVNb5REvUz^f47738A9EY>P^$0vfXOR1$|x)67%Trsg7r=N0%Zsrv-x){5BV z(sQCrs>egzjG(h6%`aOt#Ei>%&Dxap44d|Mv`VJS;A9mp$$d2pbwU1uI#J@FY|HO1 z1980?;?5%ph0c?6C1vzF(bL?zz7S>Lq0=zFEoY(}oQ{MO{AJFkG@}-1V!Z