Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



Consider the program below which uses six temporary variables a, b, c, d, e, and f.
a = 10
b = 20
c = 30
d=a+c
f=c+c
b=c+e
e=b+f
d=5+e
return d+f

Assuming that all the above operations take their operands from registers, the minimum number of registers needed to execute this program without spilling is





Solution

Detailed Register Allocation Analysis

Objective: Determine the minimum number of registers needed to execute the program without spilling.

Live Range Analysis:

  • a: Line 1 → 4
  • b: Line 6 → 7
  • c: Line 3 → 6
  • d: Line 8 → 9
  • e: Line 7 → 8
  • f: Line 5 → 9

Max live variables: 3 (after lines 6 and 7)

✅ Final Answer: 3 registers are required to execute the program without spilling.



Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.