www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/29/15:49:30

Message-Id: <m0yqjuJ-000S47C@inti.gov.ar>
Comments: Authenticated sender is <salvador AT natacha DOT inti DOT gov DOT ar>
From: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT gov DOT ar>
Organization: INTI
To: "Arthur" <arfa AT clara DOT net>, djgpp AT delorie DOT com
Date: Mon, 29 Jun 1998 16:54:24 +0000
MIME-Version: 1.0
Subject: Re: 64k demo
In-reply-to: <008b01bda38e$369d3d80$364e08c3@arthur>

"Arthur" <arfa AT clara DOT net> wrote:
> >In C you use << SHL and >> SHR
> 
> You don't seem to understand what I mean. There is a fundamental difference
> between arethmetic and logical shifting. Arethmetic shifting shifts the data
> (bytes, words or longs) but keeps the sign bit intact. Logical shifting
> treats the sign bit as any other bit in the byte/word/long.


SHR/SHL are logical shift
SAL/SAR are arithmetic (Shift Arithmetic Left)
 
> So for instance, aretmetically shifting left the value -2 would give the
> result -4; logically shifting left -2 would give 4.
> 
> Rolling takes any bits shifted off one end of the byte/word/long and sticks
> them on the other end.

ROR/ROL
 
> So rolling a byte right (logically) with the value of 1 would give the
> answer of 65664.
> 
> The shift commands which change different bits that I was referring to are
> commands like "shift with carry" and "shift with overflow."
> 
> AFAIK, you can only do arethmetic shifting in C, like I said.

No! if you apply >> and << to an unsigned you get logical stuff. The arithmetic 
is used only for signeds.

SET 
------------------------------------ 0 --------------------------------
Visit my home page: http://set-soft.home.ml.org/
or
http://www.geocities.com/SiliconValley/Vista/6552/
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org
ICQ: 2951574
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(541) 759 0013

- Raw text -


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