Thread: Simple Question
View Single Post
Old 09 January 2009, 19:48   #12
Ed Cruse
Registered User
 
Join Date: Sep 2007
Location: Las Cruces, USA
Age: 71
Posts: 351
Quote:
Originally Posted by StingRay View Post
you do



while that code is of course perfectly ok, it's not what the thread opener asked about:


He asked if it is ok to use absolute (or fixed) addresses and something like
lea $7000.w,a0 WON'T be converted to an offset when you use org/load directives, i.e. assemble your program to fixed memory locations!



That's not quite correct either, it is perfectly possible to reach offsets larger than 16 bit (e.g. a different SECTION) WITHOUT using absolute addressing. There's actually NO reason to have any RELOC32 entry in any program. So saying that you should always use absolute addressing when you need to access a label in another section is simply wrong.



While there's nothing wrong with it, there ARE reasons why you need to worry about it (sometimes size DOES matter, you know ;D) I for myself HATE non-relocatable code and try to avoid it whenever I can.
OK, I have to ask a stupid question. How do you reference to other sections with relative addressing, I may know but right now it don't. I can see doing multiple relative jumps, but you don't know how many. Seems like my C compiler will insert an absolute jump in a situation like that. I suppose I could follow the linking from section to section and get the pointer of the section of interest. I'm actuall interested in knowing, something new to learn.

I'm sorry if I didn't pick my words really well. You're absolutely right, for small fast code absolute addressing is not the way to go, but for situation where you're not to concerned, it's not something to worry about. I will try and pick my words better next time.

Last edited by Ed Cruse; 09 January 2009 at 19:58.
Ed Cruse is offline  
 
Page generated in 0.04673 seconds with 11 queries