GATE / CS ARCHIVE

GATE CSE 2017 SET 1 / QUESTION 11

GATE CSE 2017 Set 1 Q11

Computer Organization & Architecture · Instructions & Addressing Modes · Full GATE CSE 2017 Set 1 paper

GATE 2017 Set 1, Q11 1 mark · MCQ
Report issue

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.
Tap to enlarge
Your answer
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.

Original paper, page 6 · Answer key