diff options
author | Ian Moffett <ian@osmora.org> | 2025-07-24 04:51:34 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-07-24 04:55:08 -0400 |
commit | b10c398798d32ed2c91314239d1af474efeb7de1 (patch) | |
tree | d8550525735931ec0388a896bbb609f455028b48 /usr.bin/oasm/parse.c | |
parent | cb134267d4596122bc78c162d23f4719041c7540 (diff) |
oasm: Add table to keep track of labels
Implement a hash table used to store a maximum of 128 labels.
This commit adds functions such as label_enter() to add labels
to the table, label_lookup() to lookup labels as well as various
utility functions used internally by the assembler.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin/oasm/parse.c')
-rw-r--r-- | usr.bin/oasm/parse.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/usr.bin/oasm/parse.c b/usr.bin/oasm/parse.c index ff3c9d2..229455b 100644 --- a/usr.bin/oasm/parse.c +++ b/usr.bin/oasm/parse.c @@ -34,6 +34,7 @@ #include <oasm/lex.h> #include <oasm/parse.h> #include <oasm/log.h> +#include <oasm/label.h> static struct emit_state emit_state; static const char *tokstr[] = { @@ -159,6 +160,7 @@ parse_tok(struct oasm_state *state, struct oasm_token *tok) break; case TT_LABEL: state->last = tok->type; + label_enter(tok->raw, state->pip); break; case TT_HLT: state->last = tok->type; @@ -246,4 +248,5 @@ parse_enter(struct oasm_state *state) /* Process then destroy the emit state */ emit_process(state, &emit_state); emit_destroy(&emit_state); + labels_destroy(); } |