summaryrefslogtreecommitdiff
path: root/usr.bin/oasm/lex.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-24 17:00:55 -0400
committerIan Moffett <ian@osmora.org>2025-07-24 17:04:10 -0400
commitaa3820495e8c2f103f82923240e7936ca78fab84 (patch)
treefe1441e28054a3e7b7300e2597df9444ac6f018b /usr.bin/oasm/lex.c
parent24dabe54c845b88ccd4842eb0e7c0fa097a7beaf (diff)
oasm: Introduce encoding for the NOP instruction
The NOP (no operation) instruction simply tells the processor to do nothing. This can be useful for various things such as padding, timing, etc. -- nop nop nop ... -- Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin/oasm/lex.c')
-rw-r--r--usr.bin/oasm/lex.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/usr.bin/oasm/lex.c b/usr.bin/oasm/lex.c
index dcd7c1f..fea9dc3 100644
--- a/usr.bin/oasm/lex.c
+++ b/usr.bin/oasm/lex.c
@@ -40,6 +40,7 @@
static char putback = '\0';
/* Instruction mnemonic strings */
+#define S_IMN_NOP "nop"
#define S_IMN_MOV "mov"
#define S_IMN_ADD "add"
#define S_IMN_SUB "sub"
@@ -372,6 +373,13 @@ lex_tok(struct oasm_state *state, struct oasm_token *ttp)
return 0;
}
+ /* No operation? */
+ if (strcmp(p, S_IMN_NOP) == 0) {
+ ttp->type = TT_NOP;
+ ttp->raw = p;
+ return 0;
+ }
+
/* Arithmetic operation? */
if ((tok = token_arith(p)) != TT_UNKNOWN) {
ttp->type = tok;