little endian

This commit is contained in:
sfja 2026-02-15 21:58:55 +01:00
parent 5d64c62171
commit b7ed64e6c0
2 changed files with 6 additions and 6 deletions

View File

@ -79,8 +79,8 @@ public:
void push(uint16_t v) void push(uint16_t v)
{ {
m_data[m_ip] = v >> 8; m_data[m_ip] = v & 0xff;
m_data[m_ip + 1] = v & 0xff; m_data[m_ip + 1] = v >> 8;
m_ip += 2; m_ip += 2;
} }

View File

@ -145,8 +145,8 @@ uint16_t VM::word(uint16_t addr) const
} }
uint16_t value = 0; uint16_t value = 0;
value |= static_cast<uint16_t>(m_mem[addr]) << 8; value |= m_mem[addr];
value |= m_mem[addr + 1]; value |= static_cast<uint16_t>(m_mem[addr + 1]) << 8;
return value; return value;
} }
@ -167,8 +167,8 @@ void VM::set_word(uint16_t addr, uint16_t value)
std::format("invalid address alignment, addr = {}", addr)); std::format("invalid address alignment, addr = {}", addr));
} }
m_mem[addr] = value >> 8; m_mem[addr] = value & 0xff;
m_mem[addr + 1] = value & 0xff; m_mem[addr + 1] = value >> 8;
} }
void VM::set_byte(uint16_t addr, uint8_t value) void VM::set_byte(uint16_t addr, uint8_t value)