Similar questions 5 more →
Instructions & Addressing Modes
![Question 11, GATE 2017: C declaration: struct data { int marks[100]; char grade; int cnumber; }; struct data student; Register R1 holds the base address of student. How to access student.grade efficiently? A postincrement (R1)+; B predecrement −(R1); C register direct R1; D indexed X(R1), with signed 16-bit displacement X.](../../assets/questions/CS-2017-S1-Q21-1.webp)
Answer & solution
Official answer: D
1. A structure layout assigns each member a fixed byte offset from its base. The compiler determines grade’s offset after the marks array, accounting for the implementation’s layout rules.
2. R1 already contains the base. Computing effective address R1+X directly selects grade without traversing the array or modifying R1.
3. That is displacement/index addressing X(R1), D. Register direct accesses the register rather than the field; predecrement and postincrement unnecessarily change the base. No assumed int width is needed.