https://github.com/akkartik/mu/blob/main/105string-equal.subx
1
2
3 == code
4
5
6
7
8 string-equal?:
9
10
11
12
13
14 55/push-ebp
15 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
16
17 51/push-ecx
18 56/push-esi
19 57/push-edi
20
21 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 .
22
23 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 0xc/disp8 .
24
25 8b/copy 0/mod/indirect 6/rm32/esi . . . 1/r32/ecx . .
26 $string-equal?:sizes:
27
28 39/compare 0/mod/indirect 7/rm32/edi . . . 1/r32/ecx . .
29 b8/copy-to-eax 0/imm32/false
30 75/jump-if-!= $string-equal?:end/disp8
31 $string-equal?:contents:
32
33
34 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
35 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
36
37 e8/call string-starts-with?/disp32
38
39 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
40 $string-equal?:end:
41
42 5f/pop-to-edi
43 5e/pop-to-esi
44 59/pop-to-ecx
45
46 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
47 5d/pop-to-ebp
48 c3/return
49
50 string-starts-with?:
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 55/push-ebp
72 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
73
74 51/push-ecx
75 52/push-edx
76 56/push-esi
77 57/push-edi
78
79 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 .
80
81 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 0xc/disp8 .
82
83 8b/copy 0/mod/indirect 7/rm32/edi . . . 1/r32/ecx . .
84 $string-starts-with?:sizes:
85
86 39/compare 0/mod/indirect 6/rm32/esi . . . 1/r32/ecx . .
87 7c/jump-if-< $string-starts-with?:false/disp8
88
89 81 0/subop/add 3/mod/direct 6/rm32/esi . . . . . 4/imm32
90
91 81 0/subop/add 3/mod/direct 7/rm32/edi . . . . . 4/imm32
92
93 01/add 3/mod/direct 1/rm32/ecx . . . 7/r32/edi . .
94
95 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
96
97 31/xor 3/mod/direct 2/rm32/edx . . . 2/r32/edx . .
98 $string-starts-with?:loop:
99
100 39/compare 3/mod/direct 7/rm32/edi . . . 1/r32/ecx . .
101 73/jump-if-addr>= $string-starts-with?:true/disp8
102
103 8a/copy-byte 0/mod/indirect 6/rm32/esi . . . 0/r32/AL . .
104
105 8a/copy-byte 0/mod/indirect 7/rm32/edi . . . 2/r32/DL . .
106
107 39/compare 3/mod/direct 0/rm32/eax . . . 2/r32/edx . .
108 75/jump-if-!= $string-starts-with?:false/disp8
109
110 46/increment-esi
111
112 47/increment-edi
113 eb/jump $string-starts-with?:loop/disp8
114 $string-starts-with?:true:
115 b8/copy-to-eax 1/imm32
116 eb/jump $string-starts-with?:end/disp8
117 $string-starts-with?:false:
118 b8/copy-to-eax 0/imm32
119 $string-starts-with?:end:
120
121 5f/pop-to-edi
122 5e/pop-to-esi
123 5a/pop-to-edx
124 59/pop-to-ecx
125
126 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
127 5d/pop-to-ebp
128 c3/return
129
130
131
132 test-compare-empty-with-empty-string:
133
134
135 68/push ""/imm32
136 68/push ""/imm32
137
138 e8/call 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-empty-with-empty-string"/imm32
144 68/push 1/imm32/true
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-empty-with-non-empty-string:
153
154
155 68/push "Abc"/imm32
156 68/push ""/imm32
157
158 e8/call 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-empty-with-non-empty-string"/imm32
164 68/push 0/imm32/false
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-equal-strings:
173
174
175 68/push "Abc"/imm32
176 68/push "Abc"/imm32
177
178 e8/call 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-equal-strings"/imm32
184 68/push 1/imm32/true
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-inequal-strings-equal-sizes:
193
194
195 68/push "Adc"/imm32
196 68/push "Abc"/imm32
197
198 e8/call 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-inequal-strings-equal-sizes"/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
213 check-strings-equal:
214
215 55/push-ebp
216 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
217
218 50/push-eax
219
220
221 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
222 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
223
224 e8/call string-equal?/disp32
225
226 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
227
228
229 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x10/disp8 .
230 68/push 1/imm32
231 50/push-eax
232
233 e8/call check-ints-equal/disp32
234
235 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
236 $check-strings-equal:end:
237
238 58/pop-to-eax
239
240 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
241 5d/pop-to-ebp
242 c3/return
243
244
245 test-check-strings-equal:
246
247
restack();
extern void settags(Client *c);
extern void tag(Arg *arg);
extern void togglemode(Arg *arg);
extern void toggletag(Arg *