https://github.com/akkartik/mu/blob/master/subx/072slice.subx
1
2
3
4 == code
5
6
7
8
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 b8/copy-to-EAX 1/imm32/exit
14 cd/syscall 0x80/imm8
15
16 slice-empty?:
17
18 55/push-EBP
19 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
20
21 51/push-ECX
22
23 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 1/r32/ECX 8/disp8 .
24
25
26 8b/copy 0/mod/indirect 1/rm32/ECX . . . 0/r32/EAX . .
27
28 39/compare 1/mod/*+disp8 1/rm32/ECX . . . 0/r32/EAX 4/disp8 .
29 b8/copy-to-EAX 1/imm32/true
30 74/jump-if-equal $slice-empty?:end/disp8
31 b8/copy-to-EAX 0/imm32/false
32 $slice-empty?:end:
33
34 59/pop-to-ECX
35
36 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
37 5d/pop-to-EBP
38 c3/return
39
40 test-slice-empty-true:
41
42 55/push-EBP
43 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
44
45 68/push 34/imm32/end
46 68/push 34/imm32/start
47 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
48
49
50 51/push-ECX
51
52 e8/call slice-empty?/disp32
53
54 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
55
56
57 68/push "F - test-slice-empty-true"/imm32
58 68/push 1/imm32
59 50/push-EAX
60
61 e8/call check-ints-equal/disp32
62
63 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
64
65 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
66 5d/pop-to-EBP
67 c3/return
68
69 test-slice-empty-false:
70
71 55/push-EBP
72 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
73
74 68/push 23/imm32/end
75 68/push 34/imm32/start
76 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
77
78
79 51/push-ECX
80
81 e8/call slice-empty?/disp32
82
83 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
84
85
86 68/push "F - test-slice-empty-false"/imm32
87 68/push 0/imm32
88 50/push-EAX
89
90 e8/call check-ints-equal/disp32
91
92 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
93
94 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
95 5d/pop-to-EBP
96 c3/return
97
98 slice-equal?:
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118 55/push-EBP
119 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
120
121 51/push-ECX
122 52/push-EDX
123 53/push-EBX
124 56/push-ESI
125
126 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 8/disp8 .
127
128 8b/copy 0/mod/indirect 6/rm32/ESI . . . 2/r32/EDX . .
129
130 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 6/r32/ESI 4/disp8 .
131
132 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 3/r32/EBX 0xc/disp8 .
133
134 89/copy 3/mod/direct 0/rm32/EAX . . . 6/r32/ESI . .
135 29/subtract 3/mod/direct 0/rm32/EAX . . . 2/r32/EDX . .
136
137 39/compare 0/mod/indirect 3/rm32/EBX . . . 0/r32/EAX . .
138 75/jump-if-not-equal $slice-equal?:false/disp8
139
140 81 0/subop/add 3/mod/direct 3/rm32/EBX . . . . . 4/imm32
141
142 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
143 31/xor 3/mod/direct 1/rm32/ECX . . . 1/r32/ECX . .
144 $slice-equal?:loop:
145
146 39/compare 3/mod/direct 2/rm32/EDX . . . 6/r32/ESI . .
147 7d/jump-if-greater-or-equal $slice-equal?:true/disp8
148
149 8a/copy-byte 0/mod/indirect 3/rm32/EBX . . . 0/r32/AL . .
150
151 8a/copy-byte 0/mod/indirect 2/rm32/EDX . . . 1/r32/CL . .
152
153 39/compare 3/mod/direct 0/rm32/EAX . . . 1/r32/ECX . .
154 75/jump-if-not-equal $slice-equal?:false/disp8
155
156 43/increment-EBX
157
158 42/increment-EDX
159 eb/jump $slice-equal?:loop/disp8
160 $slice-equal?:false:
161 b8/copy-to-EAX 0/imm32
162 eb/jump $slice-equal?:end/disp8
163 $slice-equal?:true:
164 b8/copy-to-EAX 1/imm32
165 $slice-equal?:end:
166
167 5e/pop-to-ESI
168 5b/pop-to-EBX
169 5a/pop-to-EDX
170 59/pop-to-ECX
171
172 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
173 5d/pop-to-EBP
174 c3/return
175
176 test-slice-equal:
177
178
179 55/push-EBP
180 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
181
182 68/push _test-slice-data-3/imm32/end
183 68/push _test-slice-data-0/imm32/start
184 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
185
186
187 68/push "Abc"/imm32
188 51/push-ECX
189
190 e8/call slice-equal?/disp32
191
192 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
193
194
195 68/push "F - test-slice-equal"/imm32
196 68/push 1/imm32
197 50/push-EAX
198
199 e8/call check-ints-equal/disp32
200
201 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
202
203 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
204 5d/pop-to-EBP
205 c3/return
206
207 test-slice-equal-false:
208
209
210 55/push-EBP
211 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
212
213 68/push _test-slice-data-4/imm32/end
214 68/push _test-slice-data-1/imm32/start
215 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
216
217
218 68/push "Abc"/imm32
219 51/push-ECX
220
221 e8/call slice-equal?/disp32
222
223 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
224
225
226 68/push "F - test-slice-equal-false"/imm32
227 68/push 0/imm32
228 50/push-EAX
229
230 e8/call check-ints-equal/disp32
231
232 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
233
234 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
235 5d/pop-to-EBP
236 c3/return
237
238 test-slice-equal-too-long:
239
240
241 55/push-EBP
242 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
243
244 68/push _test-slice-data-4/imm32/end
245 68/push _test-slice-data-0/imm32/start
246 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
247
248
249 68/push "Abc"/imm32
250 51/push-ECX
251
252 e8/call slice-equal?/disp32
253
254 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
255
256
257 68/push "F - test-slice-equal-too-long"/imm32
258 68/push 0/imm32
259 50/push-EAX
260
261 e8/call check-ints-equal/disp32
262
263 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
264
265 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
266 5d/pop-to-EBP
267 c3/return
268
269 test-slice-equal-too-short:
270
271
272 55/push-EBP
273 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
274
275 68/push _test-slice-data-1/imm32/end
276 68/push _test-slice-data-0/imm32/start
277 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
278
279
280 68/push "Abc"/imm32
281 51/push-ECX
282
283 e8/call slice-equal?/disp32
284
285 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
286
287
288 68/push "F - test-slice-equal-too-short"/imm32
289 68/push 0/imm32
290 50/push-EAX
291
292 e8/call check-ints-equal/disp32
293
294 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
295
296 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
297 5d/pop-to-EBP
298 c3/return
299
300 test-slice-equal-empty:
301
302
303 55/push-EBP
304 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
305
306 68/push _test-slice-data-0/imm32/end
307 68/push _test-slice-data-0/imm32/start
308 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
309
310
311 68/push "Abc"/imm32
312 51/push-ECX
313
314 e8/call slice-equal?/disp32
315
316 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
317
318
319 68/push "F - test-slice-equal-empty"/imm32
320 68/push 0/imm32
321 50/push-EAX
322
323 e8/call check-ints-equal/disp32
324
325 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
326
327 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
328 5d/pop-to-EBP
329 c3/return
330
331 test-slice-equal-with-empty:
332
333
334 55/push-EBP
335 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
336
337 68/push _test-slice-data-2/imm32/end
338 68/push _test-slice-data-0/imm32/start
339 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
340
341
342 68/push ""/imm32
343 51/push-ECX
344
345 e8/call slice-equal?/disp32
346
347 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
348
349
350 68/push "F - test-slice-equal-with-empty"/imm32
351 68/push 0/imm32
352 50/push-EAX
353
354 e8/call check-ints-equal/disp32
355
356 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
357
358 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
359 5d/pop-to-EBP
360 c3/return
361
362 test-slice-equal-empty-with-empty:
363
364
365 55/push-EBP
366 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
367
368 68/push _test-slice-data-0/imm32/end
369 68/push _test-slice-data-0/imm32/start
370 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
371
372
373 68/push ""/imm32
374 51/push-ECX
375
376 e8/call slice-equal?/disp32
377
378 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
379
380
381 68/push "F - test-slice-equal-empty-with-empty"/imm32
382 68/push 1/imm32
383 50/push-EAX
384
385 e8/call check-ints-equal/disp32
386
387 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
388
389 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
390 5d/pop-to-EBP
391 c3/return
392
393 write-slice:
394
395 55/push-EBP
396 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
397
398 50/push-EAX
399 51/push-ECX
400 52/push-EDX
401 53/push-EBX
402 56/push-ESI
403 57/push-EDI
404
405 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 0xc/disp8 .
406
407 8b/copy 0/mod/indirect 6/rm32/ESI . . . 1/r32/ECX . .
408
409 8b/copy 1/mod/*+disp8 6/rm32/ESI . . . 6/r32/ESI 4/disp8 .
410
411 8b/copy 1/mod/*+disp8 5/rm32/EBP . . 7/r32/EDI 8/disp8 .
412
413 8b/copy 1/mod/*+disp8 7/rm32/EDI . . . 2/r32/EDX 0xc/disp8 .
414
415 8b/copy 1/mod/*+disp8 7/rm32/EDI . . . 3/r32/EBX 4/disp8 .
416 $write-slice:loop:
417
418 39/compare 3/mod/direct 1/rm32/ECX . . . 6/r32/ESI . .
419 7d/jump-if-greater-or-equal $write-slice:loop-end/disp8
420
421 39/compare 3/mod/direct 3/rm32/EBX . . . 2/r32/EDX . .
422 7c/jump-if-lesser $write-slice:to-stream/disp8
423
424 89/copy 1/mod/*+disp8 7/rm32/EDI . . . 3/r32/EBX 4/disp8 .
425
426
427 57/push-EDI
428
429 e8/call flush/disp32
430
431 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
432
433
434 8d/copy-address 1/mod/*+disp8 7/rm32/EDI . . . 0/r32/EAX 4/disp8 .
435 50/push-EAX
436
437 e8/call clear-stream/disp32
438
439 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
440
441 31/xor 3/mod/direct 3/rm32/EBX . . . 3/r32/EBX . .
442 $write-slice:to-stream:
443
444
445 31/xor 3/mod/direct 0/rm32/EAX . . . 0/r32/EAX . .
446 8a/copy-byte 0/mod/indirect 1/rm32/ECX . . . 0/r32/AL . .
447
448 88/copy-byte 1/mod/*+disp8 4/rm32/sib 7/base/EDI 3/index/EBX . 0/r32/AL 0x10/disp8 .
449
450 43/increment-EBX
451
452 41/increment-ECX
453 eb/jump $write-slice:loop/disp8
454 $write-slice:loop-end:
455
456 89/copy 1/mod/*+disp8 7/rm32/EDI . . . 3/r32/EBX 4/disp8 .
457 $write-slice:end:
458
459 5f/pop-to-EDI
460 5e/pop-to-ESI
461 5b/pop-to-EBX
462 5a/pop-to-EDX
463 59/pop-to-ECX
464 58/pop-to-EAX
465
466 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
467 5d/pop-to-EBP
468 c3/return
469
470 test-write-slice:
471
472 55/push-EBP
473 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
474
475
476
477 68/push _test-stream/imm32
478
479 e8/call clear-stream/disp32
480
481 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
482
483
484 b8/copy-to-EAX _test-buffered-file/imm32
485 05/add-to-EAX 4/imm32
486 50/push-EAX
487
488 e8/call clear-stream/disp32
489
490 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
491
492 68/push _test-slice-data-3/imm32/end
493 68/push _test-slice-data-0/imm32/start
494 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
495
496
497 51/push-ECX
498 68/push _test-buffered-file/imm32
499
500 e8/call write-slice/disp32
501
502 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
503
504
505 68/push _test-buffered-file/imm32
506
507 e8/call flush/disp32
508
509 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
510
511
512 68/push "F - test-write-slice"/imm32
513 68/push "Abc"/imm32
514 68/push _test-stream/imm32
515
516 e8/call check-stream-equal/disp32
517
518 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
519
520 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
521 5d/pop-to-EBP
522 c3/return
523
524
525
526
527
528
529 write-stream-buffered:
530
531 55/push-EBP
532 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
533
534 50/push-EAX
535 56/push-ESI
536
537 8b/copy 1/mod/*+disp8 5/rm32/EBP . . . 6/r32/ESI 0xc/disp8 .
538
539
540 8b/copy 0/mod/indirect 6/rm32/ESI . . . 0/r32/EAX . .
541 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/ESI 0/index/EAX . 0/r32/EAX 0xc/disp8 .
542 50/push-EAX
543
544 8d/copy-address 1/mod/*+disp8 6/rm32/ESI . . . 0/r32/EAX 0xc/disp8 .
545 50/push-EAX
546
547 89/copy 3/mod/direct 1/rm32/ECX . . . 4/r32/ESP . .
548
549
550 51/push-ECX
551 ff 6/subop/push 1/mod/*+disp8 5/rm32/EBP . . . . 8/disp8 .
552
553 e8/call write-slice/disp32
554
555 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
556 $write-stream-buffered:end:
557
558 5e/pop-to-ESI
559 58/pop-to-EAX
560
561 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
562 5d/pop-to-EBP
563 c3/return
564
565 test-write-stream-buffered:
566
567 55/push-EBP
568 89/copy 3/mod/direct 5/rm32/EBP . . . 4/r32/ESP . .
569
570
571
572 68/push _test-stream/imm32
573
574 e8/call clear-stream/disp32
575
576 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
577
578
579 b8/copy-to-EAX _test-buffered-file/imm32
580 05/add-to-EAX 4/imm32
581 50/push-EAX
582
583 e8/call clear-stream/disp32
584
585 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
586
587
588 68/push _test-tmp-stream/imm32
589
590 e8/call clear-stream/disp32
591
592 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
593
594
595
596 68/push "abcd"/imm32
597 68/push _test-tmp-stream/imm32
598
599 e8/call write/disp32
600
601 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
602
603
604
605 68/push _test-tmp-stream/imm32
606 68/push _test-buffered-file/imm32
607
608 e8/call write-stream-buffered/disp32
609
610 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 8/imm32
611
612
613
614 68/push _test-buffered-file/imm32
615
616 e8/call flush/disp32
617
618 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 4/imm32
619
620
621 68/push "F - test-write-stream-buffered"/imm32
622 68/push "abcd"/imm32
623 68/push _test-stream/imm32
624
625 e8/call check-stream-equal/disp32
626
627 81 0/subop/add 3/mod/direct 4/rm32/ESP . . . . . 0xc/imm32
628
629 89/copy 3/mod/direct 4/rm32/ESP . . . 5/r32/EBP . .
630 5d/pop-to-EBP
631 c3/return
632
633 == data
634
635 _test-slice-data-0:
636 41/A
637 _test-slice-data-1:
638 62/b
639 _test-slice-data-2:
640 63/c
641 _test-slice-data-3:
642 64/d
643 _test-slice-data-4:
644
645