COBOL Manual for TNS and TNS/R Programs

Data Fundamentals
HP COBOL Manual for TNS and TNS/R Programs522555-006
4-16
Implicit FILLER Bytes
To improve the alignment of its subordinate items, a level-01 (record) or level-77 data
item is aligned on a 2-byte boundary.
For TNS processes, a word is 2 bytes (16 bits), so a data item that is aligned on a word
boundary is aligned on a byte position that is divisible by 2. For TNS/R processes, a
word is 4 bytes (32 bits), so a data item that is aligned on a word boundary is aligned
on a byte position that is divisible by 4.
The compiler aligns a data item according to its size if one of these conditions is true:
The data item is described as USAGE BINARY or USAGE COMPUTATIONAL and
the PORT directive is not specified.
The data item is described as USAGE NATIVE-n.
The data item is described with a SYNCHRONIZED clause.
A data item that is aligned according to its size is usually aligned on a character
position that is divisible by 2. This is not a TNS/R word size, but this alignment
preserves data compatibility.
If the PORT directive is specified, BINARY/COMPUTATIONAL data items are not
aligned on byte boundaries, and program execution can be much slower. The PORT
directive does not affect NATIVE-n data items; they are always aligned on byte
boundaries.
If the PORT directive is not specified, then a data item is aligned on a 2-byte boundary
unless it is described with the SYNCHRONIZED clause. If it is described with the
SYNCHRONIZED clause, it is aligned on a 2-byte boundary if its size is less than 4
bytes, and on a 4-byte boundary if its size is 4 bytes or larger.
Within a data structure, the compiler might align BINARY/COMPUTATIONAL data
items by inserting implicit FILLER bytes.
More information:
Implicit FILLER Bytes
When an odd number of character positions precedes a 2-byte-aligned item within a
record, the compiler inserts FILLER bytes before the item, completing allocation of the
preceding 2 bytes.
When the number of character positions preceding a 4-byte-aligned item within a
record is not a multiple of 4, the compiler inserts the number of FILLER bytes needed
to complete allocation of the preceding 4 bytes.
Topics Sources
USAGE clause USAGE Clause
SYNCHRONIZED clause SYNCHRONIZED Clause
PORT directive PORT and NOPORT
Implicit filler bytes Implicit FILLER Bytes