6.43.5.1. Defining Global Register Variables
6.43.5.1 Defining Global Register Variables
You can define a global register variable in GNU C like this:
register int *foo asm ("a5");
Here a5
is the name of the register that should be used. Choose a register that is normally saved and restored by function calls on your machine, so that library routines will not clobber it.
Naturally the register name is CPU-dependent, so you need to conditionalize your program according to CPU type. The register a5
is a good choice on a 68000 for a variable of pointer type. On machines with register windows, be sure to choose a “global” register that is not affected magically by the function call mechanism.
In addition, different operating systems on the same CPU may differ in how they name the registers; then you need additional conditionals. For example, some 68000 operating systems call this re