Exercise 3: Choosing the Right Addressing Mode for a Runtime Array Index — Possible Solution ==================================================================== THE SCENARIO ------------------------------ The array's starting address is already sitting in R3 at runtime, and we need to read its 4th element, where the exact index isn't known until the program actually runs. THE RIGHT MODE: BASE+OFFSET (INDEXED) ------------------------------ LDR R1, R3, #3 ; address = (value in R3) + 3 Base+offset is built exactly for this situation: it computes an effective address as a chosen register's current value plus a small offset. R3 already holds the array's base address, and #3 selects the 4th element (0-indexed), matching the chapter's own description of base+offset as "the mode that makes arrays and data structures practical." WHY THE OTHER THREE MODES FAIL HERE ------------------------------ - Immediate: has no addressing step at all -- it embeds a VALUE directly in the instruction, not an address to look up. It can't express "go read whatever is at this computed location" at all. - PC-relative: computes its address relative to the PC -- a fixed point tied to where the INSTRUCTION lives in the program, not to wherever the array happens to sit in memory. It has no way to incorporate a runtime value like the one sitting in R3. - Indirect: also computes its pointer address relative to the PC (PC + offset), then follows a pointer stored in memory at that fixed location. Like PC-relative, it has no mechanism to combine with a register's current runtime value the way base+offset does -- it would require the array's address to already be stored at some fixed, predetermined memory location, not held dynamically in R3. WHY THIS WORKS AS AN ANSWER ------------------------------ It picks base+offset using the chapter's own description of its purpose, gives the exact instruction with the correct register and offset, and explains specifically why each of the other three modes lacks a mechanism to incorporate a value that's only known at runtime and held in a register -- not just a generic "they don't fit."