GATE / CS ARCHIVE

GATE CSE 2005 / QUESTION 66

Natural addressing modes

Computer Organization & Architecture · Instructions & Addressing Modes · Full GATE CSE 2005 paper

GATE 2005, Q66 2 marks · MCQ
Report issue

Instructions & Addressing Modes

Question 66, GATE 2005: Match 1 A[I]=B[J]; 2 while(*A++); 3 int temp=*x; to (a)indirect,(b)indexed,(c)autoincrement addressing. A (1, c),(2, b),(3, a); B (1, a),(2, c),(3, b); C (1, b),(2, c),(3, a); D (1, b),(2, b),(3, c). GFG D begins (1, b); GateForum D begins (1, a).
Question 66, GATE 2005: Match 1 A[I]=B[J]; 2 while(*A++); 3 int temp=*x; to (a)indirect,(b)indexed,(c)autoincrement addressing. A (1, c),(2, b),(3, a); B (1, a),(2, c),(3, b); C (1, b),(2, c),(3, a); D (1, b),(2, b),(3, c). GFG D begins (1, b); GateForum D begins (1, a).
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Array indexing A[I]=B[J] naturally uses indexed addressing; walking a pointer with *A++ uses autoincrement; dereferencing *x uses indirect addressing. The matching is (1, b),(2, c),(3, a), option C.

Indexed addressing adds a scaled index to an array base, matching 1. Autoincrement supplies the current pointer address and advances the pointer, matching 2. Plain dereference uses an address stored in a register or variable without an index, matching 3. Thus the mapping is 1b2c3a. These are natural implementation correspondences, not claims that a compiler must choose exactly these machine instructions.

Original paper, page 8