diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-02-13 14:24:31 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-02-13 14:24:31 +0100 |
commit | e9e7baf5bec50929acf2b79cdcd1af17ce0e9b3f (patch) | |
tree | 65622b924646b2b1f1f4c62002dc85b2b5bbacde | |
parent | 6b0b5fc36227949a6dda9c715309a9d6100f9da9 (diff) |
More simplification
-rw-r--r-- | src/c8asm/assembler.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/c8asm/assembler.c b/src/c8asm/assembler.c index b5c6f1b..6160397 100644 --- a/src/c8asm/assembler.c +++ b/src/c8asm/assembler.c @@ -58,25 +58,22 @@ getlabel(struct u8view sv) uint16_t getaddr(struct raw_addr a) { - if (a.label) { - struct label *lbl = getlabel(a.sv); - if (lbl) - return lbl->addr; - die_with_off(filename, a.sv.p - baseptr, E_LNEXISTS, U8_PRI_ARGS(a.sv)); - } - return a.val; + struct label *lbl; + if (!a.label) + return a.val; + if (lbl = getlabel(a.sv)) + return lbl->addr; + die_with_off(filename, a.sv.p - baseptr, E_LNEXISTS, U8_PRI_ARGS(a.sv)); } void pushlabel(struct labels *dst, struct label lbl) { - da_foreach (dst, stored) { - if (u8eq(stored->sv, lbl.sv)) { - die_with_off(filename, lbl.sv.p - baseptr, E_LEXISTS, - U8_PRI_ARGS(lbl.sv)); - } + struct label *found; + if (found = getlabel(lbl.sv)) { + die_with_off(filename, lbl.sv.p - baseptr, E_LEXISTS, + U8_PRI_ARGS(lbl.sv)); } - dapush(dst, lbl); } |