summaryrefslogtreecommitdiff
path: root/usr.bin/oasm/lex.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-22 15:23:28 -0400
committerIan Moffett <ian@osmora.org>2025-07-22 15:23:28 -0400
commit61f9cb8c58aac0fcc283b2c352c7cc328bd62b8d (patch)
tree96779b4c4b9fa7e0c86c256df0840b8f453078f4 /usr.bin/oasm/lex.c
parentff5a77f6f2ee9e7086b0f2c16cf0752a2d105d33 (diff)
oasm: Add encoding for BR instruction
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin/oasm/lex.c')
-rw-r--r--usr.bin/oasm/lex.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/usr.bin/oasm/lex.c b/usr.bin/oasm/lex.c
index 7b78d54..3ca9e8d 100644
--- a/usr.bin/oasm/lex.c
+++ b/usr.bin/oasm/lex.c
@@ -47,6 +47,7 @@ static char putback = '\0';
#define S_IMN_INC "inc"
#define S_IMN_DEC "dec"
#define S_IMN_HLT "hlt"
+#define S_IMN_BR "br"
/*
* Returns 0 if a char is counted as a
@@ -190,6 +191,19 @@ token_arith(char *p)
return TT_UNKNOWN;
}
+/*
+ * Control flow instructions
+ */
+static tt_t
+token_cfi(char *p)
+{
+ if (strcmp(p, S_IMN_BR) == 0) {
+ return TT_BR;
+ }
+
+ return TT_UNKNOWN;
+}
+
static tt_t
token_xreg(char *p)
{
@@ -293,6 +307,13 @@ lex_tok(struct oasm_state *state, struct oasm_token *ttp)
return 0;
}
+ /* Control flow instruction? */
+ if ((tok = token_cfi(p)) != TT_UNKNOWN) {
+ ttp->type = tok;
+ ttp->raw = p;
+ return 0;
+ }
+
/* Register? */
if ((tok = token_reg(p)) != TT_UNKNOWN) {
ttp->is_reg = 1;