delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/29/14:23:47

Message-ID: <3597DAD1.A64738EA@compmore.net>
Date: Mon, 29 Jun 1998 14:20:01 -0400
From: stdenis <stdenis AT compmore DOT net>
MIME-Version: 1.0
To: Arthur <arfa AT clara DOT net>
CC: DJGPP Mailing List <djgpp AT delorie DOT com>
Subject: Re: 64k demo
References: <000301bda384$5fe81de0$364e08c3 AT arthur>

> In almost any language, this is correct. It's faster to shift bits along a
> byte than it is to multply, carry, check for overflows etc. It's much faster
> to divide by using >> or SHR.

Well you mean for most cpus not languages.  In a  AMD 686 a multiply is almost
as fast a shift.  (well except it doesn't pair)

> I have noticed, though, that the PC only has one type of shifting command.
> On the Motorola, there's ASL, ASR (arethmetic), LSL and LSR (logical), along
> with the rolling commands ROL and ROR and all the shifting commands that
> change different bits depending on the values entered into them. Are there
> any of these on the PC?

You can shift (on a 286) a byte or word or dword (386) any value, not just one.
On a 8086 you must put the shift count in cl.... read a doc on 8086 for more.

> And while we're on the subject, I am assuming that << and >> are arethmetic
> shifting operands. Is there a similar command to do logical shifting in
> C/C++?

In C you use << SHL and >> SHR

Read a doc on 8086 to find out.

tom

- Raw text -


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