# Interdata Instruction SetArithmetic Types

## Instructions

Each instruction that the Interdata machine understands will be presented below. Where instructions may be of more than one type (e.g. RR, RX, RS), they will be grouped together. Note that some instructions are only valid on machines with appropriate options - this is especially true of the multiply/ divide and floating- point operations.

In general, instructions will be presented by their assembler mnemonics, followed by their class and hexidecimal operation code (opcode). Notes about each instruction's operational characteristics will be presented where appropriate and any effects upon the PSW or CC bits will be discussed.

This page describes the arithmetic instructions in the Interdata set. Other pages describe:

### Fixed Point Arithmetic Instructions

#### Add Halfword

```AH  R1, A(X2) - [RX] - 0x4A | (R1) <-- (R1) + [(X2) + A]
AHI R1, A(X2) - [RS] - 0xCA | (R1) <-- (R1) + (X2) + A
AHR R1, R2    - [RR] - 0x0A | (R1) <-- (R1) + (R2)
```

The Add Halfword instruction algebraically adds the two operands together to produce the sum of the two. All operands are signed 16 bit quantities.

Affected CC bits:

```	C V G L
-------
0 0 - Sum is zero
0 1 - Sum is Less than zero
1 0 - Sum is Greater than zero
1     - Result caused Overflow
1       - Result caused a Carry
```

Notes:

The Add Halfword Immediate instruction produces a result which consists of the algebraic sum of the contents of R1, X2, and the Address Field.

#### Add Halfword with Carry

```ACH  R1, A(X2) - [RX] - 0x4E | (R1) <-- (R1) + [(X2) + A] + C
ACHR R1, R2    - [RR] - 0x0E | (R1) <-- (R1) + (R2) + C
```

The Add Halfword with Carry instruction algebraically adds the two operands together to produce the sum of the two including the current status of the Carry bit. The two GPRs are 16 bit quantities; Carry is a single bit.

Affected CC bits:

```	C V G L
-------
0 0 - Sum is zero
0 1 - Sum is Less than zero
1 0 - Sum is Greater than zero
1     - Result caused Overflow
1       - Result caused a Carry
```

Notes:

The Add Halfword with Carry instruction is used in the implementation of multiple- precision arithmetic. The basic stategy is to add the lower- order operands then for each next- higher order set use the ACH instruction to include the carry out of the previous (lower- order) calculation.

#### Subtract Halfword

```SH  R1, A(X2) - [RX] - 0x4B | (R1) <-- (R1) - [(X2) + A]
SHI R1, A(X2) - [RS] - 0xCB | (R1) <-- (R1) - (X2) + A
SHR R1, R2    - [RR] - 0x0B | (R1) <-- (R1) - (R2)
```

The Subtract Halfword instruction algebraically subtracts the contents of the second operand from the first and places the result into the former.

Affected CC bits:

```	C V G L
-------
0 0 - Difference is zero
0 1 - Difference is Less than zero
1 0 - Difference is Greater than zero
1     - Result caused Overflow
1       - Result caused a Borrow
```

Notes:

The Subtract Halfword Immediate instruction produces a result which consists of the algebraic difference of the contents of R1 and the sum of X2 and the Address Field.

#### Subtract Halfword with Carry

```SCH  R1, A(X2) - [RX] - 0x4F | (R1) <-- (R1) - [(X2) + A] - C
SCHR R1, R2    - [RR] - 0x0F | (R1) <-- (R1) - (R2) - C
```

The Subtract Halfword with Carry instruction algebraically subtracts the contents of the second operand from the first, subtracts the value of the Carry bit from that, and then places the result into the former.

Affected CC bits:

```	C V G L
-------
0 0 - Difference is zero
0 1 - Difference is Less than zero
1 0 - Difference is Greater than zero
1     - Result caused Overflow
1       - Result caused a Borrow
```

Notes:

This instruction is used in multiple- precision arithmetic. For details, see the Add Halfword with Carry instruction.

#### Multiply Halfword

```MH  R1, A(X2) - [RX] - 0x4C | (R1, R1+1) <-- (R1+1) * [(X2) + A]
MHR R1, R2    - [RR] - 0x0C | (R1, R1+1) <-- (R1+1) * (R2)
```

The Multiply Halfword instruction multiplies the signed value in (R1 + 1) by the quantity in the second operand. The high- order 15 bits (plus sign) of the result are stored in R1; the low- order 16 bits are placed into (R1 + 1). The second operand is unchanged during the operation.

