summaryrefslogtreecommitdiff
path: root/usr.bin/oasm/emit.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-21 09:17:30 -0400
committerIan Moffett <ian@osmora.org>2025-07-21 09:17:30 -0400
commit3ab5f07bac34bc9de5b9038407353c707f3f4c2f (patch)
tree57b028642f4fc81d839994132eda2859d6255162 /usr.bin/oasm/emit.c
parent60c8f4c34194fcec0e9e7d8da9cd1ad8b38707e7 (diff)
oasm: Parse and encode the "HLT" instruction
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin/oasm/emit.c')
-rw-r--r--usr.bin/oasm/emit.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/usr.bin/oasm/emit.c b/usr.bin/oasm/emit.c
index ee13582..cef90d7 100644
--- a/usr.bin/oasm/emit.c
+++ b/usr.bin/oasm/emit.c
@@ -220,6 +220,26 @@ emit_encode_add(struct emit_state *state, struct oasm_token *tok)
return TAILQ_NEXT(tok, link);
}
+/*
+ * Encode a HLT instruction
+ *
+ * 'hlt' - no operands
+ *
+ * Returns the next token on success,
+ * otherwise NULL.
+ */
+static struct oasm_token *
+emit_encode_hlt(struct emit_state *state, struct oasm_token *tok)
+{
+ inst_t curinst;
+
+ curinst.opcode = OSMX64_HLT;
+ curinst.rd = 0;
+ curinst.unused = 0;
+ emit_bytes(state, &curinst, sizeof(curinst));
+ return TAILQ_NEXT(tok, link);
+}
+
int
emit_osxm64(struct emit_state *state, struct oasm_token *tp)
{
@@ -301,6 +321,9 @@ emit_process(struct oasm_state *oasm, struct emit_state *emit)
case TT_ADD:
curtok = emit_encode_add(emit, curtok);
break;
+ case TT_HLT:
+ curtok = emit_encode_hlt(emit, curtok);
+ break;
default:
curtok = TAILQ_NEXT(curtok, link);
break;