Compiler Construction Lab Manual / Code Generation For While lex Program

Program Name

Write a Compiler Construction Program for Code Generation For While lex Program.
Theory
Code Generation For While lex Program using lex sections.
Program Code


Saving: vi whilecodegen.c

Compiling and Running
cc whilecodegen.c
./a.out
Input
enter the c stmt: while(i=2) x=x+5

Output
MOV i,R1
JMP NEW
BACK:MOV x,R2
ADD 5,R2
STORE R2,x
NEW:CMP R1,2
JE BACK


Home     Back