Fix bug with imm16 processing

This commit is contained in:
2026-07-16 19:18:49 +10:00
parent c5fc6a8493
commit ba4121b6c4

View File

@@ -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 case OP_IMM16: { // the immediate 16 takes up the space where the next instruction would be
(*pc) += sizeof(SerializedInst); (*pc) += sizeof(SerializedInst);
uint16_t nextDataOver = m->data[*pc]; uint16_t nextDataOver;
memcpy(&nextDataOver, &m->data[*pc], sizeof(uint16_t));
outputInst.immediate = nextDataOver; outputInst.immediate = nextDataOver;
outputInst.hasImm16 = true; outputInst.hasImm16 = true;
break; break;
@@ -109,4 +110,4 @@ void freeMemory(Memory* m) {
inline uint32_t getAddress(uint16_t low, uint16_t high) { inline uint32_t getAddress(uint16_t low, uint16_t high) {
return (high << 16) | low; return (high << 16) | low;
} }