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