GateAI
Instruction Set and Addressing Modes

GATE CSE 2023 · Q41

MCQ2 marksMedium

Time

Consider the given C-code and its corresponding assembly code, with a few operands U1–U4 being unknown. Some useful information as well as the semantics of each unique assembly instruction is annotated as inline comments in the code. The memory is byte-addressable.

Which one of the following options is a CORRECT replacement for operands in the position (U1, U2, U3, U4)(\text{U1, U2, U3, U4}) in the above assembly code?

GATE CSE 2023 Q41 diagram

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: B) (3, 4, 4, L01)

Instruction Set and Addressing Modes

Let us analyze the C code and the assembly translation:

  1. Shift amount (U1\text{U1}):

    • In the C loop body, we compute a[i] = b[i] * 8.

    • Multiplying an integer by 88 (232^3) is equivalent to a logical left shift by 33 bits:

      r5←r5≪3r_5 \leftarrow r_5 \ll 3
    • Therefore, U1=3\text{U1} = 3.

  2. Pointer updates (U2\text{U2} and U3\text{U3}):

    • An int is given as 32-bit (which is 44 bytes).

    • Since the memory is byte-addressable, advancing to the next integer element in array a (pointed to by r3r_3) and array b (pointed to by r4r_4) requires incrementing the memory addresses by 44 bytes:

      r3←r3+4r_3 \leftarrow r_3 + 4
      r4←r4+4r_4 \leftarrow r_4 + 4
    • Therefore, U2=4\text{U2} = 4 and U3=4\text{U3} = 4.

  3. Jump target (U4\text{U4}):

    • At the end of each iteration, the loop must branch back to the loop condition check at label L01 (jeq r1, r2, end) to test if $i == 10$.

    • Therefore, U4=L01\text{U4} = \text{L01}.

Thus, the correct replacement is (U1, U2, U3, U4)=(3,4,4,L01)(\text{U1, U2, U3, U4}) = (3, 4, 4, \text{L01}), which corresponds to Option (B).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Instruction Set and Addressing Modes previous year question is Q41 of the GATE CSE 2023 paper. Find more GATE CSE PYQs on Instruction Set and Addressing Modes in Computer Organization and Architecture, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Instruction Set and Addressing Modes PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Instruction Set and Addressing Modes in GATE CSE

Instruction Set and Addressing Modes has 19 GATE CSE PYQs across 15 papers from 2011 to 2026. 3 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2023.

How GATE tests Instruction Set and Addressing Modes

More from GATE CSE 2023

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2023 · Q41 · MCQ

Consider the given C-code and its corresponding assembly code, with a few operands U1–U4 being unknown. Some useful information as well as the semantics of each unique assembly instruction is annotated as inline comments in the code. The memory is byte-addressable. Which one of the following options is a CORRECT replacement for operands in the position (U1, U2, U3, U4) in the above assembly code?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.