| |
midiland Account closed
Registered: Nov 2004 Posts: 4 |
address for changing pointers for rts?
Hey guys
I need a reminder of the addresses used for when I need to change an address for a "rts" so it returns to a new location rather than the old
eg
jsr blah
rts
blah rts
but instead of returning to the jsr'd address to go to a new address
Thanks!!
I cant remember the mem locations to change it :( |
|
| |
Style
Registered: Jun 2004 Posts: 498 |
PLA
PLA
LDA #<new address
PHA
LDA #>new address
PHA
or similar :) During a JSR the return address (PC + 2) is pushed to the stack. I think its in low byte/high byte order.
Obviously during an RTS the address is then pulled from the stack. |
| |
midiland Account closed
Registered: Nov 2004 Posts: 4 |
Ahhh thats it...!!!!
Thanks mate!
|
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
Not quite, you must store "address-1" to stack if you want to return to the opcode after the JSR. |
| |
Ninja
Registered: Jan 2002 Posts: 411 |
PLA
PLA
JMP new_adress
is shorter and faster. And as we are at it:
JSR somewhere
RTS
can be replaced with
JMP somewhere
which is also shorter and faster. |
| |
Style
Registered: Jun 2004 Posts: 498 |
He'll figure it out :) |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
ninja, indeed, this question smells me some horrible coding style |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
@Oswald: That coding style have saved me quite some times. =) But yes, horrible indeed. |
| |
Zyron
Registered: Jan 2002 Posts: 2381 |
You naughty boy :) |
| |
Monte Carlos
Registered: Jun 2004 Posts: 359 |
If Steve Wozniak used it in its Sweet 16 asm style interpreter
for the Apple II, why should we not use it?
|
| |
Cruzer
Registered: Dec 2001 Posts: 1048 |
I prefer
jmp subroutine
back:
subroutine:
jmp back
for subroutines that are only called from one place, e.g. typically speedcode, since it saves 6 cycles. No coding style is horrible if it saves cycles :) |
... 11 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 | 3 - Next |