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:
where D is a general register where the result of the operation
is placed, and and
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, , 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 is a constant, and D and
are the same register,
then
may be omitted. For example,
add $8, 1
is equivalent to:
add $8, $8, 1
The MAL arithmetic and logical instructions are shown below.
Notes: