From c5fc6a8493d55e0134b153b2d34f15275cfee768 Mon Sep 17 00:00:00 2001 From: SpookyDervish Date: Thu, 16 Jul 2026 19:13:03 +1000 Subject: [PATCH] fix instruction loading i think --- add.o | Bin 17 -> 22 bytes src/emu.c | 4 ++++ src/main.c | 4 +--- src/memory.c | 1 - 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/add.o b/add.o index 0e926cabb13784ff32f29d53a1b34503d8b77fef..44f77e0310119e635c874c4bfff312a440bb0fae 100644 GIT binary patch literal 22 acmd1JNoHVVU|?VcVnzl*1|}fQzyJUn0s&V5 literal 17 Vcmd1JNoHVVVE_R}20;cU1^^Uh0agG2 diff --git a/src/emu.c b/src/emu.c index fd3b65c..8f86cf3 100644 --- a/src/emu.c +++ b/src/emu.c @@ -84,7 +84,11 @@ void startEmulator(Emulator* emu) { #define DISPATCH() if (emu->irq != 0) handleInterrupt(emu); \ updateDevices(emu); \ + if (emu->halted) { \ + return; \ + } \ inst = fetchInst(emu); \ + printf("%s\n", instructionToCStr(inst)); \ goto *dispatchTable[inst.opcode] DISPATCH(); diff --git a/src/main.c b/src/main.c index b28c5f3..28ee566 100644 --- a/src/main.c +++ b/src/main.c @@ -35,9 +35,7 @@ int main(int argc, char** argv) { return 1; } - memcpy(emu->mem + MEM_PROGRAM_START, rom->instructions, sizeof(SerializedInst) * rom->header.numInstructions); - - printf("hi i exist\n"); + memcpy(emu->mem->data + MEM_PROGRAM_START, rom->instructions, sizeof(SerializedInst) * rom->header.numInstructions); startEmulator(emu); freeEmulator(emu); diff --git a/src/memory.c b/src/memory.c index 2f1d2e9..c1c6614 100644 --- a/src/memory.c +++ b/src/memory.c @@ -53,7 +53,6 @@ uint32_t memorySerializeInst(Memory* m, Instruction inst, uint32_t offset) { void memoryLoadProgram(Memory* m, Instruction program[], size_t numInstructions) { size_t offset = 0; for (size_t i = 0; i < numInstructions; i++) { - printf("%zu. %s\n", i, instructionToCStr(program[i])); offset = memorySerializeInst(m, program[i], offset); } }