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
1
2
3
4
5
6
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
GROUP−G
GROUP−G
GROUP−G
GROUP−G
GROUP−G
ZK−6050−GE
TABLE−A
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
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......