The AP instruction is an SS instruction that adds two packed decimal fields. The result of the addition is stored in the first operand. The two operands are added byte by byte, starting at the low-order byte.
Rules for the AP instruction:
Given the following definitions:
ONE DC PL3'11223' TWO DC PL3'1950' THREE DC P'256' FOUR DC C'999' FIVE DC C'123 ' SIX DS PL3 SEVEN DC PL2'-300'
Before | After | |||
---|---|---|---|---|
AP Instruction | Operand 1 | Operand 2 | Operand 1 | Operand 2 |
AP ONE,TWO | 11 22 3C | 01 95 0C | 13 17 3C | 01 95 0C |
AP ONE(3),THREE(2) | 11 22 3C | 25 6C | 11 47 9C | 25 6C |
AP ONE(3),THREE(1) | 11 22 3C | 25 | data exception, op2 invalid | |
AP THREE,TWO | 25 6C | 01 95 0C | 20 6C | 01 95 0C |
AP ONE,FOUR | 11 22 3C | F9 F9 F9 | data exception, op2 invalid | |
PACK SIX,FIVE AP SIX,TWO |
01 23 04 | 01 95 0C | data exception, op1 invalid | |
AP THREE,SEVEN | 25 6C | 30 0D | 04 4D | 30 0D |
AP THREE,=P'128' | 25 6C | 12 8C | 38 4C | 12 8C |
The SP instruction is an SS instruction that subtracts two packed decimal fields. The second operand is subtracted from the first operand, and the result of the subtraction is stored in the first operand, that is, op1 is set to the result of op1 - op2. When subtracting signed numbers, remember that the rules for subtraction can be summarized by "change the sign of the second operand, and then add."
Rules for the SP instruction:
Given the following definitions:
ONE DC PL3'12500' TWO DC PL3'1750' THREE DC P'-250' FOUR DC P'-1000'
Before | After | |||
---|---|---|---|---|
SP Instruction | Operand 1 | Operand 2 | Operand 1 | Operand 2 |
SP ONE,TWO | 12 50 0C | 01 75 0C | 10 75 0C | 01 75 0C |
SP TWO,THREE | 01 75 0C | 25 0D | 02 00 0C | 25 0D |
SP FOUR,TWO | 01 00 0D | 01 75 0C | 02 75 0D | 01 75 0C |
SP FOUR,THREE | 01 00 0D | 25 0D | 00 75 0D | 25 0D |
SP THREE,TWO | 25 0D | 01 75 0C | 00 0D | 01 75 0C |
SP ONE,=P'500' | 12 50 0C | 50 0C | 12 00 0C | 50 0C |
SP ONE(2),TWO | 12 50 | 01 75 0C | data exception, op1 invalid |
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2003