summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-21 09:18:51 -0400
committerIan Moffett <ian@osmora.org>2025-07-21 09:18:51 -0400
commitcf0acae537a4664948485bc9e9a370fe7d100803 (patch)
tree5575808d7a7431f4eb3827b7d3d8e7da11e52002
parent3ab5f07bac34bc9de5b9038407353c707f3f4c2f (diff)
oemu: cpu: Decode and process HLT instruction
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--usr.bin/oemu/cpu.c6
-rw-r--r--usr.bin/oemu/include/oemu/osmx64.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/usr.bin/oemu/cpu.c b/usr.bin/oemu/cpu.c
index 9b8c622..8ec106a 100644
--- a/usr.bin/oemu/cpu.c
+++ b/usr.bin/oemu/cpu.c
@@ -163,6 +163,12 @@ cpu_kick(struct oemu_cpu *cpu, struct sysmem *mem)
break;
}
+ /* Is this a halt instruction? */
+ if (inst->opcode == INST_HLT) {
+ printf("HALTED\n");
+ break;
+ }
+
if (regs->ip >= MEMORY_SIZE) {
break;
}
diff --git a/usr.bin/oemu/include/oemu/osmx64.h b/usr.bin/oemu/include/oemu/osmx64.h
index d7ea8b1..e9baae0 100644
--- a/usr.bin/oemu/include/oemu/osmx64.h
+++ b/usr.bin/oemu/include/oemu/osmx64.h
@@ -47,6 +47,7 @@
#define INST_SLL 0x11 /* Shift left logical operation */
#define INST_SRL 0x12 /* Shift right logical operation */
#define INST_MOV_IMM 0x13 /* Data move operation from IMM */
+#define INST_HLT 0x14 /* Halt */
/* Registers */
#define REG_X0 0x00