[Top][All Lists]

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

Re: [avr-gcc-list] avr-gcc adding 'cli's in function prologues...

From: Larry Barello
Subject: Re: [avr-gcc-list] avr-gcc adding 'cli's in function prologues...
Date: Fri, 18 May 2001 07:10:20 -0700

The procedure code (your code) *must* save R2-R17, R28 & R29.  R0, R18-R27,
R30 & R31 are fair game (parameters and temps) for your code.  R1 always ==
0 upon exit or calling another C routine.  GCC depends upon Y being left
alone - as you found out!

This information can be found in "ctoasm.inc" found in the libc source that
is distributed with the compiler.


----- Original Message -----
From: "Ludovic COURTES" <address@hidden>

> Hi !
> I finally found what was going wrong with gcc's prologue and epilogue.
> As i wrote before (see below), avr-gcc uses Y (r29:r28) to store stack
> pointer and then decrement it in order to reserve some space for local
> variables in SRAM (this is done in function prologue) and then increment
> it with the same value to restore original SP (this is done in epilogue).
> The problem is that gcc doesn't save Y at the end of prologue. Therefore,
> if your code uses theses registers and modify them, then the ret
> won't do what you want it to (as the SP will be wrong) !
> I fixed it just by adding a "push y" and a "pop y" at the beginning and
> at the end of my code.

reply via email to

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