If you set the function placement to the initialized data section with
extern void foobar (void) __attribute__((section (".data")));
the compiler startup code will move it for you and all you have to do
is call it by name just as you would any other function.
Regards
-Bill Knight
R O SoftWare
On Thu, 13 Jan 2005 13:22:47 -0700, Rick Jenkins wrote:
>Sometimes it's necessary to move code into RAM for execution, for instance
>when reprogramming the main flash. It isn't too hard to do this in C, by
>compiling all the code to be moved into a special section within .text, then
>copying the whole section to RAM. Of course the code moved has to be
>position-independent.
>The global compiler option -fpic simply accesses all constant addresses via a
>table in RAM. This table can be quite large, and may be overwritten when the
>code is moved. Using it is pretty clumsy.
>If one avoids static variables, most of the code is position-independent
>anyway. The difficulty lies in function calls. MSP430-gcc compiles these
>with an absolute address, allowing calls to any place in memory. That's
>normally exactly what one wants, but when the code is moved the calls still
>address flash.
>It would be good to write a macro to use the PC-relative 'symbolic"
>addressing mode, something along the lines of:
>#define PI_CALL(f) asm("call %0"::"?"(f))
>but there seems to be no constraint which generates the right addressing
>mode. Am I missing something really obvious here?
>--
>Rick Jenkins <[email protected]>
>Hartman Technica http://www.hartmantech.com
>Phone +1 (403) 230-1987 voice & fax
>221 35 Avenue. N.E., Calgary, Alberta, Canada T2E 2K5
>-------------------------------------------------------
>The SF.Net email is sponsored by: Beat the post-holiday blues
>Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
>It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
>_______________________________________________
>Mspgcc-users mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/mspgcc-users