Re: Setting A in C-instruction

Posted by WBahn on
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/Setting-A-in-C-instruction-tp4036936p4036949.html

By "prior instruction", I meant the instruction that was EXECUTED before the current one, regardless of where it is in memory.

When the program first starts up, the situation is ambiguous. In the simulator, registers and RAM and other things can be initialized in a few different ways. I'm not sure how this simulator does it (or whether the various N2T simulators do it consistently). For well-written programs, it doesn't matter.

In the real world, most systems power up in a random state. The registers have random values and the RAM has random values. But there is almost always some king of power-on reset that forces certain things to happen so that well-written code can start up reliably.

In the Hack, the RESET input forces the PC to be zero and will hold it there regardless of anything else that happens until the RESET is released. So the instruction at ROM[0] will be executed over and over again during this period, but no jump can happen (because the PC is forced to be zero). Once RESET is released, the first instruction is executed again and now the PC can change under the control of the program.

I don't know what you are saying as for as first, and second and third instruction when you want to set the A-register to a constant value. This only involves a single instruction, such as

@42

I don't have time right now, but when I get a chance I'll put together a little timing diagram that I think is better than the one the author uses and will post that.