1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 == code
18
19
20
21
22
23
24 e8/call run-tests/disp32
25
26 89/copy 3/mod/direct 3/rm32/EBX . . . 0/r32/EAX . .
27 b8/copy-to-EAX 1/imm32
28 cd/syscall 0x80/imm8
29
30
31
32 kernel-string-equal:
33
34 55/push-EBP
35 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
36
37 51/push-ECX
38 52/push-EDX
39 53/push-EBX
40 56/push-ESI
41 57/push-EDI
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 7/r32/EDI 8/disp8 .
58
59 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 2/r32/EDX 0xc/disp8 .
60 8b/copy 0/mod/indirect 2/rm32/EDX . . . 2/r32/EDX . .
61
62 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 6/r32/ESI 0xc/disp8 .
63 81 0/subop/add 3/mod/direct 6/rm32/ESI . . . . . 4/imm32
64
65 b9/copy-to-ECX 0/imm32/exit
66
67 $kernel-string-equal:loop:
68 39/compare 3/mod/direct 1/rm32/ECX . . . 2/r32/EDX . .
69 74/jump-if-equal $kernel-string-equal:break/disp8
70
71 b8/copy-to-EAX 0/imm32
72 8a/copy 0/mod/indirect 7/rm32/EDI . . . 0/r32/EAX . .
73 bb/copy-to-EBX 0/imm32
74 8a/copy 0/mod/indirect 6/rm32/ESI . . . 3/r32/EBX . .
75
76 3d/compare-EAX 0/imm32
77 74/jump-if-equal $kernel-string-equal:false/disp8
78
79 39/compare 3/mod/direct 0/rm32/EAX . . . 3/r32/EBX . .
80 75/jump-if-not-equal $kernel-string-equal:false/disp8
81
82 41/inc-ECX
83 46/inc-ESI
84 47/inc-EDI
85
86 eb/jump $kernel-string-equal:loop/disp8
87 $kernel-string-equal:break:
88
89 b8/copy-to-EAX 0/imm32
90 8a/copy 0/mod/indirect 7/rm32/EDI . . . 0/r32/EAX . .
91 81 7/subop/compare 3/mod/direct 0/rm32/EAX . . . . . 0/imm32
92 75/jump-if-not-equal $kernel-string-equal:false/disp8
93 b8/copy-to-EAX 1/imm32
94 $kernel-string-equal:true:
95 eb/jump $kernel-string-equal:end/disp8
96
97 $kernel-string-equal:false:
98 b8/copy-to-EAX 0/imm32
99
100 $kernel-string-equal:end:
101
102 5f/pop-to-EDI
103 5e/pop-to-ESI
104 5b/pop-to-EBX
105 5a/pop-to-EDX
106 59/pop-to-ECX
107
108 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
109 5d/pop-to-EBP
110 c3/return
111
112
113
114 test-compare-null-kernel-string-with-empty-array:
115
116
117 68/push ""/imm32
118 68/push Null-kernel-string/imm32
119
120 e8/call kernel-string-equal/disp32
121
122 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
123
124
125 68/push "F - test-compare-null-kernel-string-with-empty-array"/imm32
126 68/push 1/imm32/true
127 50/push-EAX
128
129 e8/call check-ints-equal/disp32
130
131 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
132 c3/return
133
134 test-compare-null-kernel-string-with-non-empty-array:
135
136
137 68/push "Abc"/imm32
138 68/push Null-kernel-string/imm32
139
140 e8/call kernel-string-equal/disp32
141
142 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
143
144
145 68/push "F - test-compare-null-kernel-string-with-non-empty-array"/imm32
146 68/push 0/imm32/false
147 50/push-EAX
148
149 e8/call check-ints-equal/disp32
150
151 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
152 c3/return
153
154 test-compare-kernel-string-with-equal-array:
155
156
157 68/push "Abc"/imm32
158 68/push Abc-kernel-string/imm32
159
160 e8/call kernel-string-equal/disp32
161
162 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
163
164
165 68/push "F - test-compare-kernel-string-with-equal-array"/imm32
166 68/push 1/imm32/true
167 50/push-EAX
168
169 e8/call check-ints-equal/disp32
170
171 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
172 c3/return
173
174 test-compare-kernel-string-with-inequal-array:
175
176
177 68/push "Adc"/imm32
178 68/push Abc-kernel-string/imm32
179
180 e8/call kernel-string-equal/disp32
181
182 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
183
184
185 68/push "F - test-compare-kernel-string-with-equal-array"/imm32
186 68/push 0/imm32/false
187 50/push-EAX
188
189 e8/call check-ints-equal/disp32
190
191 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
192 c3/return
193
194 test-compare-kernel-string-with-empty-array:
195
196
197 68/push ""/imm32
198 68/push Abc-kernel-string/imm32
199
200 e8/call kernel-string-equal/disp32
201
202 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
203
204
205 68/push "F - test-compare-kernel-string-with-equal-array"/imm32
206 68/push 0/imm32/false
207 50/push-EAX
208
209 e8/call check-ints-equal/disp32
210
211 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
212 c3/return
213
214 test-compare-kernel-string-with-shorter-array:
215
216
217 68/push "Ab"/imm32
218 68/push Abc-kernel-string/imm32
219
220 e8/call kernel-string-equal/disp32
221
222 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
223
224
225 68/push "F - test-compare-kernel-string-with-shorter-array"/imm32
226 68/push 0/imm32/false
227 50/push-EAX
228
229 e8/call check-ints-equal/disp32
230
231 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
232 c3/return
233
234 test-compare-kernel-string-with-longer-array:
235
236
237 68/push "Abcd"/imm32
238 68/push Abc-kernel-string/imm32
239
240 e8/call kernel-string-equal/disp32
241
242 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
243
244
245 68/push "F - test-compare-kernel-string-with-longer-array"/imm32
246 68/push 0/imm32/false
247 50/push-EAX
248
249 e8/call check-ints-equal/disp32
250
251 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
252 c3/return
253
254
255
256
257 check-ints-equal:
258
259 55/push-EBP
260 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
261
262 51/push-ECX
263 53/push-EBX
264
265 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 0/r32/EAX 0x8/disp8 .
266 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 3/r32/EBX 0xc/disp8 .
267
268 39/compare 3/mod/direct 0/rm32/EAX . . . 3/r32/EBX . .
269 75/jump-if-unequal $check-ints-equal:else/disp8
270
271
272 68/push "."/imm32
273
274 e8/call write-stderr/disp32
275
276 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
277
278 eb/jump $check-ints-equal:end/disp8
279
280 $check-ints-equal:else:
281
282 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 1/r32/ECX 0x10/disp8 .
283
284
285 51/push-ECX
286
287 e8/call write-stderr/disp32
288
289 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
290
291
292 68/push Newline/imm32
293
294 e8/call write-stderr/disp32
295
296 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
297 $check-ints-equal:end:
298
299 5b/pop-to-EBX
300 59/pop-to-ECX
301
302 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
303 5d/pop-to-EBP
304 c3/return
305
306 write-stderr:
307
308 55/push-EBP
309 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
310
311 50/push-EAX
312 51/push-ECX
313 52/push-EDX
314 53/push-EBX
315
316
317 bb/copy-to-EBX 2/imm32
318
319 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 1/r32/ECX 8/disp8 .
320 81 0/subop/add 3/mod/direct 1/rm32/ECX . . . . . 4/imm32
321
322 8b/copy 1/mod/*+disp8 4/rm32/sib 5/base/EBP 4/index/none . 2/r32/EDX 8/disp8 .
323 8b/copy 0/mod/indirect 2/rm32/EDX . . . 2/r32/EDX . .
324
325 b8/copy-to-EAX 4/imm32/write
326 cd/syscall 0x80/imm8
327
328 5b/pop-to-EBX
329 5a/pop-to-EDX
330 59/pop-to-ECX
331 58/pop-to-EAX
332
333 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
334 5d/pop-to-EBP
335 c3/return
336
337 == data
338 Newline:
339
340 01 00 00 00
341
342 0a/newline
343
344
345 Null-kernel-string:
346 00/null
347 Abc-kernel-string:
348 41/A 62/b 63/c 00/null
349
350