avr-libc-dev
[Top][All Lists]
Advanced

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

Re: [avr-libc-dev] Stack pointer loaded on main entry?


From: Joerg Wunsch
Subject: Re: [avr-libc-dev] Stack pointer loaded on main entry?
Date: Fri, 7 Mar 2003 12:27:59 +0100
User-agent: Mutt/1.2.5i

As Harald Kipp wrote:

> which reloads the stack pointer. Shouldn't it look like
> this?
> 
> main:
> /* prologue: frame size=4 */
>          in r28,__SP_L__
>          in r29,__SP_H__

How would you be able to fetch the current stack pointer value if it
hasn't been initialized yet (as in the regular main() case)?

>          sbiw r28,4
>          in __tmp_reg__,__SREG__
>          cli
>          out __SP_H__,r29
>          out __SREG__,__tmp_reg__
>          out __SP_L__,r28
> /* prologue end (size=4) */
> 
> Is there any way to avoid overriding the stack pointer?

Don't use main().

I'm not sure how the compiler behaves if you set -ffreestanding.
Normally, this should tell it to not treat main() in any special
manner (but it has other side effects, see the documentation).

No, tried it, that doesn't help.  So your only method is to not use
main() at all.  You could perhaps achieve this by using something like

#define main task_main

in the header file all your RTOS tasks need to include anyway.  If
that's impossible, consider adding

-Dmain=task_main

to the compiler command line.
-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/




reply via email to

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