by **Robert Sample** » Tue Aug 23, 2016 9:03 am

In hexadecimal, 192 is X'C0' and 240 is X'F0'. Since these values are adjacent in your memory locations, you have a half-word (16-bit) value of X'C0F0'. This represents X'C' (12) times 16^3, 0 times 16^2, X'F' (15) times 16^1, and 0 times 16^0, which in turn represents 12 times 4096 plus 15 times 16 or 49152 plus 240. Many programmers pair hexadecimal digits (there are 4 bytes -- 8 hexadecimal digits -- per word on the system z architecture) and thus 192 times 256 plus 240. X'12345678' represents one full word of memory (PIC S9(09) COMP-5 in COBOL) and has a value of 1 x 16^7 + 2 x 16^6 + 3 x 16^5 + 4 x 16^4 (etc.) -- which could also be represented as X'12' (18) x 256^3 + X'34' (52) X 256^2 + X'56' (86) X 256 + X'78' (120).

The COBOL REDEFINES is a redefining of memory locations (one byte at the minimum). This means the REDEFINES variables do not occupy more memory locations, they occupy the SAME memory locations as the REDEFINED variable. So if you change either variable, the other variable takes on the same value -- they are sharing the memory location, not each having its own as is the usual case.

- These users thanked the author Robert Sample for the post:
- ramkumar1992sp (Tue Aug 23, 2016 9:52 am)