cpu/arm: fix branch and exchange
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
@@ -24,15 +24,19 @@ Instruction::exec(Cpu& cpu) {
|
|||||||
std::visit(
|
std::visit(
|
||||||
overloaded{
|
overloaded{
|
||||||
[&cpu, pc_warn](BranchAndExchange& data) {
|
[&cpu, pc_warn](BranchAndExchange& data) {
|
||||||
State state = static_cast<State>(data.rn & 1);
|
uint32_t addr = cpu.gpr[data.rn];
|
||||||
|
State state = static_cast<State>(get_bit(addr, 0));
|
||||||
|
|
||||||
pc_warn(data.rn);
|
pc_warn(data.rn);
|
||||||
|
|
||||||
|
if (state != cpu.cpsr.state())
|
||||||
|
glogger.info_bold("State changed");
|
||||||
|
|
||||||
// set state
|
// set state
|
||||||
cpu.cpsr.set_state(state);
|
cpu.cpsr.set_state(state);
|
||||||
|
|
||||||
// copy to PC
|
// copy to PC
|
||||||
cpu.pc = cpu.gpr[data.rn];
|
cpu.pc = addr;
|
||||||
|
|
||||||
// ignore [1:0] bits for arm and 0 bit for thumb
|
// ignore [1:0] bits for arm and 0 bit for thumb
|
||||||
rst_bit(cpu.pc, 0);
|
rst_bit(cpu.pc, 0);
|
||||||
|
@@ -168,7 +168,10 @@ Instruction::exec(Cpu& cpu) {
|
|||||||
cpu.is_flushed = true;
|
cpu.is_flushed = true;
|
||||||
} break;
|
} break;
|
||||||
case HiRegisterOperations::OpCode::BX: {
|
case HiRegisterOperations::OpCode::BX: {
|
||||||
State state = static_cast<State>(op_2 & 1);
|
State state = static_cast<State>(get_bit(op_2, 0));
|
||||||
|
|
||||||
|
if (state != cpu.cpsr.state())
|
||||||
|
glogger.info_bold("State changed");
|
||||||
|
|
||||||
// set state
|
// set state
|
||||||
cpu.cpsr.set_state(state);
|
cpu.cpsr.set_state(state);
|
||||||
|
Reference in New Issue
Block a user