+ All Categories
Home > Documents > 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in...

1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in...

Date post: 20-Dec-2015
Category:
View: 220 times
Download: 1 times
Share this document with a friend
57
1 Code Generation (cont’d.)
Transcript
Page 1: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

1

Code Generation (cont’d.)

Page 2: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

2

Code Generation (cont’d.)

Save to Register A 1. <term>2 already in Register A, or2. <factor> already in Register A, or3. <term>2 and <factor>both are not in Register A

Page 3: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

3

Code Generation (cont’d.)

Node Specifier S(<term>1)save to rA

Page 4: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

4

Page 5: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

5

Code Generation (cont’d.)

Page 6: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

6

Code Generation (cont’d.)

Page 7: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

7

Code Generation (cont’d.) 9 and 10

S(<exp>) := S(<term>) = S(SUMSQ)

REGA = <exp>

S(<exp>) <> rA =S(MEAN)

Page 8: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

8

Code Generation (cont’d.) 10

Page 9: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

9

Code Generation (cont’d.) 10

S(<exp>2) <> rA = S(MEAN)

Call GETA(<exp>2) GETA(SUMSQ)

Generate [SUB S(MEAN)=T2]

S(<exp>1) := rA

REGA := <exp>1

Page 10: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

10

Code Generation (cont’d.) 11

S(<term>) := S(<factor>):= S(SUMSQ)

S(<term>) <> rA

S(<term>) := S(MEANl)

Page 11: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

11

Code Generation (cont’d.) 11

S(<term>2) <> rA

S(<factor>) <> rA

Call GETA(MEAN)

Generate [MUL MEAN]

S(MEAN) := rA

REGA:= MEAN

Page 12: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

12

Code Generation (cont’d.) 11

S(<term>2) <> rA

Call GETA(SUMSQ)

Generate [DIV #100]

S(<term>1) := rA

REGA := <term>1

Page 13: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

13

Code Generation (cont’d.) 12

S(<factor>) := S(SUMSQ)

S(<factor>) := S(MEANl)

S(<factor>) := S(MEANr)

S(<factor>) := S(#100)

Page 14: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

14

Page 15: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

15

Code Generation (cont’d.)

REGA = NULL

Generate [LDA SUMSQ]

S(SUMSQ) := rA

REGA := SUMSQ

REGA <> NULL = SUMSQ

S(MEAN) <> rA = S(SUMSQ)

Generate [STA T1]

S(SUMSQ) = T1

Generate [LDA MEAN]

S(MEAN) := rA

REGA := MEAN

REGA <> NULL = MEANS(SUMSQ) <> rA = S(MEAN)Generate [STA T2]S(MEAN) = T2Generate [LDA S(SUMSQ)=T1]S(SUMSQ) := rAREGA := SUMSQ

Page 16: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

16

Code Generation (cont’d.)

I

Page 17: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

17

Code Generation (cont’d.) 1, 2, and 3

Page 18: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

18

Code Generation (cont’d.) 4, 5, and 7

Page 19: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

19

8, 14, 15

Page 20: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

20

Code Generation (cont’d.) 16 and 17

Page 21: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

21

Code Generation (cont’d.)

Page 22: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

22

Code Generation (cont’d.)

Page 23: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

23

Page 24: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

24

Page 25: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

25

Page 26: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

26

Page 27: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

27

Page 28: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

28

Page 29: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

29

Page 30: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

30

Page 31: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

31

LDA SUMSQDIV #100STA T1LDA MEANMUL MEANSTA T2LDA T1SUB T2STA T3LDA T3STA VARIANCE

Page 32: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

32

T2

T2

LDA MEANMUL MEANSTA T2LDA SUMSQDIV #100STA T1LDA T1SUB T2STA T3LDA T3STA VARIANCE

Page 33: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

33

T2

T2

Page 34: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

34

Page 35: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

35

Page 36: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

36

Page 37: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

37

3*(6-1)=3*5=15

Page 38: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

38

Page 39: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

39

3*(I-1)

Content of Address of A A(3*(I-1))=5

Page 40: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

40

Page 41: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

41

3*((I-0)*(6-1+1)+(J-1))=5

Page 42: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

42

3*((I-1)*(10-1+1)+(2J-1-1))3*(i1(i8)*103*(i2(i9) +i3(i10)-1-1

+i4(i11)-1 +i53*i6(i12)i7(i13)

Page 43: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

43

Page 44: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

44

Page 45: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

45

Page 46: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

46

Machine-Independent Compiler Features

Page 47: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

47

Machine-Independent Compiler Features Storage Allocation

Static Allocation: cannot be used for recursive call

Dynamic Allocation: Activation Record

Page 48: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

48

Page 49: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

49

Page 50: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

50

Page 51: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

51

Page 52: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

52

Page 53: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

53

Page 54: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

54

Page 55: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

55

P-Code Compliers

Page 56: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

56

Compiler-Compilers

Page 57: 1 Code Generation (cont’d.). 2 Save to Register A 1. 2 already in Register A, or 2. already in Register A, or 3. 2 and both are not in Register A.

57

http://ptt.cc/google.wmv


Recommended