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:

displaymath3206

where D is a general register where the result of the operation is placed, and tex2html_wrap_inline3208 and tex2html_wrap_inline3210 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_inline3210 , 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_inline3210 is a constant, and D and tex2html_wrap_inline3208 are the same register, then tex2html_wrap_inline3208 may be omitted. For example,

        add     $8, 1

is equivalent to:

        add     $8, $8, 1

The MAL arithmetic and logical instructions are shown below.

tabular1437

Notes:

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



CS 301 Class Account
Mon Sep 13 11:15:41 ADT 1999