summaryrefslogtreecommitdiff
path: root/usr.bin/oasm
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-20 21:58:24 -0400
committerIan Moffett <ian@osmora.org>2025-07-20 21:59:18 -0400
commit7a43fb95afa4cee74b2282f38789bbc363b86dd7 (patch)
treefcda49151fb2df0918629fcd84d40ed0e1078e60 /usr.bin/oasm
parent60ceb932fd0889690fef6883361eaf81cbf7ffae (diff)
oasm: lex: Convert and store <imm> to uint16_t
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin/oasm')
-rw-r--r--usr.bin/oasm/include/oasm/lex.h1
-rw-r--r--usr.bin/oasm/lex.c4
2 files changed, 5 insertions, 0 deletions
diff --git a/usr.bin/oasm/include/oasm/lex.h b/usr.bin/oasm/include/oasm/lex.h
index 9e293e6..1bb8641 100644
--- a/usr.bin/oasm/include/oasm/lex.h
+++ b/usr.bin/oasm/include/oasm/lex.h
@@ -113,6 +113,7 @@ typedef enum {
struct oasm_token {
tt_t type;
uint8_t is_reg : 1;
+ uint16_t imm;
char *raw;
};
diff --git a/usr.bin/oasm/lex.c b/usr.bin/oasm/lex.c
index c2a7a1f..f8427e0 100644
--- a/usr.bin/oasm/lex.c
+++ b/usr.bin/oasm/lex.c
@@ -297,6 +297,10 @@ lex_tok(struct oasm_state *state, struct oasm_token *ttp)
/* Immediate operand? */
if ((tok = token_operand(p)) != TT_UNKNOWN) {
+ if (tok == TT_IMM) {
+ ttp->imm = atoi(&p[1]);
+ }
+
ttp->type = tok;
ttp->raw = p;
return 0;