https://github.com/akkartik/mu/blob/master/apps/tests.subx
1
2
3
4 == code
5
6
7
8
9 Entry:
10
11
12 68/push Heap/imm32
13 68/push Heap-size/imm32
14
15 e8/call new-segment/disp32
16
17 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
18
19
20 68/push 0x40000/imm32/256KB
21
22 e8/call initialize-trace-stream/disp32
23
24 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
25
26
27
28 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
29
30
31
32 81 7/subop/compare 1/mod/*+disp8 5/rm32/EBP . . . . 0/disp8 1/imm32
33 7e/jump-if-lesser-or-equal $run-main/disp8
34
35
36 68/push "test"/imm32
37 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
38
39 e8/call kernel-string-equal?/disp32
40
41 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
42
43 3d/compare-EAX-and 1/imm32
44 75/jump-if-not-equal $run-main/disp8
45
46 e8/call run-tests/disp32
47 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/EBX Num-test-failures/disp32
48 eb/jump $main:end/disp8
49 $run-main:
50
51
52
53 68/push Stdout/imm32
54 68/push Stdin/imm32
55
56 e8/call convert/disp32
57
58 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
59
60 bb/copy-to-EBX 0/imm32
61 $main:end:
62 b8/copy-to-EAX 1/imm32/exit
63 cd/syscall 0x80/imm8
64
65 convert:
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91 55/push-EBP
92 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
93
94 50/push-EAX
95 51/push-ECX
96 52/push-EDX
97 53/push-EBX
98 57/push-EDI
99
100 81 5/subop/subtract 3/mod/direct 4/rm32/ESP . . . . . 0x200/imm32
101 68/push 0x200/imm32/length
102 68/push 0/imm32/read
103 68/push 0/imm32/write
104 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
105
106 68/push 0/imm32/end
107 68/push 0/imm32/start
108 89/copy 3/mod/direct 2/rm32/EDX . . . 4/r32/ESP . .
109
110 31/xor 3/mod/direct 3/rm32/EBX . . . 3/r32/EBX . .
111
112
113
114 68/push 1/imm32
115 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Segment-size/disp32
116 68/push Heap/imm32
117
118 e8/call new-stream/disp32
119
120 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
121
122 89/copy 3/mod/direct 7/rm32/EDI . . . 0/r32/EAX . .
123
124
125 68/push "\n== code\n"/imm32
126 57/push-EDI
127
128 e8/call write/disp32
129
130 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
131
132
133 68/push "run-tests:\n"/imm32
134 57/push-EDI
135
136 e8/call write/disp32
137
138 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
139 $convert:loop:
140
141
142 51/push-ECX
143
144 e8/call clear-stream/disp32
145
146 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
147
148
149 51/push-ECX
150 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
151
152 e8/call read-line-buffered/disp32
153
154 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
155 $convert:check0:
156
157 81 7/subop/compare 0/mod/indirect 1/rm32/ECX . . . . . 0/imm32
158 0f 84/jump-if-equal $convert:break/disp32
159
160
161 52/push-EDX
162 51/push-ECX
163
164 e8/call next-word/disp32
165
166 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
167 $convert:check-for-label:
168
169
170
171 52/push-EDX
172
173 e8/call is-label?/disp32
174
175 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
176
177 3d/compare-EAX-and 0/imm32
178 74/jump-if-equal $convert:continue/disp8
179 $convert:check-label-prefix:
180
181 ff 1/subop/decrement 1/mod/*+disp8 2/rm32/EDX . . . . 4/disp8 .
182
183
184 68/push "test-"/imm32
185 52/push-EDX
186
187 e8/call slice-starts-with?/disp32
188
189 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
190
191 3d/compare-EAX-and 0/imm32
192 74/jump-if-equal $convert:continue/disp8
193 $convert:call-test-function:
194
195 bb/copy-to-EBX 1/imm32/true
196
197
198 68/push " e8/call "/imm32
199 57/push-EDI
200
201 e8/call write/disp32
202
203 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
204
205
206 52/push-EDX
207 57/push-EDI
208
209 e8/call write-slice/disp32
210
211 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
212
213
214 68/push "/disp32\n"/imm32
215 57/push-EDI
216
217 e8/call write/disp32
218
219 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
220 $convert:continue:
221
222
223 51/push-ECX
224
225 e8/call rewind-stream/disp32
226
227 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
228
229
230 51/push-ECX
231 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
232
233 e8/call write-stream-data/disp32
234
235 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
236
237 e9/jump $convert:loop/disp32
238 $convert:break:
239
240 81 7/subop/compare 3/mod/direct 3/rm32/EBX . . . . . 0/imm32
241 74/jump-if-equal $convert:end/disp8
242
243
244 68/push " c3/return\n"/imm32
245 57/push-EDI
246
247 e8/call write/disp32
248
249 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
250
251
252 57/push-EDI
253 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
254
255 e8/call write-stream-data/disp32
256
257 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
258 $convert:end:
259
260
261 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 0xc/disp8 .
262
263 e8/call flush/disp32
264
265 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
266
267 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0x214/imm32
268
269 5f/pop-to-EDI
270 5b/pop-to-EBX
271 5a/pop-to-EDX
272 59/pop-to-ECX
273 58/pop-to-EAX
274
275 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
276 5d/pop-to-EBP
277 c3/return
278
279