summaryrefslogtreecommitdiff
path: root/usr.bin/oasm/include
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/include
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/include')
-rw-r--r--usr.bin/oasm/include/oasm/emit.h4
-rw-r--r--usr.bin/oasm/include/oasm/lex.h22
2 files changed, 26 insertions, 0 deletions
diff --git a/usr.bin/oasm/include/oasm/emit.h b/usr.bin/oasm/include/oasm/emit.h
index dab63d0..0236967 100644
--- a/usr.bin/oasm/include/oasm/emit.h
+++ b/usr.bin/oasm/include/oasm/emit.h
@@ -62,6 +62,10 @@
#define OSMX64_MOV_IMM 0x13 /* Data move operation from IMM */
#define OSMX64_HLT 0x14 /* Halt the processor */
#define OSMX64_BR 0x15 /* Branch */
+#define OSMX64_MROB 0x16 /* Mask register over byte */
+#define OSMX64_MROW 0x17 /* Mask register over word */
+#define OSMX64_MROD 0x18 /* Mask register over dword */
+#define OSMX64_MROQ 0x19 /* Mask register over qword */
/*
* OSMX64 register definitions
diff --git a/usr.bin/oasm/include/oasm/lex.h b/usr.bin/oasm/include/oasm/lex.h
index 69e50a1..fa82398 100644
--- a/usr.bin/oasm/include/oasm/lex.h
+++ b/usr.bin/oasm/include/oasm/lex.h
@@ -97,6 +97,10 @@ typedef enum {
TT_DIV, /* 'div' */
TT_HLT, /* 'hlt' */
TT_BR, /* 'br' */
+ TT_MROB, /* 'mrob' */
+ TT_MROW, /* 'mrow' */
+ TT_MROD, /* 'mrod' */
+ TT_MROQ, /* 'mroq' */
/* Register ops */
TT_MOV, /* 'mov' */
@@ -156,4 +160,22 @@ tok_is_xreg(tt_t tok)
return false;
}
+/*
+ * Check if a token is of an MRO type
+ * instruction. Returns true on match.
+ */
+__always_inline static inline bool
+lex_is_mro(tt_t tok)
+{
+ switch (tok) {
+ case TT_MROB:
+ case TT_MROW:
+ case TT_MROD:
+ case TT_MROQ:
+ return true;
+ }
+
+ return false;
+}
+
#endif /* !_OASM_LEX_H_ */