From aa3820495e8c2f103f82923240e7936ca78fab84 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 24 Jul 2025 17:00:55 -0400 Subject: 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 --- usr.bin/oasm/lex.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'usr.bin/oasm/lex.c') 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; -- cgit v1.2.3