From: Lukas Krickl Date: Sat, 2 Dec 2023 15:21:25 +0000 (+0100) Subject: WIP: address labels X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=42bff3ae2c47a20407f7214969c808c1f54cc1f6;p=ulas%2F.git WIP: address labels --- diff --git a/src/ulas.c b/src/ulas.c index 854eebc..24376f2 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -1187,7 +1187,10 @@ void ulas_symbufclear(struct ulas_symbuf *sb) { sb->len = 0; } -void ulas_symbuffree(struct ulas_symbuf *sb) { free(sb->buf); } +void ulas_symbuffree(struct ulas_symbuf *sb) { + ulas_symbufclear(sb); + free(sb->buf); +} /** * Assembly step @@ -2072,13 +2075,16 @@ int ulas_asmline(FILE *dst, FILE *src, const char *line, unsigned long n) { // is it a label? if (ulas_islabelname(ulas.tok.buf, strlen(ulas.tok.buf))) { const char *prev = line; + struct ulas_tok label_tok = {ULAS_INT, {ulas.address}}; + ulas_symbolset(ulas.tok.buf, -1, label_tok, 1); + // is next token empty? if (ulas_tok(&ulas.tok, &line, n) == 0 || strnlen(ulas.tok.buf, ulas.tok.maxlen) == 0) { ulas_asmlst(start, outbuf, towrite); return 0; } - // ulas_symbolset(ulas.tok.buf, -1, + line = prev; } else { // start over for the next step... diff --git a/tests/t0.s b/tests/t0.s index 823a6b6..102f333 100644 --- a/tests/t0.s +++ b/tests/t0.s @@ -69,6 +69,8 @@ rlc c rlc [hl] -label: +l1: bit 0, d bit 0, [hl] + + ; ld bc, l1 + 1