Fix 32-bit register reading/writing

Co-Authored-By: Ryan Teal <rynteal@protonmail.com>
This commit is contained in:
◱ PixelyIon 2019-08-19 03:37:47 +05:30
parent 9a36d5fcf9
commit 9657064740
2 changed files with 3 additions and 3 deletions

View File

@ -107,10 +107,10 @@ namespace lightSwitch::hw {
}
uint64_t Cpu::GetRegister(wreg reg_id) {
return (reinterpret_cast<uint32_t *>(regs.regs))[wreg_lut[reg_id]];
return (reinterpret_cast<uint32_t *>(&regs.regs))[wreg_lut[reg_id]];
}
void Cpu::SetRegister(wreg reg_id, uint32_t value) {
(reinterpret_cast<uint32_t *>(regs.regs))[wreg_lut[reg_id]] = value;
(reinterpret_cast<uint32_t *>(&regs.regs))[wreg_lut[reg_id]] = value;
}
}

View File

@ -34,7 +34,7 @@ namespace lightSwitch::hw {
void WriteBreakpoint(uint64_t address, uint64_t size);
uint8_t wreg_lut[31] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61};
uint8_t wreg_lut[31] = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60};
public:
~Cpu();