Two Address Subtract (DEC)/OP=03

Format

OP AF BF A Syllable B Syllable

OP = 03

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 and difference fields. Address may be indexed, indirect or extended. The final address controller data type may be UN, SN or UA.

Function

The Two Address Subtract instruction subtracts the contents of one memory location A to the contents of a second memory location B and stores the difference in the second memory location B unless an overflow condition exists. 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 difference 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.08.

Examples

Example (1) Subtract two positive numbers

OP AF BF A Syllable B Syllable
03 03 03 A field SN B field SN
                    BEFORE         AFTER
  A FIELD            +014        unchanged
  B FIELD            +062           C048
  COMPARISON          nn            HIGH
  OVERFLOW            nn         unchanged

Example (2) Subtract two negative numbers

OP AF BF A Syllable B Syllable
03 03 03 A field SN B field SN
                    BEFORE         AFTER
  A FIELD           D035         unchanged
  B FIELD           D029           C006
  COMPARISON          nn           HIGH
  OVERFLOW            nn         unchanged

Example (3) Subtract Signed field from Unsigned field

OP AF BF A Syllable B Syllable
03 02 03 A field SN B field UN
                    BEFORE         AFTER
  A FIELD            D71         unchanged
  B FIELD            121            192
  COMPARISON          nn           HIGH
  OVERFLOW            nn         unchanged

Example (4) Subtract Unsigned field from Signed field

OP AF BF A Syllable B Syllable
03 03 03 A field UN B field SN
                    BEFORE         AFTER
  A FIELD            259         unchanged
  B FIELD           +138           D121
  COMPARISON          nn            LOW
  OVERFLOW            nn         unchanged

Example (5) Subtract Two Signed field , Overflow condition

OP AF BF A Syllable B Syllable
03 03 03 A field SN B field SN
                    BEFORE         AFTER
  A FIELD           D556         unchanged
  B FIELD           +942         unchanged
  COMPARISON          nn         unchanged
  OVERFLOW            nn            ON
instructions/dec.txt · Last modified: 2008/05/13 07:22 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki