[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Unnecessary mov to temp register in inline funct.
From: |
Christian Vogel |
Subject: |
[avr-gcc-list] Unnecessary mov to temp register in inline funct. |
Date: |
Mon, 6 Jan 2003 15:28:45 +0100 |
User-agent: |
Mutt/1.4i |
Hi,
I have a simple routine to send a char out of the uart:
> inline void send_char_uart(unsigned char c){
> while(! (USR & BV(UDRE)) ); /* wait until last char is gone */
> UDR = c; /* send char out of serial port */
> }
Now if I call this in another routine, the data is first moved from
the original register to a temp register and then out'ed to UDR:
(comments by myself, assembly code by gcc version 3.3 20021111 (experimental).
(rpm by address@hidden, many thanks!):
mov r24,r21 ; data32_0(r21) --> r24
sbis 0x0b,5 ; <--+
rjmp .-4 ; ---+ while(! USR & BV(UDRE) );
out 0x06,r24 ; r24 --> UDR
What I would preferrably use is just out 0x06,r21 and forget the first mov.
Can I do something (besides making this short function a #define, this
get's rid of the temp register) to make this inline-function not use the
temp-register or is the assemly of an inline function fixed as soon
as it's defined so gcc really *HAS* to use this fixed register r24?
Chris
---- just for reference, a snippet of my main program ---
(which just read data from a ADC and outputs it to
my computer's serial port)
> /* access variable as 32 bit or 4x 8 bit */
> typedef union {
> uint32_t data32; /* later: r18..21 */
> struct {
> uint8_t data32_0; /* later: r18 */
> uint8_t data32_1; /* later: r19 */
> uint8_t data32_2; /* later: r20 */
> uint8_t data32_3; /* later: r21 */
> };
> } union32_t;
> int main(void){
> register union32_t data;
> (...)
> send_char_uart(data.data32_3); /* mov r24,r21 ... */
> send_char_uart(data.data32_2); /* mov r24,r20 ... */
> send_char_uart(data.data32_1); /* mov r24,r19 ... */
> send_char_uart(data.data32_0); /* mov r24,r18 ... */
> }
--
Microsoft -- because god hates us
avr-gcc-list at http://avr1.org
- [avr-gcc-list] Unnecessary mov to temp register in inline funct.,
Christian Vogel <=