inline assembly & r0 SOS

Jeremy Kerr jk at ozlabs.org
Wed Aug 6 10:41:50 EST 2008


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?

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.

Cheers,


Jeremy



More information about the Linuxppc-dev mailing list