High yield ●●●

🧩 Instruction Formats & Addressing Modes

Why it matters: Most predictable topic. Nearly every paper has an EA / operand-value or instruction-format question.

Subtopics

Each subtopic has its own page: idea, why, how, example, play, check. Mark each one understood when it clicks. 0 of 8 done.

Formulas

Memory refs per mode
Immediate 0 · Register 0 · Direct 1 · Reg-indirect 1 · Indirect 2 (to get the operand)
Instruction length
L = opcode + (#operands × field width) [+ mode bits]
Expanding opcode (2-addr → 1-addr → 0-addr)
1-addr max = (2^opbits − x)·2^a · 0-addr max = ((2^opbits − x)·2^a − y)·2^a (x = #2-addr, y = #1-addr, a = address-field bits, opbits = L − 2a)
Registers addressable
k register-field bits → 2^k registers
Address bits
Memory of 2^n words → n address bits; addressable range = 2^n × word size

What GATE asks from this

Question types seen repeatedly in past papers. More stars means more frequent.

★★★
EA / operand value for a given mode
Given register & memory contents and instruction fields (indexed, base, relative, indirect), compute EA or final operand. Trap: relative uses updated PC; auto-increment gives EA before increment.
★★★
Expanding opcode: max number of instructions
'16-bit instr, 4-bit regs; 15 two-addr instrs exist, how many one-addr / zero-addr can be encoded?' Use the formula, subtract used patterns at each level.
★★★
Instruction size / memory needed
Compute instruction length from #opcodes, #registers, immediate size; then program size or PC increment.
★★★
Stack machine / postfix code
Count PUSH/POP or evaluate expression on a stack machine; min registers needed.
★★★
Concept one-liners
Which mode suits array access / relocation / pointer; RISC vs CISC statements; endianness; why immediate is fastest.

Ratings are approximate, based on recurring patterns in past GATE CSE papers.

Previous year questions

12 real questions from the official GATE CSE papers (2014 to 2025), newest first, each with the official answer key and a worked solution. Questions are the property of the GATE organising institutes; this copy is for your personal study.

12 questions · 0 correct of 0 attempted · marks 0 / 20

Year:
GATE 2025 CS2 · Q28MSQ1 mark
Which of the following is/are part of an Instruction Set Architecture of a processor?

One or more options may be correct. Select all that apply, then submit.

GATE 2025 CS1 · Q37MCQ2 marks
A processor has 64 general-purpose registers and 50 distinct instruction types. An instruction is encoded in 32 bits. What is the maximum number of bits that can be used to store the immediate operand for the given instruction? ADD R1, #25 // R1 = R1 + 25
GATE 2024 CS2 · Q57NAT2 marks
A processor with 16 general purpose registers uses a 32-bit instruction format. The instruction format consists of an opcode field, an addressing mode field, two register operand fields, and a 16-bit scalar field. If 8 addressing modes are to be supported, the maximum number of unique opcodes possible for every addressing mode is ______.
GATE 2024 CS2 · Q61NAT2 marks
A processor uses a 32-bit instruction format and supports byte-addressable memory access. The ISA has 150 distinct instructions, equally divided into R-type and I-type. R-type: OPCODE | UNUSED | DST register | SRC register 1 | SRC register 2. I-type: OPCODE | DST register | SRC register | Immediate value/address. In the OPCODE, 1 bit distinguishes I-type from R-type and the remaining bits indicate the operation. The processor has 50 architectural registers and all register fields are of equal size. Let X = bits of the UNUSED field, Y = bits of the OPCODE field, Z = bits of the immediate field. The value of X + 2Y + Z is ______.
GATE 2023 · Q41MCQ2 marks
Consider the given C-code and its corresponding assembly code, with a few operands U1–U4 being unknown. The memory is byte-addressable.
// C-code (int is 32-bit)
int a[10], b[10], i;
for (i=0; i<10; i++)
    a[i] = b[i] * 8;

; assembly (r1-r5 are 32-bit registers; r1=0, r2=10; r3, r4 = base of a, b)
L01: jeq r1, r2, end      ; if (r1==r2) goto end
L02: lw   r5, 0(r4)       ; r5 <- Memory[r4+0]
L03: shl  r5, r5, U1      ; r5 <- r5 << U1
L04: sw   r5, 0(r3)       ; Memory[r3+0] <- r5
L05: add  r3, r3, U2      ; r3 <- r3+U2
L06: add  r4, r4, U3
L07: add  r1, r1, 1
L08: jmp  U4              ; goto U4
L09: end
Which option is a CORRECT replacement for (U1, U2, U3, U4)?
GATE 2021 Set 1 · Q55NAT2 marks
Consider the following instruction sequence where registers R1, R2 and R3 are general purpose and MEMORY[X] denotes the content at the memory location X.
MOV R1, (5000) R1 ← MEMORY[5000] (4 bytes) · MOV R2, (R3) R2 ← MEMORY[R3] (4 bytes) · ADD R2, R1 R2 ← R1 + R2 (2 bytes) · MOV (R3), R2 MEMORY[R3] ← R2 (4 bytes) · INC R3 R3 ← R3 + 1 (2 bytes) · DEC R1 R1 ← R1 − 1 (2 bytes) · BNZ 1004 branch if not zero to the given absolute address (2 bytes) · HALT stop (1 byte). Assume that the content of memory location 5000 is 10, and the content of the register R3 is 3000. The content of each of the memory locations from 3000 to 3010 is 50. The instruction sequence starts from the memory location 1000. All the numbers are in decimal format. Assume that the memory is byte addressable. After the execution of the program, the content of memory location 3010 is ______.
GATE 2020 · Q44NAT2 marks
A processor has 64 registers and uses a 16-bit instruction format. It has two types of instructions: I-type and R-type. Each I-type instruction contains an opcode, a register name, and a 4-bit immediate value. Each R-type instruction contains an opcode and two register names. If there are 8 distinct I-type opcodes, then the maximum number of distinct R-type opcodes is ______.
GATE 2018 · Q5MCQ1 mark
Consider the following processor design characteristics. I. Register-to-register arithmetic operations only. II. Fixed-length instruction format. III. Hardwired control unit. Which of the characteristics above are used in the design of a RISC processor?
GATE 2018 · Q51NAT2 marks
A processor has 16 integer registers (R0 to R15) and 64 floating point registers (F0 to F63). It uses a 2-byte instruction format. There are four categories of instructions: Type-1 has four instructions, each with 3 integer register operands (3Rs). Type-2 has eight instructions, each with 2 floating point register operands (2Fs). Type-3 has fourteen instructions, each with one integer register operand and one floating point register operand (1R+1F). Type-4 has N instructions, each with a floating point register operand (1F). The maximum value of N is ______.
GATE 2017 Set 1 · Q11MCQ1 mark
Consider the C struct defined below:
struct data {
  int marks[100];
  char grade;
  int cnumber;
};
struct data student;
The base address of student is available in register R1. The field student.grade can be accessed efficiently using
GATE 2017 Set 1 · Q49NAT2 marks
Consider a RISC machine where each instruction is exactly 4 bytes long. Conditional and unconditional branch instructions use PC-relative addressing mode with Offset specified in bytes to the target location of the branch instruction. Further, the Offset is always with respect to the address of the next instruction in the program sequence. Consider the following instruction sequence: i: add R2, R3, R4, i+1: sub R5, R6, R7, i+2: cmp R1, R9, R10, i+3: beq R1, Offset. If the target of the branch instruction is i, then the decimal value of the Offset is ______.
GATE 2014 Set 1 · Q9NAT1 mark
A machine has a 32-bit architecture, with 1-word long instructions. It has 64 registers, each of which is 32 bits long. It needs to support 45 instructions, which have an immediate operand in addition to two register operands. Assuming that the immediate operand is an unsigned integer, the maximum value of the immediate operand is ______.

Extra practice (GATE-style)

More questions in the same formats, each with a full solution. These are original questions written to follow the patterns above, not past-paper questions.

5 questions · 0 correct of 0 attempted · marks 0 / 7

Q1NAT1 mark
A processor has 40 distinct instructions and 24 general-purpose registers. A 32-bit instruction word has an opcode, two register operands and an immediate operand. The number of bits available for the immediate field is ____.
Q2NAT1 mark
A relative-addressing branch is at address 1000 and occupies one word. Its offset field holds −8, and PC is incremented before the offset is added. The target address is ____.
Q3MCQ2 marks
A 16-bit instruction has two 6-bit address fields. 15 two-address instructions use opcodes 0000 to 1110 of the 4-bit opcode; 63 one-address instructions are then defined using the escape 1111 and 6 further opcode bits. The maximum number of zero-address instructions is
Q4MCQ1 mark
The 32-bit value 0xA1B2C3D4 is stored in little-endian order starting at address 2000. The byte stored at address 2001 is
Q5MCQ2 marks
On a zero-address (stack) machine, the minimum number of instructions to evaluate X = (A + B) × (C − D), including the final store, is

Common traps

Relative mode: PC value used is address of the next instruction unless stated.
Indirect needs 2 memory accesses for the operand (+1 for fetch).
In expanding-opcode, patterns used by shorter instrs multiply by 2a at each level, not by 2.