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
27 cd/syscall 0x80/imm8
28
29
30
31 kernel-string-equal:
32
33 55/push-EBP
34 89/copy 3/mod/direct 5/rm32/EBP 4/r32/ESP
35
36 51/push-ECX
37 52/push-EDX
38 53/push-EBX
39 56/push-ESI
40 57/push-EDI
41
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 3d/compare-EAX 0/imm32
92 75/jump-if-not-equal $kernel-string-equal:false/disp8
93 $kernel-string-equal:true:
94 b8/copy-to-EAX 1/imm32
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 == data
255
256 Null-kernel-string:
257 00/null
258 Abc-kernel-string:
259 41/A 62/b 63/c 00/null
260
261