
The Convert to Binary instruction takes packed decimal data and
converts it to 2’s complement integer
data. Operand 1 designates a register
where the result will be stored.
Operand 2 represents a doubleword storage area which contains a valid 8-byte
packed decimal integer.
CVB can convert any
signed packed decimal integer in the range -2,147,483,648 and
+2,147,483,647. If the doubleword
specified in Operand 2 contains an integer outside this range, the 32 rightmost
bits of the result are placed in the Operand 1 register and a
fixed-point-divide exception is recognized.
In the following example, a packed field of length 4 is
converted to binary.
ZAP DOUBWORD,XPACK MOVE PACKED NO TO DOUBLEWORD
CVB R5,DOUBWORD CHANGE IT TO BINARY
...
XPACK DC PL4’123’ X’0000123C’
DOUBWORD DS D
To convert XPACK to binary, we must first move it to a
doubleword as required by the CVB
instruction. At the end of the
conversion, R5 contains x’0000007B’ = 123.
The diagram below illustrates the relationship between CVB and other data conversion
instructions for some common data types.

Some Unrelated CVB Instructions
DOUBWORD DS
D
PKD1 DC PL5’19’
PKD2 DC P’1865’
PKD3 DC P’-1’
ZAP DOUBWORD,PKD1 MOVE PACKED NO. TO STAGING AREA
CVB R8,DOUBWORD R8 = X’00000013’ = 19
ZAP DOUBWORD,PKD2 MOVE PACKED NO. TO STAGING AREA
CVB R8,DOUBWORD R8 = X’00000749’ = 1865
ZAP DOUBWORD,PKD3 MOVE
PACKED NO. TO STAGING AREA
CVB R5,DOUBWORD R5 = X’FFFFFFFF’ = -1
ZAP DOUBWORD,=C’123’ DATA IS NOT PACKED
CVB R4,DOUBWORD ABEND - DATA MUST BE PACKED
ZAP DOUBWORD,=P’3,000,000,000’ DATA IS PACKED
CVB R4,DOUBWORD ABEND -
FIXED PT. DIVIDE EXCEPTION
DATA >
2,147,483,647