inline assembly & r0 SOS

Kevin Diggs kevdig at hypersurf.com
Wed Aug 6 12:31:43 EST 2008


Jeremy Kerr wrote:
> Hi Kevin,
> 
> 
>>         /*
>>          * Turn r3 (range) into a rotate count for the selected
>>range. * 0 -> 23, 1 -> 31
>>          */
>>         __asm__ __volatile__ (  "slwi %0,%0,3\n"
>>                                 "addi %0,%0,23\n"
>>                                 "rlwnm %0,%1,%0,30,31\n":
>>                 "=r"(ret):
>>                 "r"(config),"0"(range)
>>         );
> 
> 
> Wouldn't this be much simpler in plain C?
> 
I just knew someone was gonna try to rain on my rlwnm'in fun parade! 
Wonder if the C code can be made to compile down to 3 instructions?

> However, if you really do need to do this in inline asm, you can use 
> the "b" modifier rather than "r" to avoid using r0.
> 
Oh cool! Thanks! You to Ben!

> Cheers,
> 
> 
> Jeremy
> 

kevin



More information about the Linuxppc-dev mailing list