Reading position, not mastery.
Reading settings
Line spacing
Text width
Saved only in this browser. Theme and colors are in Appearance.
Explore, understand, practice

Answers to the machine-underneath exercises

Answers and reasoning

  1. add changes only t0. sd changes the memory value. Removing sd leaves a0 returning 12 while the object retains 5.

  2. After ld, t0=9 and memory=9; after add, t0=13 while memory=9; after sd, memory=13; after addi, a0=13; jalr returns to 0x1040. a0 remains address 0x4000 through the store.

  3. In the original example the store goes to address 12, or 0xc, no longer the object at 0x4000. Depending on mapping, alignment and permissions, access may fault or have another effect; the model does not justify a guaranteed crash. Keep the address location distinct from the data.

  4. A leaf calls no other function. With suitable register temporaries it can execute without a frame. Adding a nested call while needing the earlier return address and data introduces preservation requirements; the compiler chooses a solution according to needs and ABI. A function name alone is no evidence of a frame.

  5. Page number is 5, offset is 0xabc and frame base is 0x2000. The result is 0x2abc. Adding the entire virtual address to the frame base is wrong; transfer only the offset.

  6. In the first case the translation cache lacks an entry but mappings and permissions are valid; a page-table walk can repair the miss. In the second, the requested access is forbidden, and finding a physical address does not authorize it. Separate misses and faults using the data, translation and permission questions.

  7. No. Address spaces and mappings may differ. Equal numbers establish only equal virtual-address numbers. A sharing claim requires mapping and sharing information.

  8. No. Memory latency, dependencies, pipelining and implementation affect time. An architectural trace is not a performance measurement.

Fresh retrieval question

A virtual page moves to another frame while an address's offset remains unchanged. Is retaining the old TLB entry always harmless? No: stale translation may target the wrong frame or expired permissions. The appropriate update and invalidation protocol must be followed. Architecture and concurrency details belong to the memory lesson.

Return to the lesson. If address and value still blur together, redraw the C example with separate boxes for the pointer and its target before continuing.