RIP-Comm / clementine

Gameboy Advance emulator.
MIT License
49 stars 13 forks source link

ARM: Add `branch_link` implementation for `arm7tdmi` #48

Closed FedericoBruzzone closed 2 years ago

FedericoBruzzone commented 2 years ago

Closes #46

It is a first implementation. This implementation looks like that of branch, but if the bit 24 is set to 1 we need save the PC in cell 14 of the registers.

Signed-off-by: Federico Bruzzone federico.bruzzone.i@gmail.com

FedericoBruzzone commented 2 years ago

Branch with Link (BL) writes the old PC into the link register (R14) of the current bank. The PC value written into R14 is adjusted to allow for the prefetch, and contains the address of the instruction following the branch and link instruction. Note that the CPSR is not saved with the PC and R14[1:0] are always cleared.


This part has not been implemented.

To return from a routine called by Branch with Link use MOV PC,R14 if the link register is still valid or LDM Rn!,{..PC} if the link register has been saved onto a stack pointed to by Rn.

So, do we want to open an issue about this?