Thread: Simple Question
View Single Post
Old 22 January 2009, 01:39   #13
Ray Norrish
Registered User
 
Ray Norrish's Avatar
 
Join Date: May 2005
Location: Cheshire, UK
Age: 56
Posts: 322
I skipped over some stuff, but I think I know what the op means.

He may be talking about PC code, where you can sacrifice an address register as a reference to the start of the executable (or thereabouts)

So..

lea base_label(pc),a6

thereby -depending on compiler- reference other statics as #myvar-a6 or some such.. (I'd have to consult some old code to confirm) but making you code PC or reloc compatible.

Of course addressing MOVEA.W #FTABLE,A0 is ludicrous, as this would only work if #ftable was resident in <64K memory.

I prefer to refer to a label with LEA FTABLE(pc),A0 although move.l #FTABLE,A0 will do.

If PC code is desired, then using the above method (something like LEA FTABLE-a6(pc),a0) would ensure reloc code.

You are able to compile your code without org instructions and use a variety of tools to reloc the code, however you don`t usually need to do this unless you are coding multiple sets of code or relying on a loader to position code etc..

I remember that (pc) only works within a word range? and I used to have countless arguments with fellow coders regarding "pc" coding styles.. but .. if you use the PC register, you can code independant code that can be loaded to any location, although for trackmos / independant loading of code, you can "org" your code and load it there - it will be fine.

Last edited by Ray Norrish; 22 January 2009 at 01:46.
Ray Norrish is offline  
 
Page generated in 0.04677 seconds with 11 queries