https://github.com/akkartik/mu/blob/master/052kernel-string-equal.subx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 == code
20
21
22
23
24 Entry:
25 e8/call run-tests/disp32
26
27 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32
28 b8/copy-to-eax 1/imm32/exit
29 cd/syscall 0x80/imm8
30
31
32
33 kernel-string-equal?:
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 55/push-ebp
57 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
58
59 51/push-ecx
60 52/push-edx
61 53/push-ebx
62 56/push-esi
63 57/push-edi
64
65 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 .
66
67 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 2/r32/edx 0xc/disp8 .
68 8b/copy 0/mod/indirect 2/rm32/edx . . . 2/r32/edx . .
69
70 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 0xc/disp8 .
71 81 0/subop/add 3/mod/direct 6/rm32/esi . . . . . 4/imm32
72
73 b9/copy-to-ecx 0/imm32/exit
74
75 b8/copy-to-eax 0/imm32
76
77 bb/copy-to-ebx 0/imm32
78 $kernel-string-equal?:loop:
79
80 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . .
81 7d/jump-if->= $kernel-string-equal?:break/disp8
82
83 8a/copy-byte 0/mod/indirect 7/rm32/edi . . . 0/r32/AL . .
84
85 8a/copy-byte 0/mod/indirect 6/rm32/esi . . . 3/r32/BL . .
86
87 3d/compare-eax-and 0/imm32/null
88 74/jump-if-= $kernel-string-equal?:false/disp8
89
90 39/compare 3/mod/direct 0/rm32/eax . . . 3/r32/ebx . .
91 75/jump-if-!= $kernel-string-equal?:false/disp8
92
93 41/increment-ecx
94
95 47/increment-edi
96
97 46/increment-esi
98 eb/jump $kernel-string-equal?:loop/disp8
99 $kernel-string-equal?:break:
100
101 8a/copy-byte 0/mod/indirect 7/rm32/edi . . . 0/r32/AL . .
102 3d/compare-eax-and 0/imm32/null
103 75/jump-if-!= $kernel-string-equal?:false/disp8
104 $kernel-string-equal?:true:
105 b8/copy-to-eax 1/imm32
106 eb/jump $kernel-string-equal?:end/disp8
107 $kernel-string-equal?:false:
108 b8/copy-to-eax 0/imm32
109 $kernel-string-equal?:end:
110
111 5f/pop-to-edi
112 5e/pop-to-esi
113 5b/pop-to-ebx
114 5a/pop-to-edx
115 59/pop-to-ecx
116
117 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
118 5d/pop-to-ebp
119 c3/return
120
121
122
123 test-compare-null-kernel-string-with-empty-array:
124
125
126 68/push ""/imm32
127 68/push Null-kernel-string/imm32
128
129 e8/call kernel-string-equal?/disp32
130
131 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
132
133
134 68/push "F - test-compare-null-kernel-string-with-empty-array"/imm32
135 68/push 1/imm32/true
136 50/push-eax
137
138 e8/call check-ints-equal/disp32
139
140 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
141 c3/return
142
143 test-compare-null-kernel-string-with-non-empty-array:
144
145
146 68/push "Abc"/imm32
147 68/push Null-kernel-string/imm32
148
149 e8/call kernel-string-equal?/disp32
150
151 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
152
153
154 68/push "F - test-compare-null-kernel-string-with-non-empty-array"/imm32
155 68/push 0/imm32/false
156 50/push-eax
157
158 e8/call check-ints-equal/disp32
159
160 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
161 c3/return
162
163 test-compare-kernel-string-with-equal-array:
164
165
166 68/push "Abc"/imm32
167 68/push _test-Abc-kernel-string/imm32
168
169 e8/call kernel-string-equal?/disp32
170
171 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
172
173
174 68/push "F - test-compare-kernel-string-with-equal-array"/imm32
175 68/push 1/imm32/true
176 50/push-eax
177
178 e8/call check-ints-equal/disp32
179
180 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
181 c3/return
182
183 test-compare-kernel-string-with-inequal-array:
184
185
186 68/push "Adc"/imm32
187 68/push _test-Abc-kernel-string/imm32
188
189 e8/call kernel-string-equal?/disp32
190
191 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
192
193
194 68/push "F - test-compare-kernel-string-with-equal-array"/imm32
195 68/push 0/imm32/false
196 50/push-eax
197
198 e8/call check-ints-equal/disp32
199
200 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
201 c3/return
202
203 test-compare-kernel-string-with-empty-array:
204
205
206 68/push ""/imm32
207 68/push _test-Abc-kernel-string/imm32
208
209 e8/call kernel-string-equal?/disp32
210
211 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
212
213
214 68/push "F - test-compare-kernel-string-with-equal-array"/imm32
215 68/push 0/imm32/false
216 50/push-eax
217
218 e8/call check-ints-equal/disp32
219
220 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
221 c3/return
222
223 test-compare-kernel-string-with-shorter-array:
224
225
226 68/push "Ab"/imm32
227 68/push _test-Abc-kernel-string/imm32
228
229 e8/call kernel-string-equal?/disp32
230
231 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
232
233
234 68/push "F - test-compare-kernel-string-with-shorter-array"/imm32
235 68/push 0/imm32/false
236 50/push-eax
237
238 e8/call check-ints-equal/disp32
239
240 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
241 c3/return
242
243 test-compare-kernel-string-with-longer-array:
244
245
246 68/push "Abcd"/imm32
247 68/push _test-Abc-kernel-string/imm32
248
249 e8/call kernel-string-equal?/disp32
250
251 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
252
253
254 68/push "F - test-compare-kernel-string-with-longer-array"/imm32
255 68/push 0/imm32/false
256 50/push-eax
257
258 e8/call check-ints-equal/disp32
259
260 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
261 c3/return
262
263 == data
264
265 Null-kernel-string:
266 00/null
267
268 _test-Abc-kernel-string:
269 41/A 62/b 63/c 00/null
270
271