Elementary pointers cannot be moved using the MOVE statement; a SET statement must be used; however, pointers are implicitly moved when they are part of a group item.
When compiling a MOVE statement, the ILE COBOL compiler generates code to maintain (a pointer MOVE) or not maintain (a non-pointer MOVE) pointers within a group item.
A pointer MOVE is done when all of the following conditions are met:
Of the conditions listed above, determining if two data items are properly aligned can be the most difficult.
Items must be on the same offset relative to a 16-byte boundary for a pointer MOVE to occur. (A warning is issued if this is not true.)
The following example shows three data structures, and the results when a MOVE statement is issued:
Figure 81. Using Pointers in a MOVE Statement
WORKING-STORAGE SECTION. 01 A. 05 B PIC X(10). 05 C. 10 D PIC X(6). 10 E POINTER. 01 A2. 05 B2 PIC X(6). 05 C2. 10 D2 PIC X(10). 10 E2 POINTER. 01 A3. 05 B3 PIC X(22). 05 C3. 10 D3 PIC X(10). 10 E3 POINTER. PROCEDURE DIVISION. MOVE A to A2. (1) MOVE A to A3. (1) MOVE C to C2. (2) MOVE C2 to C3. (3) |
If a group item contains a pointer, and the ILE COBOL compiler cannot determine the offset relative to a 16-byte boundary, the ILE COBOL compiler issues a warning message, and the pointer move is attempted. However, pointer integrity may not be maintained. The ILE COBOL compiler cannot determine the offset if the item is defined in the Linkage Section, or if the item is reference-modified with an unknown starting position. You must ensure that pointer alignment is maintained, or a machine check error may result.
The ILE COBOL compiler places all 01-level and 77-level items on a 16-byte boundary whether or not they contain pointers.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.