Match each of the high level language statements given on the left hand side with the most natural addressing mode from those listed on the right hand side.
View worked solution
Answer: C
To find the most natural addressing mode for each high-level language statement, we analyze how each operation is translated into machine instructions:
-
Statement (1):
This statement accesses elements of arrays and using indices and . In assembly, the effective address of an array element is computed as . This is the definition of Indexed addressing.
-
Statement (2):
while (*A++);
This statement dereferences the pointer and then increments the pointer to point to the next memory location. This sequential access and update operation is directly supported by the Auto-increment addressing mode, where the register holding the address is automatically incremented after the memory access.
-
Statement (3):
int temp = *x;
Here, is a pointer variable that holds the address of the actual data. Accessing the value pointed to by (dereferencing) requires fetching the address from first and then accessing that address. This is Indirect addressing (specifically, register indirect if is in a register, or memory indirect if is in memory).
Thus, the correct matching is , which corresponds to Option C.
Free practice · Your answers on this page are not saved.
