[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] Stack pointer loaded on main entry?
From: |
Harald Kipp |
Subject: |
[avr-libc-dev] Stack pointer loaded on main entry? |
Date: |
Fri, 07 Mar 2003 12:09:08 +0100 |
Hi,
I'm using
void MyInit(void) __attribute__ ((naked)) __attribute__ ((section(".init8")));
to do some initialization for a multithreaded RTOS. Actually this
function never returns. It initializes some internal RTOS stuff,
allocates stack space, sets up the stack pointer and calls main.
Everything works as expected.
The problem is, however, that the compiler generates
main:
/* prologue: frame size=4 */
ldi r28,lo8(__stack - 4)
ldi r29,hi8(__stack - 4)
out __SP_H__,r29
out __SP_L__,r28
/* prologue end (size=4) */
which reloads the stack pointer. Shouldn't it look like
this?
main:
/* prologue: frame size=4 */
in r28,__SP_L__
in r29,__SP_H__
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?
Thanks for any hint,
Harald Kipp
- [avr-libc-dev] Stack pointer loaded on main entry?,
Harald Kipp <=
Re: [avr-libc-dev] Stack pointer loaded on main entry?, Marek Michalkiewicz, 2003/03/07