Compaq AAQ2G1FTK Marine Radio User Manual


 
Managing Memory and Data Access
16.4 Using Alignment Directives, Qualiers, and Flags
Example 16–3 shows the differences in the actions of /NOALIGN, /ALIGN and
-align
, and /ALIGN=PADDING and
-align pad
on the internal alignments of
data fields within COBOL data structures in the OpenVMS Alpha and Tru64
UNIX environments.
The program fragment in Example 16–3 was extracted from a COBOL program
that was compiled three times on Compaq COBOL, using the following qualifiers
for each compilation:
1. /LIST/MAP=D—No alignment and no padding, as in Compaq COBOL for
OpenVMS VAX (see Example 16–4)
2. /ALIGN/LIST/MAP=D—Compaq COBOL V1.0-style field elementary
alignment, but no Alpha natural alignment and padding (see Example 16–5)
3. /ALIGN=PAD/LIST/MAP=D—Alpha natural alignment and padding (see
Example 16–6)
The excerpts of the Data Names in Declared Order from the listing maps show
the differences in vertical format in the Location and Byte columns. Note the
horizontal byte layouts to make it easier to read in that orientation.
Example 16–3 shows that /ALIGNMENT without PADDING will align internal
COMP fields in the record format on longword boundaries, but will not pad out
the lengths of substructures to be multiples of the alignments of the most strongly
aligned fields within them. Also, it does not pad the entire data structure.
Alternatively, /ALIGNMENT=PADDING pads internal sub-structures as well as
the entire record. The result is many more slack bytes in the record layout for
Example 16–6.
Example 163 Comparing /NOALIGN, /ALIGN and /ALIGN=PADDING
4 DATA DIVISION.
5 WORKING-STORAGE SECTION.
6
7 01 REC1.
8 02 FLD1.
9 03 FLD1-1 PIC S9(9) USAGE COMP.
10 03 FLD1-2 PIC S9(03)V9(04) USAGE DISPLAY.
11 02 FLD2 PIC X(005).
12 02 FLD3.
13 03 FLD3-1 PIC X.
14 03 FLD3-2 PIC S9(9) USAGE COMP.
15 03 FLD3-3 PIC S9(5) USAGE DISPLAY.
1610 Managing Memory and Data Access