Compaq AAQ2G1FTK Marine Radio User Manual


 
Handling Tables
4.1 Defining Tables
Example 4–8 describes a table containing a COMP SYNC data item. Figure 4–7
illustrates how it is mapped into memory.
Example 4–8 Record Description Containing a COMP SYNC Item
01 A-TABLE.
03 GROUP-G OCCURS 4 TIMES.
05 ITEM1 PIC X.
05 ITEM2 PIC S9(5) COMP SYNC.
Figure 4–7 Memory Map for Example 4–8
Level 03
Longword number
Byte number
Level 01
123
0 0 0 0 0 0 0 0 0 1 1 1
1 2 3 4 5 6 7 8 9 0 1 2
78
456
ATABLE
1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3
3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2
GROUPG GROUPG GROUPG GROUPG
Level 05
Legend: 1 = ITEM1
2 = ITEM2
ZK6044GE
1f f f 22221f f f22221f f f 22221f f f 2222
f = fill byte
Because a 5-digit COMP SYNC item requires one longword (or 4 bytes) of storage,
ITEM2 must start on a longword boundary. This requires the addition of 3
fill bytes after ITEM1, and each GROUP-G occupies 8 bytes. In Example 4–8,
A-TABLE requires 32 bytes to store four elements of 8 bytes each.
If, in the previous example, you define ITEM2 as a COMP data item of the same
size without the SYNC clause, the storage required will be considerably less.
Although ITEM2 will still require one longword of storage, it will be aligned on
a byte boundary. No fill bytes will be needed between ITEM1 and ITEM2, and
A-TABLE will require a total of 20 bytes.
If you now add a 3-byte alphanumeric item (ITEM3) to Example 4–8 and locate it
between ITEM1 and ITEM2 (see Example 4–9), the new item occupies the space
formerly occupied by the 3 fill bytes. This adds 3 data bytes without changing the
table size, as Figure 4–8 illustrates.
Example 4–9 Adding an Item Without Changing the Table Size
01 A-TABLE.
03 GROUP-G OCCURS 4 TIMES.
05 ITEM1 PIC X.
05 ITEM3 PIC XXX.
05 ITEM2 PIC 9(5) COMP SYNC.
4–8 Handling Tables