avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fwd: Re: [avr-gcc-list] Allocating variables to a fixed address]


From: Robert von Knobloch
Subject: [Fwd: Re: [avr-gcc-list] Allocating variables to a fixed address]
Date: Tue, 12 May 2009 12:31:05 +0200
User-agent: Thunderbird 1.5.0.14 (X11/20060911)

Jan Waclawek wrote:
>> I simply require a way to fix absolutely this jump table in memory.
>> Whether I write it in C or assembler seems to me to be irrelevant, as is
>> using an array of pointer to functions, because I still have the problem
>> of fixing these at absolute addresses.
>>
>> If anyone knows a way to do this, I would very much appreciate it.
>>     
>
>
> The attachment illustrates what I mean by jumptable in asm, and its usage 
> (see main). Address of .mysection was fixed to 0x00FF by passing it to the 
> linker through avr-gcc ("-Wl,--section-start,.mysection=0xFF00"). 
>
> It of course can be a separate asm file, and the individual lines can be 
> generated by a handy macro; but those are only unimportant details.
>
> Enjoy! ;-)
>
> JW
>
>
>
>   
Thanks Jan,
This is effectively what I have done, except I used C stubs instead of
assembler:

[.section origin is at 0xff00]
void test_func_1(uint16_t foo)
{
    func_1(foo);
}
void test_func_2(uint16_t foo)
{
    func_2(foo);
}

Why would the compiler respect assembler any more than my C calls (it
changes the order of them as they are stored in memory, so I cannot
guarantee the address of "test_func_1()")

If GCC will respect the order of the assembler jumps (and thus the
absolute address) then that is my easiest solution. At the moment I
can't really see any difference between assembler and C here. Or does
someone know better ?

You see I really distrust the compiler now :-)

Robert






reply via email to

[Prev in Thread] Current Thread [Next in Thread]