diff options
author | Ian Moffett <ian@osmora.org> | 2025-07-20 02:26:25 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-07-20 02:36:56 -0400 |
commit | f41c27255f364076c5848526429a4e9f9e1c69ca (patch) | |
tree | bdf6566837c05ba0239e7084f05572b71bafe789 /usr.bin/oasm | |
parent | 239cbc23b2da5a770b02f5b743e3e5db8ad34416 (diff) |
usr: oasm: Lex registers and operands
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin/oasm')
-rw-r--r-- | usr.bin/oasm/lex.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/usr.bin/oasm/lex.c b/usr.bin/oasm/lex.c index 56c6eb5..afbe21d 100644 --- a/usr.bin/oasm/lex.c +++ b/usr.bin/oasm/lex.c @@ -206,6 +206,17 @@ token_xreg(char *p) } static tt_t +token_operand(char *p) +{ + /* Is this a numeric constant? */ + if (p[0] == '#') { + return TT_IMM; + } + + return TT_UNKNOWN; +} + +static tt_t token_reg(char *p) { tt_t tok; @@ -263,6 +274,14 @@ lex_tok(struct oasm_state *state, struct oasm_token *ttp) /* Register? */ if ((tok = token_reg(p)) != TT_UNKNOWN) { + ttp->is_reg = 1; + ttp->type = tok; + ttp->raw = p; + return 0; + } + + /* Immediate operand? */ + if ((tok = token_operand(p)) != TT_UNKNOWN) { ttp->type = tok; ttp->raw = p; return 0; |