next up previous
Next: Shift Instructions Up: Registers and MAL Previous: Address Modes

Arithmetic and Logical Instructions

In MAL, the arithmetic and logical instructions use only register or immediate operands. All operands are words. The arithmetic operations perform 2's complement integer arithmetic. The logical operations are performed bitwise.

The general format of an arithmetic or logical instruction is:

displaymath186

where D is a general register where the result of the operation is placed, and tex2html_wrap_inline188 and tex2html_wrap_inline190 are general registers containing the operands. For example,

        add     $10, $8, $9

performs 2's complement addition on the contents of registers $8 and $9 and places the result in register $10.

The second source operand, tex2html_wrap_inline190 , may be a register or a constant. For example,

        or      $4, $8, 0xffff

zero-extends the mask 0xFFFF to 32 bits and ORs it with the contents of register $8, placing the result in register $4. This sets the least significant 16 bits of $4 to 1's and copies the remaining bits from $8 to $4 unchanged.

When tex2html_wrap_inline190 is a constant, and D and tex2html_wrap_inline188 are the same register, then tex2html_wrap_inline188 may be omitted. For example,

        add     $8, 1

is equivalent to:

        add     $8, $8, 1

The MAL arithmetic and logical instructions are shown below.

tabular95

Notes:

  1. D specifies a general register where the result of the operation is placed.
  2. tex2html_wrap_inline188 is a general register.
  3. tex2html_wrap_inline190 is either a general register or a constant.
  4. When tex2html_wrap_inline190 is a constant and tex2html_wrap_inline188 is omitted, tex2html_wrap_inline188 is the same as D.



CS301 Class Account
Thu Nov 21 23:32:28 AST 1996