> it's because MUL operations are among the slowest on the
> x86.  while SHL/SHR bitwise operations are among the
> fastest.  so you'd rather want to use SHL instead of the
> MUL to do Nx2 equations your PC during those times
> including writing to video memory.

yes i know, it just an example if your compiler is not smart unlike borland
compilers, it will automatically converted that into SHL/SHR as long as the
multiplier/divisor is power of 2. but if it is not power of 2 then it will
going to use the MUL operand. but the bottom line is, you outsmart what the
compiler can produce thus produces you an astonishing and remarkable speed .
i cant blame those compilers because its a general purpose compiler!

fooler.

>
> pong
>
> --- fooler <[EMAIL PROTECTED]> wrote:
> > with this and using a high level language, the compiler
> > will going to use
> > MUL assembly code which will consume you 85 clock ticks!
> > multiply by 2
> > (because of x * 2) is already 170 clock ticks! aside from
> > adding the MOV and
> > ADD clock ticks.
> >
> > while using your own code like this
> >
> > mov ax, Y
> > mov cx, 6
> > shl ax, cx      <---   Y * 32
> > mov bx, ax
> > shl ax, 1        <-\
> > shl ax, 1         <-\-- Y * 128
> > add bx, ax      BX = (Y * 32 + Y * 128) =  Y * (32 + 128)
> > = Y * 160


_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]

To subscribe to the Linux Newbies' List: send "subscribe" in the body to 
[EMAIL PROTECTED]

Reply via email to