Assembly Language and the Instruction Set · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

Talking straight to the processor

Computing · Computer Systems · ages 16-18
Name ______________________   Date ____________
  1. What is a register in the lesson's processor model?

    • A named file kept on a storage drive
    • A small fast store inside the processor
    • A connection carrying printer commands
  2. In the lesson's model, R holds 6. Which instruction adds literal 2 to R?

    • ADD R,#2
    • MOV R,#2
    • ADD T,R
  3. One high-level statement can become several machine instructions.

    Circle one:   True   False

  4. In the lesson's model, T=6 and C=3. Run ADD T,C, then ADD C,#1. What is the new state?

    • T=10 and C=4
    • T=9 and C=4
    • T=9 and C=3
  5. In the lesson's model, what do CMP and BLT do in a counting loop?

    • CMP raises the counter; BLT copies it into the total.
    • CMP stores the total; BLT clears the counter to zero.
    • CMP sets a test flag; BLT jumps when it reports less.
  6. Use LOAD R,[a]; ADD R,#2; STORE [a],R for memory statement a = a + 2. Why does this model use three instructions?

    • It loads a value, adds to it, then stores the result.
    • It repeats the addition three times to detect errors.
    • It saves three copies of the program in one register.
  7. In the lesson's model, C=2. A trace runs CMP C,#3; BLT loop, but skips the flag. Which branch decision must the trace record?

    • CMP reports equal, so BLT must continue without jumping.
    • CMP reports greater, so BLT must continue without jumping.
    • CMP reports less, so BLT must jump to the loop label.
  8. Use the lesson's model. Start T=0, C=1. Loop: ADD T,C; ADD C,#1; CMP C,#5; BLT loop; HALT. Which branch change makes it total 1 through 5?

    • Use BLT loop, repeating only when C is below 5.
    • Use BLE loop, repeating when C is at most 5.
    • Use HALT, stopping before another value is added.
LightMySky · lightmysky.comW1-mt_bzmsfvdzwp-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

Talking straight to the processor W1-mt_bzmsfvdzwp-s1

  1. A small fast store inside the processor · A register is storage inside the processor. Instructions use the values it holds.
  2. ADD R,#2 · ADD R,#2 adds literal 2 to R, producing 8. MOV replaces a value, and ADD T,R changes T.
  3. True · A memory update can require a load, arithmetic and a store. This is possible, not compulsory for every statement.
  4. T=9 and C=4 · ADD T,C makes T=6+3=9. Then ADD C,#1 makes C=4 without changing T.
  5. CMP sets a test flag; BLT jumps when it reports less. · CMP compares without changing its operands. BLT uses the less flag to decide whether to jump.
  6. It loads a value, adds to it, then stores the result. · In this model, arithmetic uses a register. LOAD brings in a, ADD changes R, and STORE writes the result back to a.
  7. CMP reports less, so BLT must jump to the loop label. · 2 is less than 3, so CMP sets less. BLT must jump. The trace needs that flag to justify its next instruction.
  8. Use BLE loop, repeating when C is at most 5. · The original loop stops at C=5 with T=10. BLE includes the pass adding 5, then stops at C=6 with T=15.
Worksheet · LightMySky