An 8-bit computer simulator built in Unity that shows how components of a computer actually work.
Installation (for Unity Editor)
Clone or download the repository
Open UnityHub, click add, and select 8bitComputer-master
IN 0 // Read I/O Port 0, Store into Accumulator CMPB A, 0 // Compare Accumulator with 0 JZ 0 // If Equal, Jump to <0> else continue SBB A, 1 // Remove 1 from Accumulator JNZ 7 // If not zero, jump to <7> else continue LDB A, 14 // Define Accumulator value (0x0E) OUT 0 // Write Value from Accumulator into I/O Port 0 HLT // Halt CPU
This will wait for something to be Inputted (else than 0) If Inputed, With Loop X times (X == Input Value) and Output 0x0E
// OPCodes (Decimal) 00 NOP // NO OPERATION 01 LDB // LOAD REGISTER, BYTE 02 LDR // LOAD REGISTER, REGISTER 03 LDM // LOAD REGISTER, MEMORY 04 STB // STORE MEMORY, BYTE 05 STR // STORE MEMORY, REGISTER // for ADD & SUB i'm not really sure what we should use for name 06 ADB (or ADDB) // ADD REGISTRY, BYTE 07 ADR (or ADDR) // ADD REGISTRY, REGISTRY 08 ADM (or ADDM) // ADD REGISTRY, MEMORY 09 SBB (or SUBB) // SUB REGISTRY, BYTE 10 SBR (or SUBR) // SUB REGISTRY, REGISTRY 11 SBM (or SUBM) // SUB REGISTRY, MEMORY 12 CMPB // CMP REGISTRY, BYTE 13 CMPR // CMP REGISTRY, REGISTRY 14 CMPM // CMP REGISTRY, MEMORY 15 JMP // JMP BYTE 16 JC // JC BYTE 17 JNC // JNC BYTE 18 JZ // JZ BYTE 19 JNZ // JNZ BYTE 20 HLT // HALT CPU 21 IN // IN MEM (MEM == I/O Port Number, using Accumulator (gpr) for Interfacing) 22 OUT // OUT MEM (MEM == I/O Port Number, using Accumulator (gpr) for Interfacing)
I suggest having an understanding of how the individual components of a computer work. This should be used to aid that process or experiment with low level operations. Trying out some basic programs, having a large delay time, and checking each operation via the log will seriously help your understanding. Also, I suggest hovering over the components to see what is what and to get familiar with the scene.
Ben Eater is awesome. If you have any questions or confusions I strongly suggest watching his series on building an 8-bit computer. This is how I was able to implement the computer in Unity along with previous experience from school.
I also recommend seeing other projects like this one :
https://github.com/MichaelGaidas/Unity_8BitComputerSimulator/ Wich is really simple to understand and is a first step in understanding how computers work.