Exam-style question
Try this first
Write a mnemonic instruction sequence that loads the value at memory location 10, compares it with the immediate value 0, and branches to the label ZERO when the values are equal. If they are not equal, the sequence must store the immediate value 1 in memory location 20 and then halt. At ZERO, it must store the immediate value 0 in memory location 20 and then halt. Explain how the compare and conditional branch work.
Answer and explanation
Concise answer
One valid sequence is:
Why this is correct
The sequence uses compare followed by a conditional branch. The instruction immediately after the conditional branch is the not-equal path, while the label identifies the equal path. Direct addressing is used for memory locations 10 and 20, and immediate addressing is used for the constants 0 and 1.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
