Compilerbau: Codeerzeugung für logische Operatoren |
1begin
2 var
3 i, j, s : int := 1, 2, 0;
4
5 var
6 a, b, c : boolean := false, true, false;
7
8 if a and b and c
9 then
10 i := 42;
11 a := a => b;
12 i := 43;
13 b := a <=> b;
14 i := 44;
15 c := (i /= 0)
16 and (j /= 0)
17 and (i >= 0 <=> j >= 0)
18 endif;
19
20 while true
21 do
22 endwhile;
23
24 i := 45;
25
26 while false
27 do
28 endwhile;
29
30 i := 46;
31
32 while a and b and c
33 do
34 a, i, b, j, c := a and b, 27, a or b, 28, not c
35 endwhile;
36
37 i := 47;
38
39 begin
40 var
41 s : int := 0;
42
43 while i > 0
44 do
45 i, j := i - 1, i;
46 while j > 0
47 do
48 j,s := j - 1, s + 1
49 endwhile
50 endwhile
51 end;
52
53 i := 48;
54
55 repeat
56 until false;
57
58 i := 49;
59
60 repeat
61 until true;
62
63 i := 50;
64
65 repeat
66 i, j := i + 1, j - 1
67 until i > j
68
69end
70
|
1.text
2 loadi 1
3 loadi 2
4 loadi 0
5 store m[2]
6 store m[1]
7 store m[0]
8 loadi 0
9 loadi 1
10 loadi 0
11 store m[5]
12 store m[4]
13 store m[3]
14 load m[3]
15 brfalse l0
16 load m[4]
17 brfalse l0
18 load m[5]
19 brfalse l0
20 loadi 42
21 store m[0]
22 load m[3]
23 brfalse l2
24 load m[4]
25 jmp l3
26l2:
27 loadi 1
28l3:
29 store m[3]
30 loadi 43
31 store m[0]
32 load m[3]
33 load m[4]
34 eqi
35 store m[4]
36 loadi 44
37 store m[0]
38 load m[0]
39 loadi 0
40 eqi
41 brtrue l4
42 load m[1]
43 loadi 0
44 eqi
45 brtrue l4
46 load m[0]
47 loadi 0
48 gei
49 load m[1]
50 loadi 0
51 gei
52 eqi
53 jmp l5
54l4:
55 loadi 0
56l5:
57 store m[5]
58l0:
59 jmp l6
60l7:
61l6:
62 jmp l7
63 loadi 45
64 store m[0]
65 jmp l8
66l9:
67l8:
68 loadi 46
69 store m[0]
70 jmp l10
71l11:
72 load m[3]
73 brfalse l12
74 load m[4]
75 jmp l13
76l12:
77 loadi 0
78l13:
79 loadi 27
80 load m[3]
81 brfalse l14
82 loadi 1
83 jmp l15
84l14:
85 load m[4]
86l15:
87 loadi 28
88 loadi 1
89 load m[5]
90 subi
91 store m[5]
92 store m[1]
93 store m[4]
94 store m[0]
95 store m[3]
96l10:
97 load m[3]
98 brfalse l16
99 load m[4]
100 brfalse l16
101 load m[5]
102 brtrue l11
103l16:
104 loadi 47
105 store m[0]
106 loadi 0
107 store m[6]
108 jmp l17
109l18:
110 load m[0]
111 loadi 1
112 subi
113 load m[0]
114 store m[1]
115 store m[0]
116 jmp l19
117l20:
118 load m[1]
119 loadi 1
120 subi
121 load m[6]
122 loadi 1
123 addi
124 store m[6]
125 store m[1]
126l19:
127 load m[1]
128 loadi 0
129 gti
130 brtrue l20
131l17:
132 load m[0]
133 loadi 0
134 gti
135 brtrue l18
136 undef
137 store m[6]
138 loadi 48
139 store m[0]
140l21:
141 jmp l21
142 loadi 49
143 store m[0]
144l22:
145 loadi 50
146 store m[0]
147l23:
148 load m[0]
149 loadi 1
150 addi
151 load m[1]
152 loadi 1
153 subi
154 store m[1]
155 store m[0]
156 load m[0]
157 load m[1]
158 gti
159 brfalse l23
160 undef
161 store m[0]
162 undef
163 store m[1]
164 undef
165 store m[2]
166 undef
167 store m[3]
168 undef
169 store m[4]
170 undef
171 store m[5]
172 terminate
173
174.data 7
|
Letzte Änderung: 14.02.2012 | © Prof. Dr. Uwe Schmidt |