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 +}