foxchild wrote:
Is it possible to manually push and pop the PC with the 65816?
I need to do PC relative jumps but can't really think of a reasonable way to jump back. Any ideas?
I'm late to the party here, but what you want is the equivalent of the
BSR instruction found in the Motorola 68K MPUs. It can be easily written as a macro:
Code:
; BSR: Branch to Subroutine
; ——————————————————————————————————————————————————————————————————————
; This macro synthesizes the BSR instruction implemented in the Motorola
; 6800 & 68000 microprocessors. Programs in which subroutines are call-
; ed via BSR are fully relocatable, as the target address is calculated
; relative to the program counter at run-time. The target address must
; be within the range of a long relative branch, +$7FFF or -$8000 bytes.
; ——————————————————————————————————————————————————————————————————————
;
bsr .macro .sr ;BSR <addr>
.mib =$82
.mip =$62
.na =*+3
.ra .set .na+2
.ba =.ra+1
.ra .set .ra-.na
.ta .set .sr-.ba
.byte .mip,<.ra,>.ra,.mib,<.ta,>.ta
.endm
The above was written to synthesize
BSR <ADDR> on the '816, using the Kowalski simulator to assemble the source code. It takes advantage of
BRL (long relative branch) and
PER.