www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/01/16:39:05

From: vcarlos35 AT juno DOT com
To: djgpp AT delorie DOT com
Date: Mon, 1 Feb 1999 16:33:51 EST
Subject: Re: can i do bit rotation in C?
Message-ID: <19990201.163628.5863.0.vcarlos35@juno.com>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 990201085736 DOT 27193F-100000 AT is>
X-Mailer: Juno 1.49
X-Juno-Line-Breaks: 0-11
Reply-To: djgpp AT delorie DOT com

> one thing i want to do is rotate a char value's bits, like
> the x86 assembly instruction ROR/ROL does.
> is this possible with an operator, or do i have to use inline
> assembly for that?
>

#define ROL(a,b) ((a) << (b) | (a) >> (8-(b)))
#define ROR(a,b) ((a) >> (b) | (a) << (8-(b)))

I'm almost certain that gcc is smart enough to generate the rotate
opcode for this.


___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019