2 using the volatile compiler directive, 3 aligning data for performance and compatibility – Compaq COBOL AAQ2G1FTK User Manual

Page 519

Advertising
background image

Managing Memory and Data Access

16.1 Managing Memory Granularity

19

if a1

not = 1

display "?1".

20

if a2

not = 2

display "?2".

21

if a3(1:1) not = "c" display "?3 ".

22

if a4

not = 4

display "?4".

23

if a5(2)

not = 5

display "?5".

24

stop run.

16.2 Using the VOLATILE Compiler Directive

VOLATILE directives offer flexibility and selectivity: they alter the current
storage of certain data items by specifying new storage information from within
the program source.

The SET VOLATILE directive enables you to direct that certain data items be
stored in memory, rather than in machine registers. This technique is useful for
declaring data that is to be accessed asynchronously. (Device driver applications
often use volatile data storage.)

The forms of the VOLATILE directives are as follows:

*DC SET VOLATILE
*DC SET NOVOLATILE
*DC END-SET VOLATILE

In your application you specify *DC SET VOLATILE to begin a range of data
declarations with this attribute set. You terminate the volatile attribute range
with the *DC END-SET VOLATILE (or *DC SET NOVOLATILE) directive.
Subsequent declarations will not be affected.

16.3 Aligning Data for Performance and Compatibility

Proper alignment is important for Compaq COBOL applications on both Tru64
UNIX and OpenVMS Alpha platforms. Manipulation of binary data (that is,
COMP, COMP-1, COMP-2, INDEX, and POINTER data items) is significantly
faster if alignment is on natural boundaries. A natural boundary is the smallest
boundary at which data can be aligned without crossing the next boundary for
that type. (For example, longword is the natural boundary for four-byte integers.)

Two forms of alignment are available in Compaq COBOL. The basic form of
alignment allows you to align only elementary data items without padding the
record structures and substructures within which they reside. The alternate
form, which is Alpha alignment and padding, aligns both the elementary data
items and the structures and substructures in which they are found. It also pads
out those structures and substructures to lengths which are multiples of their
alignments. This form of alignment and padding conforms to the Compaq Alpha
Calling Standards.

OpenVMS VAX compatible record layouts are available for compatibility with
applications running on OpenVMS VAX platforms, including Compaq COBOL for
OpenVMS VAX.

16.3.1 Data Boundaries

Natural alignment for binary data is detailed in Table 16–1. The boundaries
described in Table 16–1 are specified in the Compaq Alpha Calling Standards.
The table generally applies both to Tru64 UNIX and to OpenVMS Alpha, with
the exception that IEEE is the only floating point data type on the Tru64 UNIX
operating system.

Managing Memory and Data Access 16–3

Advertising