Program Counter
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
True, and you're reminding me of why I abandoned my quest for relocatable code on the 6502-- code that could be scooted around in memory after it was loaded and may have already been running. It wasn't so much the code location that was the problem as the data location. It can still be done, but it was getting too cumbersome to be worth it. If you have some slick ideas though, I might take it up again.
dcl raises a point that I didn't consider at the time. However, if you're willing to invest in using 5 bytes of zero-page at a fixed (or linker-patched) address,
You have to JSR to whereAmI -- JMPing to it will likely cause a crash.
Code: Select all
.proc whereAmI
ldx #3
again:
lda thunk,x
sta zpThunk,x
dex
bpl again
jsr zpThunk
thunk:
pla
tax
pla
rts
.endproc