Compiler Conventions
For convenience, the $SHORTDATA$ and $SHORTBSS$ subspaces can be used for small scalar variables. Most scalar variables are close enough to $GLOBAL$ so that the shorter form can be used. Arrays and large structures should be defined in $DATA$ and the long form used.
To access items in the $PRIVATE$ space (global data), the following does not work:
LDIL | L'var,%r1 | ;wrong |
LDW | R'var(%r1),%r3 | ;wrong |
This example assumes that the operating system always allocates data at the same virtual space offset 0x40000000.
Thread local storage (TLS) data is accessed relative to control register 27 (%cr27). The contents of %cr27 must first be moved to a general register by using the MFCTL instruction. A symbol, __tp, is defined, similar to $global$. The following code shows the loading of the TLS variable. Note the similarities between this example and the example “Global Symbol Usage” on page 49.
MFCTL | %cr27, &rx |
|
ADDIL | ;result in r1 | |
LDW |
|
Uninitialized areas in the data space can be requested with the .COMM (common) request. These requests are always made in the $BSS$ subspace in the $PRIVATE$ space. The $BSS$ subspace should not be used for any initialized data. Common requests are passed on to the linker, which matches up all requests with the same name and allocates a block of storage equal in size to the largest request. If, however, an exported data symbol is found with the same name, the linker treats the common requests as if they were imports.
HP FORTRAN
50 | Chapter 3 |