Compaq AAQ2G1FTK Marine Radio User Manual


 
Handling Tables
4.1 Defining Tables
Figure 4–6 shows how the table defined in Example 4–7 is mapped into
memory.
Example 4–7 Sample Record Description Defining a Table
01 TABLE-A.
03 GROUP-G PIC X(5) OCCURS 5 TIMES.
Figure 4–6 Memory Map for Example 4–7
123456
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2
1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
Level 03
Longword number
Byte number
Level 01
GROUPG GROUPG GROUPG GROUPG GROUPG
ZK6050GE
TABLEA
7
Alphanumeric data items require 1 byte of storage per character. Therefore, each
occurrence of GROUP-G occupies 5 bytes. The first byte of the first element is
automatically aligned at the left record boundary and the first 5 bytes occupy all
of word 1 and part of 2. A memory longword is composed of 4 bytes. Succeeding
occurrences of GROUP-G are assigned to the next 5 adjacent bytes so that
TABLE-A is composed of five 5-byte elements for a total of 25 bytes. Each table
element, after the first, is allowed to start in any byte of a word with no regard
for word boundaries.
4.1.4.1 Using the SYNCHRONIZED Clause
By default, the Compaq COBOL compiler tries to allocate a data item at the next
unassigned byte location. However, you can align some data items on a 2-, 4-, or
8-byte boundary by using the SYNCHRONIZED clause. The compiler may then
have to skip one or more bytes before assigning a location to the next data item.
The skipped bytes, called fill bytes, are gaps between one data item and the next.
The SYNCHRONIZED clause explicitly aligns COMP, COMP-1, COMP-2,
POINTER, and INDEX data items on their natural boundaries: one-word COMP
items on 2-byte boundaries, longword items on 4-byte boundaries, and quadword
items on 8-byte boundaries. Thus the use of SYNC can have a significant effect
on the amount of memory required to store tables containing COMP and COMP
SYNC data items.
Note
The examples in this section assume compilation without the
-align
flag
(on Tru64 UNIX systems) or the /ALIGNMENT qualifier (on OpenVMS
Alpha systems).
Handling Tables 4–7