I don’t know how CPUs work so I simulated one in code
by J. Clark Scott, a book which describes the bits of a simple 8-bit computer from the NAND gates, through to the registers, RAM, bits of the CPU, ALU and I/O, I got a hankering to implement it in code. The only thing that’s different about my computer is I upgraded it to 16-bit to have more memory to play with, as storing even just the glyphs for the ASCII table would have dwarfed most of the 8-bit machine described in the book, with not much room left for useful code. Well, until the book discussed the I/O features, with designs for a simple keyboard and display interface so you can get things in and out of the machine.
Source: djhworld.github.io