On Friday 15 July 2005 07:33, Torsten Mohr wrote: > Hi, > > i tried to write an inline asm function that gets two input parameters > in "Y" and "Z". These two pointers should point to two uint32_t > locations in RAM and the asm function should copy from Y to Z > and while copying change the endianness of the copied value: > > static __inline__ void store_be32_at32(uint32_t* dest, uint32_t* src) { > asm volatile ("\t" > "ld __tmp_reg__, Y+3\n\t" > "st Z+0, __tmp_reg__\n\t" > "ld __tmp_reg__, Y+2\n\t" > "st Z+1, __tmp_reg__\n\t" > "ld __tmp_reg__, Y+1\n\t" > "st Z+2, __tmp_reg__\n\t" > "ld __tmp_reg__, Y+0\n\t" > "st Z+3, __tmp_reg__\n\t" > > :: "z" (dest), "y" (src) > > ); > > When i use this, i get the error message: > > common_lib.h: In function `store_be32_at32': > common_lib.h:20: Fehler: in der Klasse »POINTER_Y_REGS« konnte \ > während des Neuladens von »asm« kein Register gefunden werden > > This roughly translates to: > In the class "POINTER_Y_REGS" no register could be found when > reloading >>asm<<. ...
The reason is 'Y' register: it is used as stack pointer. You may use such asm in small functions (without local variables in stack, and optimization must on). Or, better, rewrite without 'Y' usage, for example: static __inline__ void store_be32_at32(uint32_t* dest, uint32_t* src) { asm volatile ("\t" "ld __tmp_reg__, Z+3\n\t" "st X+, __tmp_reg__\n\t" "ld __tmp_reg__, Z+2\n\t" "st X+, __tmp_reg__\n\t" "ld __tmp_reg__, Z+1\n\t" "st X+, __tmp_reg__\n\t" "ld __tmp_reg__, Z+0\n\t" "st X+, __tmp_reg__\n\t" : "+x" (dest) : "z" (src) ); } Regards. _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list