Three Address Add (ADD)/OP=02

Format

OP AF BF A Syllable B Syllable C Syllable

OP = 02

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 addend 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 augend 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 sum field. Address may be indexed, indirect or extended. The final address controller data type may be UN, SN or UA.

Function

The Three Address Add instruction adds the contents of one memory location A to the contents of a second memory location B and stores the sum in a third memory location C unless an overflow condition exists. The sum field length is equal to the larger of the AF and BF values.

If the number of significant digits in the result is greater than the sum field length, the sum 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 sum 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 sum field data type is SN. Fill the zone digit with the EBCDIC numeric subset code (F) when the sum field data type is alphanumeric (UA).

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

If addend and augend 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) Add an Unsigned Field to a Signed Field giving a Signed Sum

OP AF BF A Syllable B Syllable C Syllable
02 02 05 A field UN B field SN C Field SN
                    BEFORE         AFTER
  A FIELD              20        unchanged
  B FIELD          +00015        unchanged
  C FIELD          nnnnnn         C00035
  COMPARISON          nn            HIGH
  OVERFLOW            nn         unchanged

Example (2) Add an Unsigned field to a Signed field giving an Unsigned Alpha Sum

OP AF BF A Syllable B Syllable C Syllable
02 02 05 A field UN B field SN C field UA
                    BEFORE         AFTER
  A FIELD             10         unchanged
  B FIELD         D00050         unchanged
  C FIELD     nnnnnnnnnn        F0F0F0F4F0
  COMPARISON          nn            LOW
  OVERFLOW            nn         unchanged

Example (3) Add an Alpha field to an Alpha field

OP AF BF A Syllable B Syllable C Syllable
02 02 02 A field UA B field UA C field UA
                    BEFORE         AFTER
  A FIELD           F4F0         unchanged
  B FIELD           C1C2         unchanged
  C FIELD           nnnn           F5F2
  COMPARISON          nn           HIGH
  OVERFLOW            nn         unchanged

Example (4) Add two fields with an Overflow condition

OP AF BF A Syllable B Syllable C Syllable
02 02 02 A field UN B field UN C field SN
                    BEFORE         AFTER
  A FIELD             61         unchanged
  B FIELD             53         unchanged
  C FIELD             nn         unchanged
  COMPARISON          nn         unchanged
  OVERFLOW            nn             ON
instructions/add.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