Mail Archives: djgpp/1998/06/29/14:23:47
> 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 -