Instruction Definition
The following notation is used:
-
$(location) means "the contents of
location."
-
@(location) means "the address stored
in location."
-
#(argument) means "the encoding of argument, " either a register
number (see table 1) or a function code.
-
# specifies one "don't care" bit, ## specifies two "don't care"
bits, and so on.
Add
add [Destination Register], [Operand Register 1], [Operand Register 2]
Result: $(Destination) = $(Operand 1) + $(Operand 2)
Encoding:0000 #(Operand 1) #(Operand 2) #(Destination)
Add Immediate
addi [Destination Register], [8-bit signed immediate data]
Result: $(Destination) = $(Destination) + (Immediate Data)
Encoding: 0001 (8-bit signed immediate data) #(Destination)
Subtract
sub [Destination Register], [Operand Register 1], [Operand Register 2]
Result: $(Destination) = $(Operand 1) - $(Operand 2)
Encoding: 0010 #(Operand 1) #(Operand 2) #(Destination)
Logic
logic [Logical Operator], [Destination Register], [Operand Register]
Result: $(at) = operator{$(Destination), $(Operand 2)} The operator is
specified by the following four-bit code:
- 0000 = bitwise AND
- 0001 = bitwise OR
- 0010 = bitwise NAND
- 0011 = bitwise NOR
- 0100 = bitwise XOR
- 0101 = bitwise XNOR
Other codes are reserved for future expansion.
Encoding: 0011 #(Logical Opcode) #(Operand 1) #(Destination)
Comparison
comp [Relational Operator], [Operand Register 1], [Operand Register 2]
Result: $(cond) = 01h, if the expression given by $(Operand 1) [Operator]
$(Operand 2)is true;
$(cond) = 00h, if it is false. The operator is specified by the following four-bit
code:
- 0000 = Greater than (>)
- 0001 = Less than (<)
- 0010 = Greater than or equal to (>=)
- 0011 = Less than or equal to (<=)
- 0100 = Equal to (==)
- 0101 = Not equal to (!=)
Result: Other codes are reserved for future expansion.
Encoding: 0100 #(Relational Opcode) #(Operand 2) #(Operand 1)
Unconditional Jump
ujmp [8-bit signed offset]
Result: $(Program Counter) =
$(Program Counter) + Offset + 1
Encoding:0101 (8-bit signed offset) ####
Conditional Jump
cjmp [8-bit signed offset]
Result: $(Program Counter) =
$(Program Counter) + Offset, if $(cond) == 01h. $(cond) = $00h
Encoding: 0110 (8-bit signed offset) ####
Load word
lw
Result: $(mdr) = ${@(mar)} That is, the contents of the data
memory at the (word) address stored in the (the least significant 12-bits of) mar
are copied to mdr.
Encoding: 0111 #(mar) #### #(mdr)
Store word
sw
Result: ${@(mar)} = $(mdr) That is, the contents of mdr are
copied to the data memory at the (word) address stored in (the least significant
9-bits of) mar.
Encoding: 1000 #(mar) #(mdr) ####
Rotate Left
rol [Destination Register]
Result: $(Destination) =
$(Destination) * 2 That is, the contents of the destination register are rotated
left the number of times indicated by immediate data.
Encoding: 1001 ######## #(Destination)
Call
call [12-bit function address]
Result: $(ra) = $(Program Counter) + 1
$(Program Counter) = 0000 $(12-bit address) That is, the address of the next
instruction is saved in ra, and the program counter is set to the 12-bit word
address in indicated by the address.
Encoding:1010 (12-bit function address)
Ret
ret
Result: $(Program Counter) = $(ra)
Encoding: 1011 #### #### ####
Halt
halt
Result: $(Program Counter) = $(Program Counter)-1 That is, the
program counter is decremented to point back to the address of the halt
instruction, and the CPU goes into an infinite "halt" loop.
Encoding: 1100 #### #### ####