Mail Archives: djgpp/1997/05/13/18:27:28
Keith Hull wrote:
>
> Hi everyone,
>
> I would like some help with GCC and inline asm (i've looked at
> Brennan's Guide to Inline ASM - it seems to make sense ;) .... heres
> my problem..
>
> asm ("rorl _val, _num_of_rotates");
> asm ("roll _val, _num_of_rotates");
> asm ("sall _val, _num_of_rotates");
> asm ("sarl _val, _num_of_rotates");
> asm ("shll _val, _num_of_rotates");
> asm ("shrl _val, _num_of_rotates");
Two things: no such instruction (amout to rotate must be either %cl or a
const) and the operands are backwords anyway.
Try:
asm ("rorl %b1,%0":"g"(val):"c"(num_of_rotates))
This will produce something similare to:
movb _num_of_rotates,%cl
rorl %cl,_val
depending on where gcc stores val and num_of_rotates.
BTW, gcc will optimise val=(val>>8)|(val<<24) to rorl $8,_val (or more
likely replace _val with a register).
Bill
--
Leave others their otherness.
- Raw text -