I'm having trouble trying to JSL to a routine that requires a JSR. The trick i'm trying can be found here number 6. The code looks like:
In my context, i'd like to call the glitter routine from bank 0. So this is what I can interpret from the code:
- Push the program bank.
- I think this is push relative to the PC. This is one of the sources of confusion as you'll see later.
- Push an address in bank 0 that has RTL next ($84CE).
- Jump to the subroutine ($00FD5A).
- Routine finishes, return to $84CE + 1, which is an RTL.
- RTL to whatever was pushed in the opcode PER $0006.
This is where i'm stuck. Could someone please explain what happens from here and what PER $0006 actually does?
Thanks
EDIT: Logically it makes sense for the RTL at $84CF to return one line after the jump, so what was the point of PHK. Wouldn't it still be on the stack?
Code
PHK PER $0006 PEA $yyyy JML $xxxxxx
In my context, i'd like to call the glitter routine from bank 0. So this is what I can interpret from the code:
- Push the program bank.
- I think this is push relative to the PC. This is one of the sources of confusion as you'll see later.
- Push an address in bank 0 that has RTL next ($84CE).
- Jump to the subroutine ($00FD5A).
- Routine finishes, return to $84CE + 1, which is an RTL.
- RTL to whatever was pushed in the opcode PER $0006.
This is where i'm stuck. Could someone please explain what happens from here and what PER $0006 actually does?
Thanks
EDIT: Logically it makes sense for the RTL at $84CF to return one line after the jump, so what was the point of PHK. Wouldn't it still be on the stack?