You are on page 1of 8

PACK

PACK
• Instruction type: SS2
• Explicit Coding: D1(L1,B1),D2(L2,B2)
– Example PACK 3(4,5),8(9,7)
– Example PACK X(3),Y(4)
• Use: Converts zoned decimal fields to packed,
(also works on character fields that only
contain digits)
What does it do?
PACK X,Y

Y F1 F2 F3 F4 F5 C6

X 00 00 01 23 45 6C
What does it do?
PACK X,Y

Y F1 F2 F3 F4 F5 C6

X 45 6C
PACK
• Example use:
Assume:
X DS PL5
Y DC Z’-234.57’
You execute:
PACK X,Y
Y Before:
F2F3F4F5D7
X After:
000023457D
PACK
• Example use:
Assume:
X DS PL2 (TOO SHORT)
Y DC Z’-234.57’
You execute:
PACK X,Y
Y Before:
F2F3F4F5D7
X After:
457D DIGITS TRUNCATED
Programming Tips
• Make sure the receiving field will hold the
result
• Pack works no matter the state of the data. In
other words, if you pack garbage, you get more
garbage
• Pack doesn’t generate a data exception (SOC7)
• You won’t discover the data is bad until you do
arithmetic – AP, SP, MP, …
Try it in VisibleZ
• Try the following programs:
– pack.obj
– pack1.obj
– pack2.obj
– pack3.obj
– pack4.obj

You might also like