Date: Wed, 14 May 1997 10:24:33 +1200 From: Bill Currie Subject: Re: Bitwise ASM with DJGPP GCC To: Keith Hull Cc: djgpp AT delorie DOT com Reply-to: billc AT blackmagic DOT tait DOT co DOT nz Message-id: <3378EA21.774B@blackmagic.tait.co.nz> Organization: Tait Electronics NZ MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit References: <1997051321301977565 AT zetnet DOT co DOT uk> Precedence: bulk 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.