From af7a0cf9b65d6fee20029fe67c95c494f4b402a7 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 24 Jul 2025 03:41:39 -0400 Subject: 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 --- usr.bin/oasm/include/oasm/emit.h | 4 ++++ usr.bin/oasm/include/oasm/lex.h | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'usr.bin/oasm/include') 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_ */ -- cgit v1.2.3