Currently, the CPU has an ALU, an accumulator, a program counter, 4 general purpose registers, and circuitry for reading from specific addresses in memory. The CPU lacks a flags register, though this will be added later. I've began work on the instruction decoding, and have managed to get a few instructions to work.
The ALU is identical to the one in the NAND Game, only instead of the default logic operation being NAND, it's OR. This means it can only add, OR, invert and/or zero A/B, and invert the output. The zeroing and inverting of the inputs and outputs does allow this ALU to do any necessary operation for basic programs. It does not yet support flags/comparisons.
The program counter, accumulator, and general purpose registers are all 8 bit. Maybe later I will make the program counter 16 bit, but for now it will remain at 8.
So far I've only had time to add 3 instructions.
0x00 - NOP 0x01 - LDA (Number) 0x02 - NOP ... 0xFE - NOP 0xFF - Halt
Each instruction is given 4 clock cycles to run. The first is used to load the opcode, and the others can be used to actually execute instructions. This does decrease the speed of the CPU by a bit, so I may make a way to skip the unused clock cycles later.
That's all for now, but I will be working on it as often as I can, so expect to see an update within a week.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.