This is a fully functional general purpose programmable computer created in minecraft purely using redstone.
The computer contains a 4bit program counter and 3 separate 8bit general purpose registers.
Register | size | usage |
---|---|---|
r0 | 8bits | Always set to 0. Writing to this register does nothing |
r1 | 8bits | An general purpose register |
r2 | 8bits | An general purpose register |
r3 | 8bits | An general purpose register |
Register | size | usage |
---|---|---|
pc | 4bits | The program counter. It can be updated via the JMP instruction. |
The ALU is extremely basic and can only perform addition and subtraction
The computer contains a single 8bit output port that can be written to using the DSP instruction
The instruction set is extremely simple and consists of four main instructions:
Instruction | opcode | Parameters | Usage |
---|---|---|---|
DSP | 00 | OPCODE: 2bits; RESERVED: 2bits; SRC: 2bits; RESERVED: 4bits | displays the contents of the register specified by SRC |
JZ | 01 | OPCODE: 2bits; SRC: 2bits; CONSTANT: 6bits | sets the program counter to CONSTANT if the register specified by SRC is 0 (Note: the program counter is only 4 bits wide and so the first 2bits of CONSTANT are ignored) |
SET | 10 | OPCODE: 2bits; DST: 2bits; CONSTANT: 6bits | sets the first 6 bits of the register specified by DST to CONSTANT |
ALU | 11 | OPCODE: 2bits; DST: 2bits; SRC1: 2bits; SRC2: 2bits; FUNC: 2bits | Performs the arithmetic operation specified by FUNC on SRC1 and SRC2 , storing the output in DST |
The ALU instruction has the following format:
2 bits | 2 bits | 2 bits | 2 bits | 2 bits | |
OPCODE | DST | SRC1 | SRC2 | FUNC |
The alu instruction format performs DST = SRC1 FUNC SRC2
where FUNC is some arithmetic instruction specified in the below table.
FUNC | OPERATION |
---|---|
00 | ADD |
01 | SUB |
10 | UNDEFINED |
11 | UNDEFINED |
The following program will output the numbers in the Fibonacci sequence until an integer overflow occurs at which point it will display the last 8bits of the rest of the Fibonacci numbers.
r1 = 0
r2 = 0
while (true)
r3 = r1
r1 = r2 + r3
r2 = r3
print(r1)
Binary | Assembly |
---|---|
10 01 000000 | SET r1 0 |
10 10 000000 | SET r2 0 |
loop_start: | |
11 11 01 00 00 | ADD r3 r1 r0 |
11 01 10 11 00 | ADD r1 r2 r3 |
11 10 11 00 00 | ADD r2 r3 r0 |
00 00 01 0000 | DSP r1 |
01 00 000011 | JZ r0 loop_start |
- Implement conditional jumps
jl
andjle
. This will require increasing the opcode width and instruction width by 1 - add multiple outputs. Use the first two RESERVED bits in the display instruction to specify which port to write to.