From cf0acae537a4664948485bc9e9a370fe7d100803 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 21 Jul 2025 09:18:51 -0400 Subject: oemu: cpu: Decode and process HLT instruction Signed-off-by: Ian Moffett --- usr.bin/oemu/cpu.c | 6 ++++++ usr.bin/oemu/include/oemu/osmx64.h | 1 + 2 files changed, 7 insertions(+) (limited to 'usr.bin') 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 -- cgit v1.2.3