Opcodes For Instruction Decoder Assignment

The following is a break down of the opcodes of the simple machine for which you are designing an instruction decoder. It is important to note that when using the opcode for a 16-bit memory address, the byte immediately following the opcode is the most significant byte of the address and the byte following that is the least significant.

Mathematical Operations:

If the most significant bit is 0, then the opcode represents a mathematical function. The opcode may be followed by 0, 1, or 2 bytes of operand.

* -- The constant is passed to the processor as an 8-bit operand following the opcode
** -- The memory address is passed to the processor as a 16-bit operand following the opcode

Memory Operations:

If the most significant two bits are 10, then the opcode represents a memory operation. When the "Method" bit is equal to 00, the opcode is followed by a 16-bit operand that serves as the memory address. When the "Method" bit is equal to 01, the opcode is followed by an operand that serves as a constant (8 bits for A or B and 16 bits for X or D). Otherwise, the value contained in index register X is used as the memory address.

Branches/Jumps:

If the most significant three bits are 110, then the opcode represents an unconditional or conditional branch. The opcode is always followed by a 16-bit operand that serves as the memory address.

Special Opcodes:

If the most significant three bits are 111, then the opcode represents a special operation not included in the list above. None of the special opcodes require operands. They are either implied by the operation or not required.

List of Opcodes and Their Function:

The following table (which is poorly formatted because I exported it from Excel) contains a list of the opcodes that you will see for this processor. If you see any errors or have any questions, e-mail me at tarnoffetsu.edu.

Opcode
Destination
Source
Function
Note
Opcode
Operand length
Name
Prefix
Function
Name
Code
Name
Code
ADD
0
000
A
00
Indexed
00
A=A+[X]
Uses pointer X as memory address for source 
00000000
0 bytes
ADD
0
000
A
00
B
01
A=A+B
 
00000001
0 bytes
ADD
0
000
A
00
Constant
10
A=A+Const
Constant is an 8-bit value
00000010
1 byte
ADD
0
000
A
00
Memory
11
A=A+Mem
 
00000011
2 bytes
ADD
0
000
B
01
Indexed
00
B=B+[X]
Uses pointer X as memory address for source 
00000100
0 bytes
ADD
0
000
B
01
Constant
10
B=B+Const
Constant is an 8-bit value
00000110
1 byte
ADD
0
000
B
01
Memory
11
B=B+Mem
 
00000111
2 bytes

SUB

0
001
A
00
Indexed
00
A=A-[X]
Uses pointer X as memory address for source 
00010000
0 bytes
SUB
0
001
A
00
B
01
A=A-B
 
00010001
0 bytes
SUB
0
001
A
00
Constant
10
A=A-Const
Constant is an 8-bit value
00010010
1 byte
SUB
0
001
A
00
Memory
11
A=A-Mem
 
00010011
2 bytes
SUB
0
001
B
01
Indexed
00
B=B-[X]
Uses pointer X as memory address for source 
00010100
0 bytes
SUB
0
001
B
01
Constant
10
B=B-Const
Constant is an 8-bit value
00010110
1 byte
SUB
0
001
B
01
Memory
11
B=B-Mem
 
00010111
2 bytes
MULT
111
00000
 
 
 
 
D=A*B
Destination and source are implied
11100000
0 bytes
DIV
111
01000
 
 
 
 
B=B/A
Destination and source are implied
11101000
0 bytes
INC
0
101
A
00
 
 
A=A+1
 
01010000
0 bytes
INC
0
101
B
01
 
 
B=B+1
 
01010100
0 bytes
INC
0
101
D
11
 
 
D=D+1
 
01011100
0 bytes
INC
0
101
X
10
 
 
X=X+1
 
01011000
0 bytes
DEC
0
110
A
00
 
 
A=A-1
 
01100000
0 bytes
DEC
0
110
B
01
 
 
B=B-1
 
01100100
0 bytes
DEC
0
110
D
11
 
 
D=D-1
 
01101100
0 bytes
DEC
0
110
X
10
 
 
X=X-1
 
01101000
0 bytes
AND
0
010
A
00
Indexed
00
A=A&[X]
Uses pointer X as memory address for source 
00100000
0 bytes
AND
0
010
A
00
B
01
A=A&B
Bitwise operation
00100001
0 bytes
AND
0
010
A
00
Constant
10
A=A&Const
Bitwise operation
00100010
1 byte
AND
0
010
A
00
Memory
11
A=A&Mem
Bitwise operation
00100011
2 bytes
AND
0
010
B
01
Indexed
00
B=B&[X]
Uses pointer X as memory address for source 
00100100
0 bytes
AND
0
010
B
01
Constant
10
B=B&Const
Bitwise operation
00100110
1 byte
AND
0
010
B
01
Memory
11
B=B&Mem
Bitwise operation
00100111
2 bytes
OR
0
011
A
00
Indexed
00
A=A|[X]
Uses pointer X as memory address for source 
00110000
0 bytes
OR
0
011
A
00
B
01
A=A|B
Bitwise operation
00110001
0 bytes
OR
0
011
A
00
Constant
10
A=A|Const
Bitwise operation
00110010
1 byte
OR
0
011
A
00
Memory
11
A=A|Mem
Bitwise operation
00110011
2 bytes
OR
0
011
B
01
Indexed
00
B=B|[X]
Uses pointer X as memory address for source 
00110100
0 bytes
OR
0
011
B
01
Constant
10
B=B|Const
Bitwise operation
00110110
1 byte
OR
0
011
B
01
Memory
11
B=B|Mem
Bitwise operation
00110111
2 bytes
XOR
0
100
A
00
Indexed
00

