summaryrefslogtreecommitdiff
path: root/usr.bin/oasm/lex.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/oasm/lex.c')
-rw-r--r--usr.bin/oasm/lex.c19
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;