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