Compare Packed

You might also like

Download as pps, pdf, or txt
Download as pps, pdf, or txt
You are on page 1of 1

CP(Compare Packed)

Any two packed-decimal numbers can be algebrically compared without changing either number.
This is accomplished by means of Compare packed(CP) instruction. The characrter comparision
has certain drawbacks that it can’t interpret the sign bit algebrically and do not account properly
for operand of unequal length.
The instruction CP D1(L1,B1) , D2(L2,B2)
sets the condition code as follows.
Condition Condition code
first no. = second no. 0
first no. < second no. 1
first no. > second no. 2 These two number
need not be equal.. As with other comparision conditional branch statement is used after this
instruction. Let’s see a example.

X Y
CP X(2) , Y(3) 012C 00345D
result is first no. is greater than second no. and the condition
code will set as 2. The CP instruction is useful when it is necessary to determine if a number is
zero prior to using it as a divisor.
Exit

You might also like