I know one can compile a function at a fixed address.
But is it possible to compile a source file at a fixed address? For example: Main.c is compiled from 0x1000.
So all the functions in Main.c will be compiled from 0x1000 and further on.
If this is possible, how do I configure the compiler/code to do this?
yes thats possible with a modified startup.a51. But you should relocate the irq vectors too and you will need a starting programm at 0x0000 of course
Thomas
I used Main.c just as an example, but the file that I'm actually relocating is Control.c
What I've done is this:
CODE(?PR?*?CONTROL (3000h))
So it comipled Control.c from 0x3000 and further on. All the functions contained in Control.c is compiled from this address.
I don't think I should be worried about interrupts, since this file does not make use of any interrupts?
I have another question.
In my Control.h header file a have a #define that looks like this.
#define SUPPLY (0x80u) #define SUPPLY_ON (C21 |= SUPPLY) #define SUPPLY_OFF (C21 &= ~SUPPLY)
Now C21 is a variable, how will the compiler interpret this define, since I'm using and chaging a variable in the define (not constant), will it see this as a function? And if it sees it as a function, where will this #define/function be comipled in memory.
Just remember now, I've relocated Control.c from 0x3000. I had a look in the M51 file to check if I can see what it did with the define but no indication.