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