Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In the description of the Hack machine language in chapter 4, it is stated that in well-written programs a C-instruction that may cause a jump
In the description of the Hack machine language in chapter 4, it is stated that in well-written programs a C-instruction that may cause a jump should not contain a reference to M, and vice versa. Discuss why this should be avoided.
From The Elements of Computing Systems nand2tetris.org/chapters/chapter%2004.pdf
Page 69. Not sure what needs to be updated
69 Machine Language 2 | Effect No jump If out > 0 jump If 0111 0 jump If out 2 0 jump If out 0) null JGT 0 JGE JLT JLE JMP Figure 4.5 The jump field of the C-instruction. Out refers to the ALU output (resulting from the instruction's comp part), and jump implies "continue execution with the instruction addressed by the A register The last instruction (0;JMP) effects an unconditional jump. Since the C-instruction syntax requires that we always effect some computation, we instruct the ALU to compute 0 (an arbitrary choice), which is ignored. Conflicting Uses of the A Register As was just illustrated, the programmer can use the A register to select either a data memory location for a subsequent C-instruction involving M, or an instruction memory location for a subsequent C-instruction involving a jump. Thus, to prevent conflicting use of the A register, in well-written programs a C-instruction that may cause a jump (i.e., with some non-zero bits) should not contain a reference to M, and vice versa. 69 Machine Language 2 | Effect No jump If out > 0 jump If 0111 0 jump If out 2 0 jump If out 0) null JGT 0 JGE JLT JLE JMP Figure 4.5 The jump field of the C-instruction. Out refers to the ALU output (resulting from the instruction's comp part), and jump implies "continue execution with the instruction addressed by the A register The last instruction (0;JMP) effects an unconditional jump. Since the C-instruction syntax requires that we always effect some computation, we instruct the ALU to compute 0 (an arbitrary choice), which is ignored. Conflicting Uses of the A Register As was just illustrated, the programmer can use the A register to select either a data memory location for a subsequent C-instruction involving M, or an instruction memory location for a subsequent C-instruction involving a jump. Thus, to prevent conflicting use of the A register, in well-written programs a C-instruction that may cause a jump (i.e., with some non-zero bits) should not contain a reference to M, and vice versaStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started