>
> > Now, I don't see any problems with the test4() code, but I would like
> > to change the code to something like
> >
> > lui X,0x801c
> > ld a1,-19064(X)
>
> This is ok, you can use the same register as base and target.
>
> Ulf
>
Not okay. Here's the code again:
static __inline__ unsigned long
value_bit2(void *addr)
{
unsigned long *m = (unsigned long *) addr;
unsigned long temp;
__asm__ __volatile__(
".set\tnoreorder\n"
"ld\t%0, %2\n\t"
"#there may be more instructions here"
".set\treorder\n"
:"=&r" (temp), "=m" (*m)
:"m" (*m));
return temp;
}
By the output/input specs, I am explicitly saying to gcc: look, you
pick the register to hold the variable temp, but make sure you do not
use that same register to compute the address, or hold, any of the
input variables, because this is an "earlyclobber" register (the &
indicates that).
Obviously, gcc is not listening and has used a1 to hold temp, as well
as use it for address computation of the memory input.
Kanoj
|