On Thu, 15 Feb 2007, Gilboa Davara wrote:
Small example.
About two years ago I go bored, and decided to implement binary trees in
(x86) Assembly.
The end result was between 2-10 times faster then GCC (-O2/-O3)
generated code. (Depending the size of the tree)
The main reason being the lack of a 3 way comparison in C.
(above/below/equal)
And assembly lacks it too. But in C you can get creative with compound
statements:
int x,y;
register int t;
(t = x - y) && (((t < 0) && below()) || above()) || equal();
which wastes 1 register variable. Still, there is no guarantee that this
generates faster code than an optimizing compiler (and gcc is not known
among the best optimizing compilers). Rewriting above using binary
operators and masks may be even faster.
Atomic code execution should not require assembly because segment
locking can be done using C (even if that C is inline assembly for
some applications).
Peter
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]