Sets the condition code: - High – result > 0 Test with BP, BNP
- Low – result < 0 Test with BM, BNM
- Equal – result = 0 Test with BZ, BNZ
X DS PL8 Y DC PL4’123’ ZAP X,Y AP X,X SP X,=P’1’ ZAP X,X BP THERE
Packed Arithmetic - MP SS2 – Multiply packed Op1 – Target Field (max 16 bytes) Op2 – Source Field (max 8 bytes) The target contains the product of multiplying Op1 by Op2 Does not set the condition code Op1 contains the multiplicand (before) and then the product (after) Op2 contains the multiplier The number of leading bytes of zeros in op1 before multiplying must be >= no of bytes in op2
Packed Arithmetic X DS PL8 Y DC PL4’20’ Z DC PL4’30 ZAP X,Y MP X,Z ZAP X,=PL5’123456789’ MP X,Y PROBLEM
Packed Arithmetic - DP SS2 – Divide packed Op1 – Target Field (max 16 bytes) Dividend/Quotient/Remainder Op2 – Source Field (max 8 bytes) Divisor The target initially contains the dividend After dividing, target contains quotient and remainder Remainder size = divisor size Quotient size = Target field size – Remainder size Does not set the condition code The number of leading bytes of zeros in op1 before dividing must be >= no of bytes in op2
Packed Arithmetic X DS PL8 COMPUTE 125/30 Y DC PL5’125’ Z DC PL3’30 ZAP X,Y DP X,Z X Before divide: 000000000000125C X After divide: 000000004C00005C Quotient Remainder
Packed Arithmetic - CP SS2 – Compare packed Op1 – Target Field (max 16 bytes) Op2 – Source Field (max 16 bytes) Sets the condition code to indicate how Op1 compares with Op2 Numbers are compared arithmetically (not a character compare) Fields can be different sizes
Packed Arithmetic X DC PL8’-30’ Y DC PL5’125’ Z DC PL3’30’ CP X,Y CC = LOW CP Y,X CC = HIGH CP Y,=P’125’ CC = EQUAL CP Z,=X’030F’ CC = EQUAL
SS – Shift and Round Packed Used to shift packed fields to the left or right in order to compute decimal precision Op1 – Target Field (max 16 bytes) Op2 – A shift factor - Positive shift factor 1-31 – left shift
- Negative shift factor in 2’s complement – right shift
- Express negative shift factor as 64 – n for n digit shift right
Op3 – Rounding factor – (0-9) Don’t shift a significant digit off the left
Packed Arithmetic X DC P’-98765’ Y DC PL5’98765’ SRP X,64-3,5 X = 00099D SRP Y,3,0 X = 098765000C SRP Y,64-1,0 X = 000009876C SRP X,1,0 ERROR
Shift Computations X DS PL4 2 DECIMALS Y DS PL4 3 DECIMALS WORK DS PL10 Compute X + Y to 2 decimals rounded AP WORK,Y SRP WORK,64-1,5
Shift Computations X DS PL4 2 DECIMALS Y DS PL4 3 DECIMALS WORK DS PL10 Compute X / Y to 2 decimals rounded 9999v999 99999v990000 ZAP WORK,X SRP WORK,4,0 DP WORK,Y SRP QUOT,64-1,5
Shift Computations X DS PL4 4 DECIMALS WORK DS PL8 COUNT DS P’9’ Compute X10 TO 4 decimals rounded ZAP WORK,X LOOP EQU * MP WORK,X SRP WORK,64-4,5 BNZ LOOP
Converting from Packed to Numeric Edited Data Packed instruction - ED SS2 Edit Pattern describes the output - X’40’ blank, fill pattern
- X’20’ digit selector
- X’21’ digit selector and significance starter
- X’6B’ comma
- X’4B’ decimal point
Edit Patterns An edit pattern is defined in hex and is called the edit “word”
Dostları ilə paylaş:
|