Affected CC bits:

```	None.
```

Notes:

General Purpose Register (GPR) R1 must be an even- numbered register during this operation.

This instruction is optional on early- model Interdata machines.

#### Divide Halfword

```DH  R1, A(X2) - [RX] - 0x4D | (R1+1) <-- (R1, R1+1) / [(X2) + A]; (R1) <-- Remainder
DHR R1, R2    - [RR] - 0x0D | (R1+1) <-- (R1, R1+1) / (R2); (R1) <-- Remainder
```

Execution of the Divide Halfword instruction causes the quotient of the 32- bit dividend in R1 and R1+1 and the 16- bit divisor in the second operand to be placed into R1+1. R1 receives the remainder of the division.

Affected CC bits:

```	None.
```

Notes:

The first operand (R1) must be an even- numbered register.

This instruction is optional on early- model Interdata machines.

### Floating Point Arithmetic Instructions

#### General notes on Interdata Floating Point Instructions

The Floating point instruction set was not avalilable on the early- model Interdata machines and may have been optional on later- model ones.

Interdata's Floating Point instructions operate on 32-bit quantities, of which 1 bit is taken up with sign information, 7 bits represent the exponent (in excess 64 notation), and 24 bits of mantissa (or fraction).

The Interdata Floating Point format does not use the IEEE standard in that numbers in the Interdata format are considered normalised if the high- order hexadecimal digit of the mantissa is non-zero. The exponent, in this format, increments or decrements in conjunction with 4-bit shifts in the mantissa.

That having been said, I must admit that I really don't have a detailed grasp of the intracies of floating- point maths on computers, never having needed to use the facility outside of high- level languages.

#### Floating Point Add

```AE  R1, A(X2) - [RX] - 0x6A | (R1) <-- (R1) + [(X2) + A]
AER R1, R2    - [RR] - 0x2A | (R1) <-- (R1) + (R2)
```

The Floating Point Add instruction adds the two operands together to produce the sum of the two. Operands are normalised before the addition, and are post- normalised following the addition.

Affected CC bits:

```	C V G L
-------
0 0 - Sum is zero
0 1 - Sum is Less than zero
1 0 - Sum is Greater than zero
1     - Exponent Overflow or Underflow
```

#### Floating Point Subtract

```SE  R1, A(X2) - [RX] - 0x6B | (R1) <-- (R1) - [(X2) + A]
SER R1, R2    - [RR] - 0x2B | (R1) <-- (R1) - (R2)
```

The Floating Point Subtract instruction subtracts the second operand from the first operand and stores the result in R1. Operands are normalised before the subtraction, and are post- normalised following the subtraction.

Affected CC bits:

```	C V G L
-------
0 0 - Difference is zero
0 1 - Difference is Less than zero
1 0 - Difference is Greater than zero
1     - Exponent Overflow or Underflow
```

#### Floating Point Multiply

```ME  R1, A(X2) - [RX] - 0x6C | (R1) <-- (R1) * [(X2) + A]
MER R1, R2    - [RR] - 0x2C | (R1) <-- (R1) * (R2)
```

The Floating Point Multiply instruction multiplies the first and second operands and stores the product in R1. Operands are normalised before the multiplication, and are post- normalised following it.

Affected CC bits:

```	C V G L
-------
0 0 - Product is zero
0 1 - Product is Less than zero
1 0 - Product is Greater than zero
1     - Exponent Overflow or Underflow
```

#### Floating Point Divide

```DE  R1, A(X2) - [RX] - 0x6D | (R1) <-- (R1) / [(X2) + A]
DER R1, R2    - [RR] - 0x2D | (R1) <-- (R1) / (R2)
```

The Floating Point Divide instruction divides the first by the second operand and stores the product in R1. Operands are normalised before the division, and are post- normalised following it.

Affected CC bits:

```	C V G L
-------
0 0 - Quotient is zero
0 1 - Quotient is Less than zero
1 0 - Quotient is Greater than zero
1     - Exponent Overflow or Underflow
```

This page described the arithmetic instructions in the Interdata set. Other pages describe:

[ Museum Lobby ] [ Museum Catalogue ] [ Carl's Homepage ]

Copyright © 1997 - 2003, Carl R. Friend. All rights reserved.
Webspace design by: Carbon & Silicon Alliance

Comments to: carl.friend@rcsri.org
Last Modified: Sat May 13 13:04:15 EDT 2000