GATE CSE 2017 Session 1 Q59: PC-relative branch offset back to instruction i from beq at i+3
- Computer Organization and Architecture
- 2 marks
- NAT
- No negative marking
Syllabus topic: Instruction set and addressing modes
Question
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
| Instr. No. | Instruction |
|---|---|
| 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 ______.
Try it: numerical answer: type the value
Show answer and explanation
Answer: -16 (official GATE 2017 final answer key)
Concept used: With PC-relative addressing, Offset = target address − address of the next instruction (PC after fetch).
First step: Take the address of instruction i as 0; the next instruction after beq (i+4) is at byte 16, so subtract that from the target address.
Full step-by-step solution
Loading…
Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.
More questions on Instruction set and addressing modes
Every PYQ on this topic →Share this question
Source: official GATE 2017 Session 1 CS question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key
More Computer Organization and Architecture PYQs
- 2026 Session 1 · Q14Match addressing modes with high-level data elements
- 2026 Session 1 · Q15Instruction sequence for Z = X + Y on a load-store machine
- 2026 Session 1 · Q16Register dependency that causes a data hazard
- 2026 Session 1 · Q36IEEE 754 single-precision sum of 35C00000 and 34A00000
- 2026 Session 1 · Q38Tag length: direct-mapped vs K-way set-associative cache
- 2026 Session 1 · Q54Impossible TLB / page table / cache event sequences