TAOCP 2.1 Exercise 7
The correct sequence to bring `NEXT(TOP)` into register A is sequence (a), `LDA TOP(NEXT)`.
Exercise 7. [04] In the text's example MIX program, (5), the link variable TOP is stored in the MIX computer word whose assembly language name is TOP. Given the field structure (1), which of the following sequences of code brings the quantity NEXT(TOP) into register A? Explain why the other sequence is incorrect.
a) LDA TOP(NEXT) b) LD1 TOP
LDA 0,1(NEXT)
Verified: no
Solve time: -
The correct sequence to bring NEXT(TOP) into register A is sequence (a), LDA TOP(NEXT). This works because TOP contains the full MIX word representing the link variable, and NEXT is a field specification that extracts the appropriate subword containing the link part of that word. By using TOP(NEXT), the instruction directly loads the link portion into A.
Sequence (b) fails because LD1 TOP loads the entire word of TOP into index register 1, and LDA 0,1(NEXT) interprets the contents of index register 1 as an address, not a word containing the link field. Consequently, it does not access the link portion of TOP itself, but rather a word at a memory location determined by TOP, which is not equivalent to NEXT(TOP). This difference in addressing explains why sequence (b) is incorrect.
$$ \boxed{\text{Correct sequence: LDA TOP(NEXT)}} $$