From b10c398798d32ed2c91314239d1af474efeb7de1 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 24 Jul 2025 04:51:34 -0400 Subject: 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 --- usr.bin/oasm/parse.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'usr.bin/oasm/parse.c') 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 #include #include +#include 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(); } -- cgit v1.2.3