cpu/thumb: fix pc relative load

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2024-06-11 23:22:34 +05:30
parent 15c4802838
commit 9e6b121918
2 changed files with 4 additions and 3 deletions

View File

@@ -189,6 +189,7 @@ Instruction::exec(Cpu& cpu) {
},
[&cpu](PcRelativeLoad& data) {
uint32_t pc = cpu.pc;
rst_bit(pc, 0);
rst_bit(pc, 1);
cpu.gpr[data.rd] = cpu.bus->read_word(pc + data.word);

View File

@@ -1,6 +1,5 @@
#include "cpu/cpu-fixture.hh"
#include "cpu/thumb/instruction.hh"
#include "util/bits.hh"
#include <catch2/catch_test_macros.hpp>
using namespace matar;
@@ -531,8 +530,9 @@ TEST_CASE_METHOD(CpuFixture, "PC Relative Load", TAG) {
InstructionData data = PcRelativeLoad{ .word = 0x578, .rd = 0 };
setr(15, 0x3003FD5);
// 0x3003FD5 + 0x578
bus.write_word(0x300454D, 489753492);
// resetting bit 0 for 0x3003FD5, we get 0x3003FD4
// 0x3003FD4 + 0x578
bus.write_word(0x300454C, 489753492);
CHECK(getr(0) == 0);
exec(data);