| 1 |
*> { dg-do run } |
| 2 |
*> { dg-options "-dialect ibm" } |
| 3 |
*> { dg-output-file "group2/IBM_dialect_COMP_redefined_by_POINTER_as_64-bit.out" } |
| 4 |
|
| 5 |
identification division. |
| 6 |
program-id. prog. |
| 7 |
data division. |
| 8 |
working-storage section. |
| 9 |
*> This is a test of the "-dialect ibm" special interpretation of a common |
| 10 |
*> construction in IBM mainframe code. That machine is a 32-bit |
| 11 |
*> big-endian architecture. We are assuming a 64-bit little-endian |
| 12 |
*> x86_64 architecture. So, the COMP PIC S8(8) would usually be an 32-bit |
| 13 |
*> big-endian value. But "-dialect ibm" means that the following |
| 14 |
*> REDEFINES USAGE POINTER causes the prior "COMP" to actually be defined |
| 15 |
*> as a 64-bit little-endian binary value. |
| 16 |
77 pointer-value COMP PIC S9(8) VALUE ZERO. |
| 17 |
77 point-at REDEFINES pointer-value USAGE POINTER. |
| 18 |
procedure division. |
| 19 |
*> The following value is 0x123456789 |
| 20 |
move 4886718345 to pointer-value |
| 21 |
display point-at " should be 0x0000000123456789" |
| 22 |
set point-at down by 4886718345 |
| 23 |
display point-at " should be 0x0000000000000000" |
| 24 |
set point-at down by 4886718345 |
| 25 |
display point-at " should be 0xfffffffedcba9877" |
| 26 |
set point-at up by 4886718345 |
| 27 |
display point-at " should be 0x0000000000000000" |
| 28 |
subtract 1 from pointer-value |
| 29 |
display point-at " should be 0xffffffffffffffff" |
| 30 |
add 1 to pointer-value |
| 31 |
display point-at " should be 0x0000000000000000" |
| 32 |
goback. |
| 33 |
end program prog. |
| 34 |
|