...In the Old Days, `register' was a hint that
the compiler should try to hold the variable in a CPU register
instead of in memory. ...
[Trivia][Folklore][Old-wife-tales]
Which reminded me of the following. (Can anybody confirm this? I can
not find the original reference.)
In the Old Days, there was an original C compiler for PDP-11 Unix.
I read that this compiler had a very simple approach for handling
register declarations. Three of the CPU registers were reserved for
this purpose. The first three variables declared as 'register' were
assigned to them in the order of declaration. Any more were ignored.
The contents of these registers was preserved across function calls,
making possible to use register declarations as an alternate parameter
passing mechanism without the overhead of pushing/popping data to the
stack, and it was inevitably used in this fashion by people wanting to
squeeze more performance from the system.
So for example, the following code snipped "should" work:
f1()
{
register a1, b1, c1;
a1 = 10;
b1 = 20;
c1 = a1 + b1;
f2();
}
f2()
{
register a2, b2, c2 ;
/* prints "10 + 20 = 30" */
printf("%d + %d = %d\n", a2, b2, c2);
}