2 data field padding, 3 alignment directives, qualifiers, and flags – Compaq COBOL AAQ2G1FTK User Manual

Page 520

Advertising
background image

Managing Memory and Data Access
16.3 Aligning Data for Performance and Compatibility

Table 16–1 Boundaries for Naturally Aligned Binary Data

COBOL
USAGE

PICTURE
Declaration

OpenVMS Alpha
Standard Data Type

Natural
Alignment

Allocated
Storage

DISPLAY

PIC A
PIC X
PIC 9
PIC EDITED

8-bit character string

BYTE

1 byte

COMP

PIC [S]9(1-4)

16-bit word integer

WORD

2 bytes

PIC [S]9(5-9)

32-bit longword integer

LONGWORD

4 bytes

PIC [S]9(10-18)

64-bit quadword integer

QUADWORD

8 bytes

PIC [S]9(19-31)

128-bit octaword integer

QUADWORD

16 bytes

COMP-1

Not applicable

32-bit VAX F-floating

LONGWORD

4 bytes

32-bit IEEE S-floating

LONGWORD

4 bytes

COMP-2

Not applicable

64-bit VAX D-floating

QUADWORD

8 bytes

64-bit VAX G-floating

QUADWORD

8 bytes

64-bit IEEE T-floating

QUADWORD

8 bytes

INDEX

Not applicable

32-bit longword integer

LONGWORD

4 bytes

1

POINTER

Not applicable

32-bit longword integer

LONGWORD

4 bytes

2

1

On the OpenVMS Alpha system, USAGE IS INDEX is allocated as a longword integer for OpenVMS VAX compatibility.

On the Tru64 UNIX system, it is allocated as a 64-bit quadword integer, with 8 bytes of storage.

2

On the OpenVMS Alpha system, Compaq COBOL allocates 4 bytes for POINTER data to maintain Compaq COBOL

for OpenVMS VAX compatibility. On the Tru64 UNIX system, it allocates 8 bytes for POINTER data (a 64-bit quadword
integer).

16.3.2 Data Field Padding

In Compaq COBOL, all 01 and 77-level data items are always aligned on
quadword boundaries. With Alpha natural alignment and padding invoked, the
lengths of all data-items are compiled to be multiples of the greatest alignment of
any subordinate elementary field.

The compiler will flag (with an Informational diagnostic) all fields that might
incur side effects when compiled with alignment and padding enabled.

16.3.3 Alignment Directives, Qualifiers, and Flags

Within your program, you can specify alignment with the alignment directives,
which consist of structured comments embedded within the DATA DIVISION of
the program source.

The SYNCHRONIZED clause, which also aligns binary data on natural
boundaries, is included in both Compaq COBOL and Compaq COBOL for
OpenVMS VAX. See the Compaq COBOL Reference Manual for complete
information on the SYNCHRONIZED clause.

When you compile a COBOL program, you can use the /ALIGNMENT qualifier
or the /ALIGNMENT=PADDING qualifier on Windows NT and OpenVMS Alpha
systems and

-align

or

-align pad

on Tru64 UNIX systems to specify aligned

elementary data items or naturally aligned and padded record layouts for optimal
performance. If you do not specify this option, the default alignment is used,
which is OpenVMS VAX compatible record layouts for compatibility with Compaq
COBOL for OpenVMS VAX and other OpenVMS VAX languages.

16–4 Managing Memory and Data Access

Advertising