From: Lukas Krickl Date: Sat, 2 Dec 2023 21:45:57 +0000 (+0100) Subject: Added proper label resolver for globals with test X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=94403dcc51da7c002b108505c43134ba448e7d1d;p=ulas%2F.git Added proper label resolver for globals with test --- diff --git a/src/ulas.c b/src/ulas.c index 24376f2..33be3a2 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -246,6 +246,8 @@ int ulas_symbolset(const char *name, int scope, struct ulas_tok tok, // def new symbol struct ulas_sym new_sym = {strdup(name), tok, scope, ulas.pass, constant}; + // last char of name has to be : so we trim it away + new_sym.name[strlen(new_sym.name) - 1] = '\0'; ulas_symbufpush(&ulas.syms, new_sym); } else if (exisitng->lastdefin != ulas.pass) { // redefine if not defined this pass @@ -1027,11 +1029,8 @@ fail: int ulas_valint(struct ulas_tok *lit, int *rc) { if (lit->type == ULAS_SYMBOL) { struct ulas_sym *stok = ulas_symbolresolve(lit->val.strv, rc); - // bail if symbol is not resolvable - if (*rc > 0) { - return 0; - } if (!stok || *rc == -1) { + ULASERR("Unabel to resolve '%s'\n", lit->val.strv); *rc = -1; return 0; } diff --git a/tests/t0.bin b/tests/t0.bin index 1cc8c84..b752c2e 100644 Binary files a/tests/t0.bin and b/tests/t0.bin differ diff --git a/tests/t0.s b/tests/t0.s index 102f333..cf5efec 100644 --- a/tests/t0.s +++ b/tests/t0.s @@ -73,4 +73,4 @@ l1: bit 0, d bit 0, [hl] - ; ld bc, l1 + 1 + ld bc, l1 + 1