GATE / CS ARCHIVE

SIMILAR QUESTIONS / COMPUTER ORGANIZATION & ARCHITECTURE

Match effective-address modes to data uses

6 questions solved the same way, newest first. Back to Computer Organization & Architecture

How these are solved

Read the operand-address calculation or data access pattern and identify immediate, indirect, indexed/base-offset or auto-increment mode.

1 mark · MCQ
Report issue

Matching addressing modes to data

Instructions & Addressing Modes

Question 14, GATE 2026: Match P immediate, Q indirect, R base with index, S base with offset to 1 array element, 2 pointer, 3 record field, 4 constant. The choices give different permutations of these matches.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Givens and goal

Match P immediate, Q indirect, R base with index, S base with offset to 1 array element, 2 pointer, 3 record field, 4 constant. The choices give different permutations of these matches.

Approach

Write the effective operand or effective address for each addressing mode and identify the high-level data access it implements.

Step-by-step solution

1. Immediate addressing puts the operand value directly in the instruction, such as an encoded literal 7. It naturally represents a constant, so P→4.
2. Indirect addressing obtains an operand’s address through another location or register. A pointer holds an address and is dereferenced to find the actual data, so Q→2.
3. Base-plus-index addressing computes an address from an array base and an index-dependent displacement, conceptually base+i·element_size. Varying i chooses an array element, so R→1.
4. Base-plus-fixed-offset addressing selects a field at a fixed byte displacement from the start of a record, such as record_base+offset_of_field. Thus S→3.
5. The complete mapping is (P,Q,R,S)→(4,2,1,3), option B. The key distinction is a varying index for array positions versus a fixed layout displacement for a named record field; both may ultimately use addition in the hardware.

Original paper, page 11 · Answer key

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

1 mark · MCQ
Report issue

Base-plus-displacement addressing

Instructions & Addressing Modes

Question 21, GATE 2011: The instruction LW R1,20(R2) loads a 32-bit memory word into R1. Its effective address is 20 plus the contents of R2. Which listed addressing mode best describes the memory operand?

(A) Immediate addressing
(B) Register addressing
(C) Register indirect scaled addressing
(D) Base indexed addressing
Tap to enlarge
Your answer
Answer & solution

Official answer: D

The effective address is the content of R2 plus the displacement 20. The memory operand is neither the literal 20 nor a register value, and no scale factor is applied. Among the options this is called base indexed addressing, D; base-plus-displacement is a more precise description.

The operation can be written R1←Memory[R2+20]. Immediate addressing would use 20 itself as data; register addressing would take the operand directly from a register. Scaled indexing would multiply an index by an element size, which is absent here. Thus the listed base-indexed choice is the closest match. The memory word being 32 bits affects the load size, not the formula used to locate that word.

Original paper, page 5 · Answer key

2 marks · MCQ
Report issue

Natural addressing modes

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

2 marks · MCQ
Report issue

Matching addressing modes to uses

Instructions & Addressing Modes

Question 2.9, GATE 2001: Match indirect, indexed, and base-register addressing to passing an array as a parameter, implementing an array, and relocatable code. Option A pairs indirect with parameter passing, indexed with arrays, and base-register with relocation; the other choices permute these assignments.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step 1: Passing an array by address gives a pointer to its elements; indirect addressing accesses memory through that pointer, matching X with III.

Step 2: Indexed addressing combines an array base with an index/offset, matching Y with I. Base-register addressing expresses locations relative to a relocatable base; changing that base allows the same relative offsets to address relocated code/data, matching Z with II.

Together the matches are(X,III),(Y,I),(Z,II), A.

Original paper, page 5

1 mark · MCQ
Report issue

Addressing-mode applications

Instructions & Addressing Modes

Question 1.10, GATE 2000: Match X indirect,Y immediate,Z autodecrement addressing to 1 loops,2 pointers,3 constants. Options are permutations; C gives X2,Y3,Z1.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Indirect addressing follows a stored address, so it naturally implements pointer access: X→2. Immediate addressing embeds an operand value, so it is suited to constants: Y→3.

Step 2: Autodecrement combines a register decrement with addressing, useful when iterating backward through a sequence or maintaining a loop-related address: Z→1 among the supplied uses.

Therefore C. These are representative uses, not claims that each mode has only one application.

Original paper, page 2