Instruction types and formats, zero- to three-address machines, opcode and field-width calculations including expanding opcodes, and every common addressing mode with its effective address, as GATE EC asks.
1. Machine instructions and the number of addresses
A machine instruction is a binary word the processor decodes and executes. It has an opcode (what to do) and zero or more operand fields (where the data is). The set of all instructions, registers and addressing modes is the instruction set architecture (ISA).
Kinds of instructions: data transfer (LOAD, STORE, MOV, PUSH, POP), arithmetic and logic (ADD, SUB, AND, shifts), control transfer (JUMP, conditional BRANCH, CALL, RETURN) and input/output. Each instruction passes through fetch → decode → operand fetch → execute → write back, and the PC is incremented to the next instruction during fetch.
Machines are classed by how many operand addresses an instruction carries:
Type
Example
Code for
3-address
ADD X, A, B
ADD X, A, B; MUL X, X, C (2 instructions)
2-address
ADD A, B ()
MOV X, A; ADD X, B; MUL X, C (3)
1-address (accumulator)
ADD A ()
LOAD A; ADD B; MUL C; STORE X (4)
0-address (stack)
ADD (pop two, push sum)
PUSH A; PUSH B; ADD; PUSH C; MUL; POP X (6)
Fewer addresses give shorter instructions but more of them. A stack machine evaluates the expression in postfix order (); only PUSH and POP carry an address.
Load-store (RISC) machines allow memory access only through LOAD and STORE; arithmetic works on registers. CISC machines allow memory operands in arithmetic instructions, with variable-length formats and many modes.
2. Instruction formats and field widths
An instruction word of bits is split into fields. The rule for every field is
Opcode field for distinct instructions: bits.
Register field for registers: bits.
Address field for addressable locations: bits.
Mode field for addressing modes: bits.
Whatever is left goes to the immediate or offset field. A -bit two's complement immediate covers to .
Expanding opcode. With a fixed word length, instructions with fewer address fields can use the spare bits as extra opcode bits. If the 2-address format has an -bit opcode and only of the codes are used, each unused code becomes a prefix for 1-address instructions, which gain the bits of one address field ( bits):
The same step repeats for 0-address instructions: unused 1-address codes times . Work level by level: used codes are lost, only free codes expand.
Top: a 32-bit register-immediate format with bit positions. Bottom: expanding opcode, where the spare 4-bit code 1111 prefixes a 6-bit extended opcode for one-address instructions.
3. Addressing modes and the effective address
An addressing mode says how the operand field is turned into the operand. The memory address finally used is the effective address (EA). Let be the address field and a register.
Mode
EA / operand
Memory accesses for the operand
Typical use
Immediate
operand itself
0
constants
Register
operand
0
fast temporaries
Direct (absolute)
1
global variables
Memory indirect
2
pointers held in memory
Register indirect
1
pointers held in a register
Indexed
1
array element ( = base, register = )
Base (displacement)
1
relocatable code, fields of a record, stack frames
PC-relative
1 (for data)
branches, position-independent code
Auto-increment / decrement
, then (or decrement first)
1
stepping through arrays, stack push/pop
Implied
operand fixed by the opcode
0
CLC, stack ops, accumulator ops
"Memory accesses" counts those needed to fetch the operand after the instruction itself has been fetched.
Indexed and base modes compute the same sum; the difference is intent. In indexed the address field is the large base address and the register holds a small index; in base mode the register holds the base and the field is a small offset.
One LOAD instruction with address field 300 and register R2 = 200, read under different addressing modes against the same memory.
4. PC-relative branches and auto-increment
PC-relative addressing. By the time an instruction executes, the PC already points to the next instruction. So for an instruction at address that is bytes long,
The offset is a signed number. Some ISAs store the offset in words and shift it left (multiply by 4 for 4-byte instructions) before adding; read the question for this. Because only the distance is stored, the code still works if the whole program is loaded at a different address: it is position independent.
Auto-increment and auto-decrement. uses and then adds the operand size to ; first subtracts and then uses the new . With a stack growing downwards, PUSH is and POP is . The step equals the operand size in bytes (1, 2, 4 or 8) on a byte-addressable machine.
Byte addressing. In a byte-addressable memory, consecutive 32-bit words are at addresses differing by 4. Sequential instruction fetch therefore does for 32-bit instructions.
Subroutine call. CALL saves the return address (the updated PC) on the stack or in a link register and loads the PC with the target; RETURN restores it. Recursion needs the stack version.
Mode
Advantage
Cost
Immediate
no memory access
limited by field width
Direct
simple
address field must cover all memory
Indirect
large address space from a small field
one extra memory access
Register indirect
short field, one access
register must be loaded first
PC-relative
relocatable, short offset
only nearby targets
Formulas to remember
Field widthBits to name opcodes, registers or locations
Immediate field remaining = instruction length
Two's complement range
Expanding opcode = opcode bits of the longer format, codes used, = bits freed (one address field)
Indexed / base address
Memory indirect
PC-relative target = address of the branch, = its length in bytes
Common mistakes
Adding a PC-relative offset to the address of the branch itself instead of the updated PC (branch address plus instruction length).
In expanding-opcode problems, expanding all codes instead of only the unused ones.
Counting the instruction fetch in "memory accesses for the operand" when the question asks only for the operand.
Taking of a non power of two without rounding up; 45 opcodes need 6 bits, not 5.
Confusing memory indirect (, two accesses) with register indirect (, one access).
Forgetting that a -bit signed immediate reaches only on the positive side.
Worked examples
Try each step yourself, then reveal the working.
Example 1: Sizing the immediate field
numerical
A processor has 32-bit instructions and 32 general-purpose registers. A format holds an opcode, two register fields and a signed immediate. If 45 distinct opcodes must be supported, find the maximum immediate width and its range.
Step 1: Find the opcode width.
Try it on paper first.
Example 2: Expanding opcode
numerical
A machine has 16-bit instructions and 6-bit address fields. Two-address instructions use a 4-bit opcode. If 14 two-address instructions are defined, how many one-address instructions can be defined at most?
Step 1: Count the free 4-bit codes.
Try it on paper first.
Example 3: Operand under each addressing mode
numerical
An instruction LOAD R1 has address field 300. Register R2 = 200. Memory: , , , . Find the value loaded into R1 for immediate, direct, memory indirect, register indirect (via R2) and indexed (index register R2) modes.
Step 1: Immediate and direct.
Try it on paper first.
Example 4: PC-relative branch offset
numerical
On a byte-addressable machine with 4-byte instructions, a branch at address 2000 must jump to address 1992. The offset is in bytes and is added to the updated PC. What offset is stored?
Step 1: Find the PC value when the offset is added.
Try it on paper first.
Previous year questions
1 official GATE EC question on this topic, newest first.
9 questions: up to 1 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.
Mark as mastered
Loading your progress…
My revision notes
Notes written by the GATEiit team against the official GATE EC syllabus; being checked by a reviewer. Updated 2026-11-29. Spotted a mistake? Use Report an issue on any question, or contact us.