Fox-0
Instruction Set
The instruction set is divided up into four main classes of instructions. Register numbers are in 4-bit chunks (even though only the least 3 bits have physical registers available for use).
00 [opcode] [reg1] [reg2]
The instruction for passing data through the ALU. Reg2 is overwritten with the result. Below is a list of all accepted opcodes:
0000 - NOP
0001 - NOR
0010 - SUB
0011 - DEC
0100 - ADD
0101 - SHR (by one)
0110 - XOR
0111 - NAND
1000 - AND
1001 - XNOR
1010 - ADC (always with CF = 1)
1011 - NEG
1100 - INC
1101 - SAR (by one)
1110 - OR
1111 - NOT
11 [reg] [immediate]
Immediates an 8-bit value into the given register.
10 [condition] [target location]
Moves the instruction pointer to the given 8-bit target location if the condition is satisfied. It is strongly recommended to leave three NOP operations after any jump instruction unless you know what you're doing.
0001 - JZ
1001 - JNZ
0010 - JS
1010 - JNS
0100 - JC
1100 - JNC
Notice that the three least significant bits correspond to flags and the leading bit acts as negation. When multiple flags are selected, only one condition needs to be satisfied to jump.
01 0000 [reg1] [reg2] - MOV
01 1111 0000 0000 - HLT
Example Programs
A copy of the ROM used in the showcase is available on ORE (mc.openredstone.org). Collatz starts at address 0x05 and Fibonacci starts at address 0x30. Address 0x01 is a jump that can take the IP directly to the start of Fibonacci with a change in repeater placement (the top repeater at the first ROM address).
Conclusion
This was a fun little project. The showcase was also the first time I actually really TRIED to edit something, and I think it came out alright. I learned a lot about computer logic and architecture during this, and of course got a lot better at redstone. I would recommend trying it if you're interested, because the initial intimidation everyone feels is honestly somewhat unfounded, so long as you continually try to improve. ^w^