Spiros said:
Has anyone found that declaring variables register affected
speed of execution ? If yes on what hardware and around
which year ?
Definitely! Though it was years ago.
Specifically, the Tandy 16/6000 series running Xenix, and the original
IBM-PC running MS-DOS, back in the early-to-mid 1980's. Those were
the first two platforms I did any "real" C work on. There were other
early C compilers I used on numerous other Unix and Unix-like systems
which saw improvements as well.
Back then, optimizers were nowhere near as "smart" as they are nowadays,
and the compilers I used on those systems tended to allocate registers
(and the 8088 had very few to spare) to the first-declared variable.
For example, in the function:
int foo()
{
int a, b, c, d, e;
... code that uses 'e' a zillion times, but the rest rarely ...
return(0);
}
The compiler would likely allocate variables a and b to registers, and
e would be on the stack (please, let's not get into _that_ thread here),
despite the "obvious" speed improvements to be gained by having e in a
register instead.
However, I no longer even bother with "register". On the rare function
that really requires speed that I can't get from the optimizer, I drop
to assembly.
There were other "tricks" I learned way back then which are no longer
relevant as well. For example, rewriting a for-loop properly could
make a big improvement on 680x0-based systems, as the compiler would
then take advantage of the 680x0's "decrement and branch on non-zero"
instruction.
--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody |
www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net |
www.fptech.com | <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:
[email protected]>