Code Generation
Code Generation
s e
T2
Oe
generahion is the im task or achivihy of the compiles. Code generation
PTocess of cveating. Assembly/Machine language . Folloeing are the properies O
the code-generatfon.
c). Efficient use of
resource of target machip
a). Correctness b). High uality
d. Qurck code Generatfon.
executed.It is
Useful
jo Sma
and nialu
Cede Fixed location fn memoru
0 r e Machine
program
be placed coheve-eved
elocctcable Machine Code' not a fized location, code can cemmercia
have
Compilex8.
RAM, Itis useful for
find the xoom n
8howa
be corect anal
its purpase
code Aenerated should
aCOectness:
Itmeans that the
be altex3.
tree ,ancd exroT ree
code ahoud be ambiauity
It means thot
b . High-ualit:
o h th
I t is the
code geneva ton phase
Regource of lavget Machine, whe ther e ffitwent
c) Effiui ent use of to check
So it takes res ponsibiliby
make use
of target machine, or not
mahine taking place
0se 6f
resource of target
then immedu'ekela
cess ends
compilalton pro
,
:
When the maahine
Code Creneration
.
d.Quick execuion o n
code for that for
generate
Interme.diate Code
Creneratin
Code Ophmizahon
Tntermediae Coele:
Aclehreu Code Error
4).Three
b) Post NMotatton Handler
Sumbo
e) Syntau Tree
Table
d uadruple
e).Tiple
Code Cenevation
Assemble
Mathine (o de
mev Ro
ADD C, Ro
Cfhtent Aserbly
ADD , Ro Cde
mov o, .
Register Al te cobion for the alven Instuth on, we haye utecd onl one Registex Ro
e make use of Reaister If we have more than one regisher usage, then how Tegi'stes
Exaple', -
Ho Reg'stey Alocaion takes plate for he aiven three Addreu code,
T A+8 MOV A, Ro
T T*C- LA DD 8,Ro
T T/ D MUL C,Ro
DIv d, Ro
MoV RoT
then hoo Tesste
f the Input te the Code Generahon phase Is Syu tree
allecation todtes plate'
Cadcudoe miui mum Regis ke
Reqirtd
Vofi
Ro a
R b
( q -b Ro Ro- R
N o w R can be fee, to be ed kr
othes volue.
(2 Ctd
R R,+R2
New R can be free
tCRee
e
- R2-R
R free
et
( a-b)+ P2
Re
foc-) -(P)fae
Rot P2
Ro
e, free
et
tfee Here 3 Pegistex have ured