|
From: | Szikra Istvan |
Subject: | Re: [avr-gcc-list] push r1, pop r0 |
Date: | Tue, 7 Nov 2017 22:17:10 +0100 |
Hi Szikra,
I believe these pushes and pops are just meant to allocate 2 bytes on
the stack.
> 222: cd b7 in r28, 0x3d ; 61
> 224: de b7 in r29, 0x3e ; 62
This loads Y with SP, so the location of the 2 pushed bytes
> 226: 2e b7 in r18, 0x3e ; 62
> 228: 8d b7 in r24, 0x3d ; 61
> 22a: 90 e0 ldi r25, 0x00 ; 0
> 22c: 92 2b or r25, r18
This is the load SP from your code variable
> 22e: 89 83 std Y+1, r24 ; 0x01
> 230: 9a 83 std Y+2, r25 ; 0x02
This stores SP to your sp variable on the stack
> 232: 89 81 ldd r24, Y+1 ; 0x01
> 234: 9a 81 ldd r25, Y+2 ; 0x02
This loads your sp variable into the return value
I wonder why this even forces the value onto the stack, since that's
really not needed at all. Perhaps the "volatile" on your "sp" variable
causes this, or perhaps you're compiling without optimization?
Gr.
Matthijs
[Prev in Thread] | Current Thread | [Next in Thread] |