Chapter_8 - Chapter 8: Code Generation 1 Generating...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Chapter 8: Code Generation
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Generating Instructions from Three-address Code Example: D = (A*B)+C 0 1 2 =* A B T1 =+ T1 C T2 = T2 D quadruples
Background image of page 2
3 Skeletons =+ => Load R1 0 (first parameter) Add R1 1 (2nd parameter) Stor R1 2 (3rd parameter) =* => Load R1 0 (first parameter) Mul R1 1 (2nd parameter) Stor R1 2 (3rd parameter) = => Load R1 0 (first parameter) Stor R1 2 (3rd parameter) (For integer operation)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Thus we get: Load R1 A Mul R1 B Stor R1 T1 Load R1 T1 Add R1 C Stor R1 T2 Load R1 T2 Stor R1 D There are 8 instructions.
Background image of page 4
5 Additional skeleton (pseudo-operators) FX : fetch if not already available Code generator must remember what is in each register. Thus we have =+ => FX R1 0 (first parameter) =* => FX R1 0 Add R1 1 (2nd parameter) Mul R1 1 Stor R1 2 (3rd parameter) Stor R1 2 = => FX R1 0 Stor R1 2
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Thus we get Load R1 A Mul R1 B Stor R1 T1 Add R1 C Stor R1 T2 Stor R1 D There are 6 instructions
Background image of page 6
7 Another Pseudo Operator SX SX - store if not used right away (or if it is not a temporary
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/28/2011 for the course ENGINEERIN 100 taught by Professor Yangwei during the Spring '10 term at National Cheng Kung University.

Page1 / 18

Chapter_8 - Chapter 8: Code Generation 1 Generating...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online