Instruction Set
Here's my take on the instructions set that will control the 4-bit TTL CPU.
Since the instruction bus is only 4 bits wide there can only be a maximum of 16 instructions. Each 4-bit operator is paired with a 4-bit operand so each instruction will make up 8 bits in total. The operator will be interpretted by the control logic and the operand will be processed. The chart below describes the instruction set:
Instruction | OpCode | Summary | Description |
LOAD (Mem) | 0000 | Accum = mem[Operand]; | Load data to the accumulator from a value held in RAM with the address set by the operand. |
LOAD (Value) | 0001 | Accum = Operand; | Load the operand data to the accumulaor. |
ADD (Mem) | 0010 | Accum += mem[Operand]; | Add value held in memory to the accumuator |
ADD (Value) | 0011 | Accum += Operand; | Add operand to the accumuator |
SUB (Mem) | 0100 | Accum -= mem[Operand]; | Subtract value held in memory from the accumuator |
SUB (Value) | 0101 | Accum -= Operand; | Subtract operand from the accumuator |
STO (Mem) | 0110 | mem[mem[Operand]] = Accum; | Store accumulator's value to memory, address held in memory. |
STO (Value) | 0111 | mem[Operand] = Accum; | Store accumulator's value to memory, operand equals address. |
READ (Mem) | 1000 | Addr = mem[Operand]; | Read from address, address held in memory. |
READ (Value) | 1001 | Addr = Operand; | Read from address, operand equals address. |
JMPLOW (Mem) | 1010 | PC Low Addr = mem[Operand] | Jump the lower 4-bits of the Program Counter to an address held in memory. |
JMPLOW (Value) | 1011 | PC Low Addr = Operand | Jump the lower 4-bits of the Program Counter to an address held by the operand. |
JMPHIGH (Mem) | 1100 | PC High Addr = mem[Operand] | Jump the upper 4-bits of the Program Counter to an address held in memory. |
JMPHIGH (Value) | 1101 | PC High Addr = Operand | Jump the upper 4-bits of the Program Counter to an address held by the operand. |
JMPZERO (Mem) | 1110 | if(Accum == 0) { PC = mem[Operand]; } |
If accumulator equals zero, program counter address equals a value in program memory. |
JMPZERO (Value) | 1111 | if(Accum == 0) { PC = Operand; } |
If accumulator equals zero, program counter address equals the operand. |
* Since I've made my Address Bus 8-bits wide, I could really use 18 instructions in total. As it is I will have to make due with JMPZERO being confined to a 4-bit address space.