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

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

1 Chapter 8: Code Generation

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

View Full Document
2 Generating Instructions from Three-address Code Example: D = (A*B)+C 0 1 2 =* A B T1 =+ T1 C T2 = T2 D quadruples
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)

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

View Full Document
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.
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

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

View Full Document
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
7 Another Pseudo Operator SX SX - store if not used right away (or if it is not a temporary

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

View Full Document
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
Ask a homework question - tutors are online