Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > address for changing pointers for rts?
2006-02-11 01:23
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 :(
2006-02-11 02:05
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.
2006-02-11 02:13
midiland
Account closed

Registered: Nov 2004
Posts: 4
Ahhh thats it...!!!!

Thanks mate!

2006-02-11 12:36
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.
2006-02-11 12:39
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.
2006-02-11 14:33
Style

Registered: Jun 2004
Posts: 498
He'll figure it out :)
2006-02-11 15:34
Oswald

Registered: Apr 2002
Posts: 5094
ninja, indeed, this question smells me some horrible coding style
2006-02-11 15:55
JackAsser

Registered: Jun 2002
Posts: 2014
@Oswald: That coding style have saved me quite some times. =) But yes, horrible indeed.
2006-02-11 16:45
Zyron

Registered: Jan 2002
Posts: 2381
You naughty boy :)
2006-02-12 09:41
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?
2006-02-12 16:44
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
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Alakran_64
The Syndrom/TIA/Pret..
fegolhuzz
csabanw
MWR/Visdom
grennouille
Guests online: 132
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 Tim  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.037 sec.