From ba4121b6c47d01a1e5e66881f17728ab823f9b98 Mon Sep 17 00:00:00 2001 From: Maxwell Jeffress Date: Thu, 16 Jul 2026 19:18:49 +1000 Subject: [PATCH] Fix bug with imm16 processing --- src/memory.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/memory.c b/src/memory.c index c1c6614..c0d7c3f 100644 --- a/src/memory.c +++ b/src/memory.c @@ -83,7 +83,8 @@ Instruction decodeInstruction(Memory* m, uint32_t* pc) { case OP_IMM16: { // the immediate 16 takes up the space where the next instruction would be (*pc) += sizeof(SerializedInst); - uint16_t nextDataOver = m->data[*pc]; + uint16_t nextDataOver; + memcpy(&nextDataOver, &m->data[*pc], sizeof(uint16_t)); outputInst.immediate = nextDataOver; outputInst.hasImm16 = true; break; @@ -109,4 +110,4 @@ void freeMemory(Memory* m) { inline uint32_t getAddress(uint16_t low, uint16_t high) { return (high << 16) | low; -} \ No newline at end of file +}