[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] ATmega2560 and r30/31 save in function prologue
From: |
Stu Bell |
Subject: |
[avr-gcc-list] ATmega2560 and r30/31 save in function prologue |
Date: |
Fri, 2 May 2008 13:23:46 -0600 |
Hi all,
I'm chasing down a problem with WinAVR 20080430 and my ATmega2560 code.
In generated code comparisons of an ISR between 20071221 and 20080430, I
noticed that r30 and r31 are not saved on the stack. Normally, this
wouldn't be a problem as the ISR itself does not use r30/r31.
However, this ISR calls a function that does use r30/r31. Again, it
*should* be no problem, since the function has the responsibility to
stor r30/r31 if it uses it.
But it doesn't. I didn't in 20071221, either, but since the ISR in
20071221 *did* push r30/r31, it was covered up. Ergo, a problem shows
up in 20080430 that wasn't in 20071221.
I'm trying to come up with a simple test case to show this behavior, but
I wanted a quick "ping" to the avr-gcc elite to see if there would be
some reason why r30/r31 should be ignored in a function prologue even
though they are used in the function.
Here's the (non-optimized) code generated from 20071221. I haven't
included the entire function (it's from FreeRTOS, if anyone is
interested), but you can clearly see that we enter the function, do the
prologue and then start hammering on r30/r31 at .LM103.
.global xQueueReceiveFromISR
xQueueReceiveFromISR:
.LFB6:
.LM102:
/* prologue: frame size=7 */
CF93 push r28
DF93 push r29
CDB7 in r28,__SP_L__
DEB7 in r29,__SP_H__
2797 sbiw r28,7
0FB6 in r0,__SREG__
F894 cli
DEBF out __SP_H__,r29
0FBE out __SREG__,r0
CDBF out __SP_L__,r28
/* prologue end (size=10) */
9B83 std Y+3,r25
8A83 std Y+2,r24
7D83 std Y+5,r23
6C83 std Y+4,r22
5F83 std Y+7,r21
4E83 std Y+6,r20
.LM103:
EA81 ldd r30,Y+2
FB81 ldd r31,Y+3
82A1 ldd r24,Z+34
8823 tst r24
01F0 breq .L76
.LM104:
8C81 ldd r24,Y+4
9D81 ldd r25,Y+5
2A81 ldd r18,Y+2
3B81 ldd r19,Y+3
BC01 movw r22,r24
C901 movw r24,r18
0E94 0000 call prvCopyDataFromQueue
.LM105:
EA81 ldd r30,Y+2
FB81 ldd r31,Y+3
82A1 ldd r24,Z+34
Am I not understanding something here? Comments??
Best regards,
Stu Bell
DPHI, Inc. (DataPlay)
- [avr-gcc-list] ATmega2560 and r30/31 save in function prologue,
Stu Bell <=