CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Following table indicates the latencies of operations between the instructions producing the result and instruction using the result.

Instruction production the result Instruction using the result Latency
ALU Operation ALU Operation 2
ALU Operation Store 2
Load ALU Operation 1
Load Store 0


Consider the following code segment.

Load R1, Loc1 ; Load R1 from memory location Loc1

Load R2, Loc2 ; Load R2 from memory location Loc2

Add R1, R2, R1 ; Add R1 and R2 and save result in R1

Dec R2 ; Decrement R2

Dec R1 ; Decrement R1

Mpy R1, R2, R3 ; Multiply R1 and R2 and save result in R3

Store R3, Loc3 ; Store R3 in memory location Loc3

What is the number of cycles needed to execute the above code segment assuming each instruction takes one cycle to execute?

A
13
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
7
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
14
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
D
10
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is C 14
Instruction Latency No. of cycles
Load R1, Loc1 0 0
Load R2, Loc2 0 0
Add R1, R2, R1 1 + 1 + 2 = 4 4 × 1 cycle = 4
Dec R2 1 + 2 = 3 3 × 1 cycle = 3
Dec R1 1 + 2 = 3 3 × 1 cycle = 3
Mpy R1, R2, R3 1 + 1 + 2 = 4 4 × 1 cycle = 4
Store R3, Loc3 0 0
Total = 14

flag
Suggest Corrections
thumbs-up
1
similar_icon
Similar questions
View More
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Algebraic Solution
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon