GATE / CS ARCHIVE

GATE CSE 2017 SET 1 / QUESTION 49

GATE CSE 2017 Set 1 Q49

Computer Organization & Architecture · Instructions & Addressing Modes · Full GATE CSE 2017 Set 1 paper

GATE 2017 Set 1, Q49 2 marks · NAT
Report issue

Instructions & Addressing Modes

Question 49, GATE 2017: A RISC instruction is 4 bytes. Branch offsets are byte offsets relative to the NEXT instruction. Instructions are i:add R2,R3,R4; i+1:sub R5,R6,R7; i+2:cmp R1,R9,R10; i+3:beq R1,Offset. Branch target is i. Find signed decimal Offset.
Tap to enlarge
Answer & solution

Official answer: -16.0 to -16.0

Our answer: -16

1. Let the byte address of instruction i be A. Then i+1,i+2,i+3 have addresses A+4,A+8,A+12.

2. The branch uses the next instruction as reference, which is i+4 at A+16, not the branch’s own address A+12.

3. Offset=target−reference=A−(A+16)=−16 bytes. The negative sign denotes a backward branch. Counting three instruction gaps from the branch itself would incorrectly give −12.

Original paper, page 22 · Answer key