pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
A referral structure and the structure layout to which it refers can appear in different data blocks.
The structure layout must appear first.
In all other cases, a data declaration and any data to which it refers must appear in the same data
block. The following declarations, for example, must appear in the same data block:
INT var; ! Declare var
INT .ptr := @var; ! Declare ptr by referring to var
If the reference is not in the same block, the compiler issues an error message.
Allocating Global Data Blocks
When you compile a program, the compiler constructs relocatable blocks of code and data that
are linked into the object file. The compiler:
• Allocates each read-only array in its own data block in the code segment of the object file
• Allocates all other variables in relocatable global data blocks in the data segment (except
LITERALs and DEFINEs, which require no storage space)
Data is divided between “large” and “small” data sections.
The compiler associates the symbol information for the allocated variables with that data block.
The compiler also associates the symbol information for any LITERALs, DEFINEs, or read-only arrays
declared in that data block, but allocates 0 words of storage for such declarations.
Address Assignments
The compiler assigns each direct variable and each pointer an offset from the beginning of the
encompassing global data block. Within the data block, it allocates storage for each data
declaration according to its data type and size.
Sharing Global Data Blocks
Because the length of any shared data block must match in all compilation units, it is recommended
that you declare all shareable global data in one source file. You can then share that global data
block with other source files as follows:
1. In the source file that declares the data block, specify the SECTION directive at the beginning
of the data block to assign a section name to the data block. The SECTION directive remains
active until another SECTION directive or the end of the source file occurs:
NAME calc_unit;
?SECTION unblocked_globals ! Name first section
LITERAL true = -1, ! Implicit data block
false = 0;
STRING read_only_array = 'P' := [ " ","COBOL", "FORTRAN",
"PASCAL", "pTAL"];
?SECTION default ! Name second section
BLOCK default_vol; ! Declare named block
INT .vol_array [0:7],
.out_array [0:34];
END BLOCK;
?SECTION msglits ! Name third section
BLOCK msg_literals; ! Declare named block
LITERAL msg_eof = 0,
msg_open = 1,
msg_read = 2;
END BLOCK; ! End msglits section
?SECTION end_of_data_sections
2. In each source file that needs to include the sections, specify the file name and the section
names in a SOURCE directive:
Compiling With Global Data Blocks 365