I have a code for port bit-banging (all unnecessary is removed in debugging purposes)
#define NOP __asm__("nop\n")
while(count--) {
SPI_PORT->ODR |= SPI_CLK;
NOP;
SPI_PORT->ODR &= ~SPI_CLK;
NOP;
};
it's translated as
00101$:
ld a, xl
decw x
tnz a
jreq 00103$
; src/spi.c: 44: SPI_PORT->ODR |= SPI_CLK;
ld a, 0x500a
or a, #0x20
ld 0x500a, a
; src/spi.c: 45: NOP;
nop
; src/spi.c: 46: SPI_PORT->ODR &= ~SPI_CLK;
ld a, 0x500a
and a, #0xdf
ld 0x500a, a
; src/spi.c: 47: NOP;
nop
jra 00101$
when I remove NOP - all is translated as expected:
00101$:
ld a, xl
decw x
tnz a
jreq 00103$
; src/spi.c: 44: SPI_PORT->ODR |= SPI_CLK;
bset 0x500a, #5
; src/spi.c: 46: SPI_PORT->ODR &= ~SPI_CLK;
bres 0x500a, #5
jra 00101$
it seems like there's optimization bug...
Ticket moved from /p/sdcc/bugs/3736/
Can't be converted:
Suboptimal code generation is not a bug.