Table of Contents

Three Address Subtract (SUB)/OP=04

Format

OP AF BF A Syllable B Syllable C Syllable

OP = 04

AF is the length of the A Syllable field. AF may be indirect or may indicate the A Syllable is a literal. A value of 00 is equal to a length of 100 units.
BF is the length of the B Syllable field. BF may be indirect. A value of 00 is equal to a length of 100 units.

The A Syllable is the address of the subtrahend field. Address may be indexed, indirect or extended. The final address controller data type may be UN, SN or UA.
The B Syllable is the address of the minuend field. Address may be indexed, indirect or extended. The final address controller data type may be UN, SN or UA.
The C Syllable is the address of the difference field. Address may be indexed, indirect or extended. The final address controller data type may be UN, SN or UA.

Function

The Three Address Subtract instruction subtracts the contents of one memory location A from the contents of a second memory location B and stores the difference in a third memory location C unless an overflow condition exists. The difference field length is equal to the larger of AF or BF.

If the number of significant digits in the result is greater than the difference field length, the difference field will be unchanged, the Comparison Flags will be unchanged and the Overflow Flag will be set.

Store the absolute value of the sum when the difference field data type is unsigned (UN or UA). Store the standard EBCDIC form of the result sign as the first digit of the result when the difference field data type is SN. Fill the zone digit with the EBCDIC numeric subset code (F) when the difference field data type is alphanumeric (UA).

The sign of a zero difference is always considered to be positive.

If subtrahend and minuend are of unequal lengths (AF not equal to BF), the shorter of the two is treated as if it has been left filled with zero's.

Only the numeric digits of an alphanumeric field enter into the operation. Unsigned (UN or UA) operands are assumed to be positive.

If the operand data contains undigits other than in the sign digit, cause an Invalid Arithmetic Data fault. See Compatibility Notes A.16.

Comparison Flags

In all cases except overflow, set the Comparison Flags to indicate whether the sum is greater than (HIGH), equal to (EQUAL) or less than (LOW) zero.

Overlap

A and B may totally overlap or may have matching type-address overlap (see 3.5.3). Partial overlap of A and B other than matching type-address overlap may produce incompatible results. See Compatibility Notes A.09.

Examples

Example (1) Subtract an Unsigned field from an Alpha field

OP AF BF A Syllable B Syllable C Syllable
04 01 05 A field UN B field UA C Field SN
                    BEFORE         AFTER
  A FIELD               5        unchanged
  B FIELD      C1C2C3C4C5        unchanged
  C FIELD          nnnnnn         C12340
  COMPARISON          nn            HIGH
  OVERFLOW            nn         unchanged