Download presentation
Presentation is loading. Please wait.
1
1 Code Generation (cont’d.)
2
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
3 Code Generation (cont’d.) Node Specifier S( 1 ) save to rA
4
4
5
5 Code Generation (cont’d.)
6
6
7
7 Code Generation (cont’d.) 9 and 10 S( ) := S( ) = S(SUMSQ) REGA = S( ) <> rA =S(MEAN)
8
8 Code Generation (cont’d.) 10
9
9 S( 2 ) <> rA = S(MEAN) Call GETA( 2 ) GETA(SUMSQ) Generate [SUB S(MEAN)=T2] S( 1 ) := rA REGA := 1
10
10 Code Generation (cont’d.) 11 S( ) := S( ):= S(SUMSQ) S( ) <> rA S( ) := S(MEAN l )
11
11 Code Generation (cont’d.) 11 S( 2 ) <> rA S( ) <> rA Call GETA(MEAN) Generate [MUL MEAN] S(MEAN) := rA REGA:= MEAN
12
12 Code Generation (cont’d.) 11 S( 2 ) <> rA Call GETA(SUMSQ) Generate [DIV #100] S( 1 ) := rA REGA := 1
13
13 Code Generation (cont’d.) 12 S( ) := S(SUMSQ) S( ) := S(MEAN l ) S( ) := S(MEAN r ) S( ) := S(#100)
14
14
15
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 = MEAN S(SUMSQ) <> rA = S(MEAN) Generate [STA T2] S(MEAN) = T2 Generate [LDA S(SUMSQ)=T1] S(SUMSQ) := rA REGA := SUMSQ
16
16 Code Generation (cont’d.) I
17
17 Code Generation (cont’d.) 1, 2, and 3
18
18 Code Generation (cont’d.) 4, 5, and 7
19
19 8, 14, 15
20
20 Code Generation (cont’d.) 16 and 17
21
21 Code Generation (cont’d.)
22
22 Code Generation (cont’d.)
23
23
24
24
25
25
26
26
27
27
28
28
29
29
30
30
31
31 LDASUMSQ DIV#100 STAT1 LDAMEAN MULMEAN STAT2 LDAT1 SUBT2 STAT3 LDAT3 STAVARIANCE
32
32 T2 LDAMEAN MULMEAN STAT2 LDASUMSQ DIV#100 STAT1 LDAT1 SUBT2 STAT3 LDAT3 STAVARIANCE
33
33 T2
34
34
35
35
36
36
37
37 3*(6-1)=3*5=15
38
38
39
39 3*(I-1) Content of Address of A A(3*(I-1))=5
40
40
41
41 3*((I-0)*(6-1+1)+(J-1))=5
42
42 3*((I-1)*(10-1+1)+(2J-1-1)) 3*(i1(i8)*10 3*(i2(i9) +i3(i10)-1-1 +i4(i11)-1 +i5 3*i6(i12) i7(i13)
43
43
44
44
45
45
46
46 Machine-Independent Compiler Features
47
47 Machine-Independent Compiler Features Storage Allocation Static Allocation: cannot be used for recursive call Dynamic Allocation: Activation Record
48
48
49
49
50
50
51
51
52
52
53
53
54
54
55
55 P-Code Compliers
56
56 Compiler-Compilers
57
57 http://ptt.cc/google.wmv
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.