Sender: nate AT cartsys DOT com Message-ID: <359954C9.3B354F0@cartsys.com> Date: Tue, 30 Jun 1998 14:12:41 -0700 From: Nate Eldredge MIME-Version: 1.0 To: Arthur CC: DJGPP Mailing List Subject: Re: 64k demo References: <00ea01bda399$4f778a80$364e08c3 AT arthur> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Arthur wrote: > > >No! if you apply >> and << to an unsigned you get logical stuff. The > arithmetic > >is used only for signeds. > > Ahh, I see. Can you not do it "manually", though? You could probably do some fancy casting to do an arithmetic shift of an unsigned number, or vice versa. Something like: unsigned u; *((int *)&u) <<= 2; > Also, can you do a ROL/ROR > in C or do you have to use inline ASM? And what about "shift with carry?" There's no builtin rotate operator in C. You can, however, simulate it with some shifts: /* rotate n right by b bits, assuming a 32-bit word */ n = (n >> b) | (n << (32 - b)); For the case of `b' == constant, GCC on an x86 will actually optimize this into: rorl $b, n /* !!! */ Amazing. You can also simulate a shift with carry; this is left as an exercise for the reader. ;-) -- Nate Eldredge nate AT cartsys DOT com