Skip to content

Commit

Permalink
Bus: Fix sideloading EXEs without initial SP value
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Aug 11, 2024
1 parent 62eb557 commit 00a58eb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/core/bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,9 +981,14 @@ bool Bus::InjectExecutable(std::span<const u8> buffer, bool set_pc, Error* error
if (set_pc)
{
const u32 r_pc = header.initial_pc;
CPU::g_state.regs.gp = header.initial_gp;
CPU::g_state.regs.sp = header.initial_sp_base + header.initial_sp_offset;
CPU::g_state.regs.fp = header.initial_sp_base + header.initial_sp_offset;
const u32 r_gp = header.initial_gp;
const u32 r_sp = header.initial_sp_base + header.initial_sp_offset;
CPU::g_state.regs.gp = r_gp;
if (r_sp != 0)
{
CPU::g_state.regs.sp = r_sp;
CPU::g_state.regs.fp = r_sp;
}
CPU::SetPC(r_pc);
}

Expand Down

0 comments on commit 00a58eb

Please sign in to comment.