Well, that is more to the point that in some architectures (68000 in this example) allows you to store a pointer in a global register. For the most cases in a modern compiler, however, it just gives the compiler one less register to work with, and the compilers these days are pretty darn good at figuring out what to put in a register, and what to not put in a register.
On x86, this would almost certainly cause more problems than it solves as there are only a few (7 at the very most) freely usable registers in x86. Even if almost every line is accessing the global variable it's unlikely to give any enormous benefits then either, since the compiler will be able to load the global pointer at the beginning of the code and then operate on it from then on.
Compilers these days are pretty good at assigning registers the right way, and given a choice, I'd prefer to use the compiler to figure out which register to use when.
However, it does work to use global register variables in gcc:
Code:
#include <stdio.h>
register int x asm("ebx");
int main()
{
x = 7;
printf("x = %d\n", x);
return 0;
}
compiles OK with gcc-mingw 3.4.2, and studying the assembler code, it puts the value 7 in ebx, and pushes ebx to printf.
--
Mats