Shift right instructions

Implemented all the shift right instructions this evening, using a latch between MAR and the XY bus that just physically connects the bits shifted over by one. The code is pretty similar to the shift left code, except instead of running through the ALU in x+x mode, it runs through this new XY bus source latch. Shift right low 8 bits is pretty messy as it has to move data from the register, to MDR (to zero-extend it), to MAR (because that’s where the shift right latch is connected), then back via the same path when done. Thinking about it, I can probably simplify it a bit by not passing it through MDR on the way back, but either way there are probably more optimizations that can be done.

At one point during testing today I realized one of the instructions was only passing its unit tests by coincidence, the microcode never retrieved the value from the required register, it just happened that the correct value was in MDR which was then being used as a temporary register. Thinking about it a bit, I think I’m going to add an instruction to clear all internal registers (MAR, MDR, etc.), to be used in unit tests before critical instructions being tested. That should prevent this from happening again.

Next steps after implementing this clear instruction and simplifying the return path for the above will be to look at the swab instruction, since I’ve started to think about how to implement that when I was working on shifts. After that probably will look at sign extend, then maybe interrupts if I’m bored of instructions by then.