fix instruction loading i think

This commit is contained in:
2026-07-16 19:13:03 +10:00
parent 3bf340d9f2
commit c5fc6a8493
4 changed files with 5 additions and 4 deletions

BIN
add.o

Binary file not shown.

View File

@@ -84,7 +84,11 @@ void startEmulator(Emulator* emu) {
#define DISPATCH() if (emu->irq != 0) handleInterrupt(emu); \ #define DISPATCH() if (emu->irq != 0) handleInterrupt(emu); \
updateDevices(emu); \ updateDevices(emu); \
if (emu->halted) { \
return; \
} \
inst = fetchInst(emu); \ inst = fetchInst(emu); \
printf("%s\n", instructionToCStr(inst)); \
goto *dispatchTable[inst.opcode] goto *dispatchTable[inst.opcode]
DISPATCH(); DISPATCH();

View File

@@ -35,9 +35,7 @@ int main(int argc, char** argv) {
return 1; return 1;
} }
memcpy(emu->mem + MEM_PROGRAM_START, rom->instructions, sizeof(SerializedInst) * rom->header.numInstructions); memcpy(emu->mem->data + MEM_PROGRAM_START, rom->instructions, sizeof(SerializedInst) * rom->header.numInstructions);
printf("hi i exist\n");
startEmulator(emu); startEmulator(emu);
freeEmulator(emu); freeEmulator(emu);

View File

@@ -53,7 +53,6 @@ uint32_t memorySerializeInst(Memory* m, Instruction inst, uint32_t offset) {
void memoryLoadProgram(Memory* m, Instruction program[], size_t numInstructions) { void memoryLoadProgram(Memory* m, Instruction program[], size_t numInstructions) {
size_t offset = 0; size_t offset = 0;
for (size_t i = 0; i < numInstructions; i++) { for (size_t i = 0; i < numInstructions; i++) {
printf("%zu. %s\n", i, instructionToCStr(program[i]));
offset = memorySerializeInst(m, program[i], offset); offset = memorySerializeInst(m, program[i], offset);
} }
} }