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