Re: performance

From: djrb (rafaelbinder_at_hotmail.com)
Date: 02/10/04


Date: 10 Feb 2004 12:57:59 -0800


"lallous" <lallous@lgwm.org> wrote in message news:<c0ar0p$14mjao$1@ID-161723.news.uni-berlin.de>...
> "Gregory Noulin" <gregory.noulin@inrialpes.fr> wrote in message
> news:c0aqbg$7nh$1@trompette.imag.fr...
> > I am looking for differences of cost of an equality test between 2
> > integers and a multiplication between 2 integers.
> >
> > Which operation is most costly : multiplication (*) or equality test (==)
>
> That depends on the CPU Arch. and the code produced by the compiler to do
> the comparison or multiplication.
>
> For example, on x86, the comparison might be like this:
>
> if (x == y)
>
> mov ax, x
> xor ax, y
> jz _yes_equal
>
> And multiplication:
>
> x * y
>
> mov bx, x
> mov ax, y
> mul bx
>
> So the answer relies on whether "xor" is executed faster than "mul"
> As I remember, yes , "xor" is faster.
>
> In most cases the comparison is faster than multiplication.

As far as I know, XOR takes only one clock on x86 compatibles (386 and
higher).
As to MUL, it takes much more clocks to complete (at least 2).

There is a good book on ASM at http://webster.cs.ucr.edu/AoA.html
Another source is at http://www.masm32.com/
MASM32 package contains a lot of help files where the timings of
various asm commands are specified, but, if I am not wrong, the
timings are specified only up to x386.

As for the latest P4 CPU(s), the best source is
http://www.intel.com/design/Pentium/manuals/

I hope this info will help :)



Relevant Pages

  • Re: Help on "Bus Error(coredump)"
    ... over the years might result in bus errors on architectures other than x86 ... I did plenty of x86 assembly, but this was real mode stuff so I could do ... mov ax, ... So is this only a protected mode ...
    (comp.unix.solaris)
  • Re: Signed fixed-point multiplication
    ... I'm not surprised you considered it a "mess" if you thought it was ... On an x86, as with recent ARMs, ... mov eax,; Load eax from address adr1 ...
    (comp.sys.acorn.programmer)
  • Re: NdisInterLockedIncrement/Decrement macros
    ... and MOV is not among them. ... It is not allowed because it is useless on x86, ... Also, reading a variable will always be atomic on all CPUs, even on ...
    (microsoft.public.development.device.drivers)
  • Re: help boot
    ... I Wrote in language machine => ... mov ah,a ... So you're using an x86 assembly language. ... Above looks like Omnimon command, ...
    (comp.sys.atari.8bit)