0% found this document useful (0 votes)
18 views3 pages

Fall 2024 - CS606 - 2

Uploaded by

Ahmad Baig
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Fall 2024 - CS606 - 2

Uploaded by

Ahmad Baig
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CS606 – Compiler Construction

Total Marks: 20
Assignment No. 02
Due Date: Jan 1, 2025
Semester: Fall 2024

Please read the following instructions carefully and delete the first page from your solution file before
submitting assignment:

Uploading Instructions:
o You are supposed to consult recommended book/s to clarify your concepts as handouts are not sufficient.
o The assignment file must be an MS Word file. Any other software/tool is not allowed.
o The required file format is .doc or .docx. Any other format like scan images, txt, pdf, png or jpeg etc. will
not be accepted.
o Place all solutions in a single MS Word file along with your own Student Id at top.
o Submit the MS Word file at VULMS within the due date.

Rules for Marking:


It should be cleared that your assignment will not get any credit if:
o The assignment is submitted after due date.
o The assignment is not submitted in .doc or .docx format.
o The submitted assignment does not open or file is corrupt.
o The assignment is fully or partially copied from other student or ditto copy from handouts or Internet;
strict disciplinary action will be taken in this case.
o The submitted file does not contain your own Student Id, or contain other than yours; Zero Marks will be
awarded, and no excuse will be accepted in any case.

Note:
o No assignment will be accepted after the due date via email in any case (whether it is the case of load
shedding or internet malfunctioning etc.). Hence refrain from uploading assignment in the last hour of
deadline.
o It is recommended to upload solution file at least one day before its closing date.
o Do not put any query on MDB regarding this assignment, if you have any query then email at
[email protected]

Lectures Covered: This assignment covers Lectures # 23 to 29.

1
CS606 – Compiler Construction
Total Marks: 20
Assignment No. 02
Due Date: Jan 1, 2025
Semester: Fall 2024

Question Statement:
Imagine you're a software developer working on an exciting
challenge: designing a compiler for a new programming language
called EcoLang. This language is specifically created for an
environmentally friendly IoT device that has limited memory
and processing power. Because of these constraints, the device
can only work with three-address code for computations. Your
mission is to generate optimized intermediate code for EcoLang
that uses as few instructions as possible while ensuring
correctness.

Here are two features of EcoLang that need your expertise in


optimization:

Features to Implement
1. Arithmetic Expression Simplification:
EcoLang supports complex, nested arithmetic expressions like:
((a + b) * c) - (d / e).
Your task is to break it down and write optimized three-address
code for such expressions.
2. Conditional Statements:
The language includes conditional logic, such as:
if (a > b) then x = y + z else x = y - z.
You'll write intermediate code that efficiently handles such
conditions.

Your Tasks
Based on the scenario, complete the following:

1. Intermediate Code for Arithmetic Expression:


Write optimized three-address code for the expression:
((a + b) * c) - (d / e).
2. Intermediate Code for Conditional Statement:
Generate three-address code for the conditional statement:
if (a > b) then x = y + z else x = y - z.
3. Justification of Optimization:
Provide a brief explanation of how your three-address code
minimizes instructions and ensures efficiency, considering the
constraints of the IoT device.

2
CS606 – Compiler Construction
Total Marks: 20
Assignment No. 02
Due Date: Jan 1, 2025
Semester: Fall 2024

Good Luck

You might also like