Re: Setting A in C-instruction
Posted by eatmorepies on
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/Setting-A-in-C-instruction-tp4036936p4036948.html
Okay. I think there was a misunderstanding in regards to the meaning of "prior instructions".
When you used that term, I had assumed that by "prior instruction", you simply meant, "the program instruction in the ROM that has the previous address from the one we are evaluating now". If that were the case, there would be no "prior instruction" if we were operating on the value at address 0 (assuming there were no jumps to that point). Reading your latest comment, I think you were referring more generally to any instruction that relates to the CPU.
So, suppose our first program instruction was to set the A-register to a constant value. The FIRST instruction would be to get the program counter value and send it to the ROM. The SECOND instruction would be to get the value at that supplied address from the ROM and output it to the CPU. Our THIRD instruction, which is based on the previous two instructions, is to use the Mux16 to send this constant value to the a-register, and the FOURTH instruction is to load it, based on the leftmost bit in our program instruction (which would be from the same program instruction as our third step).
If we were to use a C-instruction on the A-register, our FIRST and SECOND instructions would be the same. Our THIRD instruction would get the ALU output value that was inputted to the Mux16 and route it to the a register, and the FOURTH instruction would be to load that value into the a register, based on the destination bits in our program instruction.