5 IT 7.  SYSTEM SOFTWARE LAB

In this lab we will practice how source code is processed by compiler/ assembler/ pre-processor.

All programs have to be written in C++

1.      Write a class for file handling, having functions to open/ read/ write/ close/ reset.

2 - 5. Develop a program which takes input a file of C language

(a)    Print Lines of Codes and print signature of all function   (including main)

(b)    Print number of variables in every function (with type)

(c)    Generate a new file without the comments. (/* */ and //)

(d)   Process all #define (i.e. #define MAX 100, than replace every occurrence of MAX with 100).

(Macro value 100 can be an expression also.)

6.       Write a program to create a symbol table.

7.       Write a program which can parse a given C file and store all variables and functions in symbol table.

8 - 10. Write a program to convert given C program into RTL code.

Assumption

(a)    Input C file will have only main function,

(b)    Only two type of statements, either variable declaration statements

(int sub1=23;) OR mathematical expression (sub1 = sub2 - sub3 ;).

(c)    System has 16 registers (R1 to R16)

(d)    RTL opcode available are: ADD, LOAD, MOVE, SUB, MULTIPLY, DIVIDE

(e)    No control-flow (i.e. if-else, loop, jump etc.) expression is there in input code e.g