80 likes | 100 Views
The ZAP instruction in SS2 explicitly codes and adds packed fields. It can handle fields of different sizes and does not require the first field to contain packed data. ZAP is preferred over MVC for packed decimal fields. This instruction zeros the target field and then adds the source field.
E N D
ZAP • Instruction type: SS2 • Explicit Coding: D1(L1,B1),D2(L2,B2) • Example ZAP 3(4,5),8(9,7) • Example ZAP X(3),Y(4) • Example ZAP X,Y • Zeroes the target field and then adds the source field. Fields can have different sizes. • Use ZAP not MVC on packed decimal fields. • First field doesn’t have to contain packed data
What does it do? ZAP X,Y 00 12 3C Y X 00 00 00 12 3C CC = 2 =Positive PADDING 0’s
What does it do? ZAP X,Y 00 00 12 34 45 6C Y 45 6C CC = 3 = Overflow X Truncation
ZAP Assume: Y DC PL3’-123.45’ X DS PL5’-1’ You execute: ZAP X,Y X Before: Y Before: 000000001D 12345D X After:Y After: 000012345D 12345D
ZAP Assume: X DC PL3’40’ You execute: ZAP X,X BP THERE … THERE EQU * X Before: 00040C X After: 00040C
Programming Tips • Never use MVC to transfer packed data • The largest field that can be copied is 16 bytes • ZAP generates a data exception (SOC7) if the second operand isn’t packed. The first operand can contain anything – it get’s zeroed out
Try it in VisibleZ • Try the following programs: • zap.obj • zap1.obj • zap2.obj • zap3.obj • zap4.obj