[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Compile problem...
From: |
Tvrtko A. Ursulin |
Subject: |
[avr-gcc-list] Compile problem... |
Date: |
Mon, 18 Nov 2002 17:28:47 +0100 |
User-agent: |
KMail/1.4.3 |
What could cause GCC 3.2 to compile this function:
uint8_t i2c_send_block(uint8_t address, uint8_t *buffer, uint8_t len)
{
uint8_t flags;
irq_save(flags);
if ( i2c_start_transmission(address) )
goto fail;
do
{
uint8_t val = *buffer;
if ( i2c_transmit(val) )
goto fail;
buffer++;
} while ( --len );
i2c_stop();
irq_restore(flags);
return I2C_NO_ERROR;
fail:
i2c_stop();
irq_restore(flags);
return I2C_ERROR;
}
Into this piece of code:
uint8_t i2c_send_block(uint8_t address, uint8_t *buffer, uint8_t len)
{
28e: 1f 93 push r17
290: 18 2f mov r17, r24
uint8_t flags;
irq_save(flags);
292: 8f b7 in r24, 0x3f ; 63
294: f8 94 cli
if ( i2c_start_transmission(address) )
296: 92 df rcall .-220 ; 0x1bc
298: 81 2f mov r24, r17
29a: a4 df rcall .-184 ; 0x1e4
29c: 99 27 eor r25, r25
goto fail;
do
{
uint8_t val = *buffer;
if ( i2c_transmit(val) )
goto fail;
buffer++;
} while ( --len );
i2c_stop();
irq_restore(flags);
return I2C_NO_ERROR;
fail:
i2c_stop();
irq_restore(flags);
return I2C_ERROR;
}
29e: 1f 91 pop r17
2a0: 08 95 ret
??? This is with -O2, but -O0 doesn't help. Just produces bigger&slower code,
the main loop is again forgotten.
Thanks!
avr-gcc-list at http://avr1.org
- [avr-gcc-list] Compile problem...,
Tvrtko A. Ursulin <=