CSC511 (Compiler Design) Autumn 2024-2025 Lab Ass - 1
CSC511 (Compiler Design) Autumn 2024-2025 Lab Ass - 1
Assignment - 1
Subject: Compiler Design Laboratory (CSC511) Marks: 10
Instructor-In-Charge: Dr. SK Hafizul Islam TA1: Sabnur Rahaman
TA2: Nilkantha Garain TA1: Suman Som
Assignment Out: 23/07/2024 (02:00 P.M.) Submission: 23/07/2024 (04:55 P.M.)
Instructions:
1. You must attend this lab class physically, execute your assignment, and show your code to
the IC/TAs. We will evaluate your assignment and award the marks accordingly. Online
submission of the assignment without attending the lab classes leads to ZERO Marks.
2. Submission Procedure: Google classroom/TA will verify the program during the lab.
3. Execute the assignment by your own wards, and do not copy from other sources. If the
assignment is copied from other sources, you will be awarded to zero (0) mark.
4. Strictly follow the date and time of submission.
5. Name of file should be “CSC511Assignment - i[Your Registration Number].extension”. Ex-
ample: CSC411Assignment - 1[313].C. Here i indicate the assignment number. If you submit the
assignment with different name, you will be awarded to zero (0) mark.
6. During the lab session, ask the TAs for the marks of the assignments you have submitted. Later we will
not entertain you for any discrepancies.
#include <stdio.h>
#define MAX 100
int main()
{
int x;
printf()"Enter the value of x\n");
scanf("%d",&x);
printf("Final max value is %d\n", x+MAX);
return 0;
}
a. Show the file program.i, which is created by the preprocessor after removing the preprocessor direc-
tives. Use the gcc (GNU Compiler Collection) command:
• gcc -E program.c -o program.i
b. Generate the relocatable machine code for program.i. Use the gcc commands:
• gcc -c program.i -o program.o
• objdump -r program.o
1
• Compile them using the gcc command:
gcc -c main.c -o main.o
gcc -c greet.c -o greet.o
• Link both the programs using the gcc command:
gcc main.o greet.o -o program
• Load the object file program and execute it using the gcc command:
./program