Hi! When I try to compile the following code with avr-gcc for atmega2560 cpu: ------------------------------------------------ #include <stdint.h> uint64_t asmfoo(uint32_t x, uint32_t y); int main(void) { return (int)asmfoo(1234, 5678); } uint64_t asmfoo(uint32_t x, uint32_t y) { uint64_t z; asm volatile ( "nop \n\t" //I'm going to make use of fmul instructions here "nop \n\t" //which only accept r16-r23 registers "nop \n\t" : [Z]"=&r"(z) //"r" is any general register (r1-r32) : [X]"a"(x), [Y]"a"(y) //"a" is a simple upper register (r16-r23) ); return z; } ------------------------------------------------- I get the following error: $ avr-gcc-4.7.2 -c test.c test.c: In function 'asmfoo': test.c:13: error: can't find a register in class 'SIMPLE_LD_REGS' while reloading 'asm' test.c:13: error: 'asm' operand has impossible constraints I have tested it with 4.3.2 and 4.7.2 with different optimization levels. On the other hand, the following code DOES compile: ------------------------------------------------- #include <stdint.h> uint64_t asmfoo(uint64_t x, uint32_t y); int main(void) { return (int)asmfoo(1234, 5678); } uint64_t asmfoo(uint64_t x, uint32_t y) // <-note the uint64_t { uint64_t z; asm volatile ( "nop \n\t" "nop \n\t" "nop \n\t" : [Z]"=&r"(z) : [X]"a"(x) // <-note the absence of y ); return z; } -------------------------------------------------
Confirmed with 4.8 from 2013-03-01 for any optimization level for the following, smaller test case: void asmfoo (long x, long y) { asm volatile ("" :: "a"(x), "a"(y)); }