summaryrefslogtreecommitdiff
path: root/usr.bin/oasm/parse.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-24 03:41:39 -0400
committerIan Moffett <ian@osmora.org>2025-07-24 03:50:04 -0400
commitaf7a0cf9b65d6fee20029fe67c95c494f4b402a7 (patch)
treebef5ae96cde9bad9cad5f3350a92072f58d594dd /usr.bin/oasm/parse.c
parent2de38a06acd1f8a392f1c6ea74a7b0aaa0de3692 (diff)
oasm: Add encoding for MRO type instructions
This commit introduces encoding logic for 4 additional instructions: - MROB (Mask Register Over [byte]) - MROW (Mask Register Over [word]) - MROD (Mask Register Over [dword]) - MROQ (Mask Register Over [qword]) This instruction is used to fill a register with a specific length of zeros or ones. For example, to fill a register (e.g., x2) with 16-bits of 1s: -- !! !! Clear bits x2[7:0]... Mrrp,, !! mrow!! !! mrow x2, #1 -- Similarly, an operand of zero sets it to zero. For example, to clear an entire 64-bit register with zeros. Something like this can be done: -- mroq x1, #0 -- Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin/oasm/parse.c')
-rw-r--r--usr.bin/oasm/parse.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/usr.bin/oasm/parse.c b/usr.bin/oasm/parse.c
index 4651b55..ff3c9d2 100644
--- a/usr.bin/oasm/parse.c
+++ b/usr.bin/oasm/parse.c
@@ -51,6 +51,12 @@ static const char *tokstr[] = {
[ TT_IMM ] = "<imm>",
[ TT_LABEL] = "<label>",
+ /* Bitwise */
+ [ TT_MROB ] = "mrob",
+ [ TT_MROW ] = "mrow",
+ [ TT_MROD ] = "mrod",
+ [ TT_MROQ ] = "mroq",
+
/* X<n> registers */
[ TT_X0 ] = "x0",
@@ -119,6 +125,11 @@ parse_reg(struct oasm_state *state, struct oasm_token *tok)
state->last = tok->type;
break;
default:
+ if (lex_is_mro(state->last)) {
+ state->last = tok->type;
+ break;
+ }
+
p = tokstr[state->last];
oasm_err("bad instruction '%s' for regop\n", p);
return -1;
@@ -187,6 +198,12 @@ parse_tok(struct oasm_state *state, struct oasm_token *tok)
emit_osmx64(&emit_state, tok);
break;
default:
+ if (lex_is_mro(tok->type)) {
+ state->last = tok->type;
+ emit_osmx64(&emit_state, tok);
+ return 0;
+ }
+
if (!tok->is_reg) {
oasm_err("syntax error\n");
return -1;