Assigning registers to variables in inlines
Timothy J. Wood
tjw@omnigroup.com
Tue Jan 9 17:15:00 GMT 2001
I'm trying to emulate the Metrowerks __lwbrx PPC intrinsic (load word
byte reversed indexed), but not having any luck. The problem I run into
is that gcc decides to put the 'offset' into r0 and gas gives an error
on this saying that you should write '0' instead (presumably this is an
error designed to catch problems in human generated code since r0 means
'0' in this instruction instead of the actual value of r0).
So, I'd like some way to say "don't put offset in r0". Any other
register is OK. The following fails, though:
static inline unsigned int __lwbrx(register void *addr, register int
offset) {
register unsigned int word;
register unsigned int asm("r9") _offset = offset;
asm("lwbrx %0,%2,%1" : "=r" (word) : "r" (addr), "r" (_offset));
return word;
}
...: parse error before `asm'
...: `_offset' undeclared (first use in this function)
Is it possible to get this to work or should I look for a different
route? I could add addr and offset and always pass 0, but that would
introduce another instruction.
-tim
More information about the Gcc
mailing list