(This is a follow-up from "Getting GCC to Optimize Builds Manually" )
I am trying to get GCC (3.3.6-m68hc1x-20060122) to generate bset
and bclr
build bset
using indexed addressing, but not one set of constraints that I use seems to work.
asm
:
#define bset(base, offset, mask) { \ volatile unsigned char *__base = base; \ const unsigned char __offset = offset; \ const char __mask = mask; \ asm volatile ("bset %0 %1" : "=o" (__base[__offset]) : "X" (__mask), "x" (__base)); }
C:
inline void spi_init() { bset(_io_ports, M6811_DDRD, 0x38); bset(_io_ports, M6811_PORTD, 0x20); bset(_io_ports, M6811_SPCR, (M6811_SPE | M6811_DWOM | M6811_MSTR)); }
Result of assembly code:
spi_init: ldx #_io_ports ; Begin inline assembler code #APP bset _io_ports+9 #56 bset _io_ports+8 #32 bset _io_ports+40 #112 ; End of inline assembler code #NO_APP rts
Now it is really very close. But, unfortunately, it is completely invalid . It should look like this:
spi_init: ldx #_io_ports ; Begin inline assembler code #APP bset 9,x #56 bset 8,x #32 bset 40,x #112 ; End of inline assembler code #NO_APP rts
What restrictions should I use to redirect GCC to this build code?
GCC 3.3.6 extended assembly documentation
GCC 3.3.6 Restrictions Documentation
source share