A=A^[X]

Uses pointer X as memory address for source 
01000000
0 bytes
XOR
0
100
A
00
B
01
A=A^B
Bitwise operation
01000001
0 bytes
XOR
0
100
A
00
Constant
10
A=A^Const
Bitwise operation
01000010
1 byte
XOR
0
100
A
00
Memory
11
A=A^Mem
Bitwise operation
01000011
2 bytes
XOR
0
100
B
01
Indexed
00
B=B^[X]
Uses pointer X as memory address for source 

0100

0100

0 bytes
XOR
0
100
B
01
Constant
10
B=B^Const
Bitwise operation
01000110
1 byte
XOR
0
100
B
01
Memory
11
B=B^Mem
Bitwise operation
01000111
2 bytes
NOT
0
111
A
00
 
 
A=!A
Bitwise operation
01110000
0 bytes
NOT
0
111
B
01
 
 
B=!B
Bitwise operation
01110100
0 bytes
STOR
10
0
A
00
 
0
A->Mem
Always uses 16-bit memory address
10000000
2 bytes
STOR
10
0
B
01
 
0
B->Mem
Always uses 16-bit memory address
10001000
2 bytes
STOR
10
0
D
11
 
0
D->Mem
Always uses 16-bit memory address
10011000
2 bytes
STOR
10
0
X
10
 
0
X->Mem
Always uses 16-bit memory address
10010000
2 bytes
STOR
10
0
A
00

Indexed 

1
A->[X]
Uses value contained in X as memory address
10000100
0 bytes
STOR
10
0
B
01
Indexed 
1
B->[X]
Uses value contained in X as memory address
10001100
0 bytes
STOR
10
0
D
11
Indexed
1
D->[X]
Uses value contained in X as memory address
10011100
0 bytes
STOR
10
0
X
10
Indexed 
1
X->[X]
Uses value contained in X as memory address
10010100
0 bytes
RETR
10
1
A
00
 
00
A<-Mem
Always uses 16-bit memory address
10100000
2 bytes
RETR
10
1
B
01
 
00
B<-Mem
Always uses 16-bit memory address
10101000
2 bytes
RETR
10
1
D
11
 
00
D<-Mem
Always uses 16-bit memory address
10111000
2 bytes
RETR
10
1
X
10
 
00
X<-Mem
Always uses 16-bit memory address
10110000
2 bytes
RETR
10
1
A
00
Constant 
01
A<-Const
Opcode serves as a 1 byte constant
10100010
1 byte
RETR
10
1
B
01
Constant 
01
B<-Const
Opcode serves as a 1 byte constant
10101010
1 byte
RETR
10
1
D
11
Constant 
01
D<-Const
Opcode serves as a 2 byte constant
10111010
2 bytes
RETR
10
1
X
10
Constant 
01
X<-Const
Opcode serves as a 2 byte constant
10110010
2 bytes
RETR
10
1
A
00
Indexed 
10
A<-[X]
Uses value contained in X as memory address
10100100
0 bytes
RETR
10
1
B
01
Indexed 
10
B<-[X]
Uses value contained in X as memory address
10101100
0 bytes
RETR
10
1
D
11
Indexed 
10
D<-[X]
Uses value contained in X as memory address
10111100
0 bytes
RETR
10
1
X
10
Indexed 
10
X<-[X]
Uses value contained in X as memory address
10110100
0 bytes
XAB
111
10000
 
 
 
 
Exchange A and B
Destination and source are implied
11110000
0 bytes
BRA
110
0000
 
 
 
 
IP<-Mem
Always uses 16-bit memory address
11000000
2 bytes
BAZ
110
0001
 
 
 
 
IP<-Mem if A=0
Always uses 16-bit memory address
11000010
2 bytes
BAN
110
0010
 
 
 
 
IP<-Mem if A!=0
Always uses 16-bit memory address
11000100
2 bytes
BAL
110
0011
 
 
 
 
IP<-Mem if A<0
Always uses 16-bit memory address
11000110
2 bytes
BAG
110
0100
 
 
 
 
IP<-Mem if A>0
Always uses 16-bit memory address
11001000
2 bytes
BBZ
110
0101
 
 
 
 
IP<-Mem if B=0
Always uses 16-bit memory address
11001010
2 bytes
BBN
110
0110
 
 
 
 
IP<-Mem if B!=0
Always uses 16-bit memory address
11001100
2 bytes
BBL
110
0111
 
 
 
 
IP<-Mem if B<0
Always uses 16-bit memory address
11001110
2 bytes
BBG
110
1000
 
 
 
 
IP<-Mem if B>0
Always uses 16-bit memory address
11010000
2 bytes
NOP
111
11000
 
 
 
 
No operation
 
11111000
0 bytes
HALT
111
11111
 
 
 
 
Halt processor
 
11111111
0 bytes