https://github.com/akkartik/mu/blob/master/069allocate.subx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 == data
20
21
22
23 Handle-size:
24 8/imm32
25
26
27 Heap:
28
29 0/imm32
30
31 0/imm32
32
33
34 Heap-size:
35 0x600000/imm32/6MB
36
37 Next-alloc-id:
38 0x100/imm32
39
40 == code
41
42
43
44
45
46
47 Entry:
48
49
50
51 68/push Heap/imm32
52 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Heap-size/disp32
53
54 e8/call new-segment/disp32
55
56 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
57
58 e8/call run-tests/disp32
59 $array-equal-main:end:
60
61 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 3/r32/ebx Num-test-failures/disp32
62 b8/copy-to-eax 1/imm32/exit
63 cd/syscall 0x80/imm8
64
65
66
67 allocate:
68
69 55/push-ebp
70 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
71
72 50/push-eax
73
74
75 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x10/disp8 .
76 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
77 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
78
79 e8/call allocate-raw/disp32
80
81 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
82
83 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 0x10/disp8 .
84 8b/copy 1/mod/*+disp8 0/rm32/eax . . . 0/r32/eax 4/disp8 .
85 05/add-to-eax 4/imm32
86
87
88 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
89 50/push-eax
90
91 e8/call zero-out/disp32
92
93 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
94 $allocate:end:
95
96 58/pop-to-eax
97
98 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
99 5d/pop-to-ebp
100 c3/return
101
102
103
104 allocate-raw:
105
106 55/push-ebp
107 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
108
109 50/push-eax
110 51/push-ecx
111 52/push-edx
112 53/push-ebx
113 56/push-esi
114 57/push-edi
115
116 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 .
117
118 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 2/r32/edx 0x10/disp8 .
119
120 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 3/r32/ebx 0xc/disp8 .
121
122 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 0/r32/eax Next-alloc-id/disp32
123 89/copy 0/mod/indirect 2/rm32/edx . . . 0/r32/eax . .
124
125 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
126 $allocate-raw:save-payload-in-eax:
127 89/copy 1/mod/*+disp8 2/rm32/edx . . . 0/r32/eax 4/disp8 .
128
129 8b/copy 1/mod/*+disp8 2/rm32/edx . . . 7/r32/edi 4/disp8 .
130 8b/copy 0/mod/indirect 5/rm32/.disp32 . . 6/r32/esi Next-alloc-id/disp32
131 89/copy 0/mod/indirect 7/rm32/edi . . . 6/r32/esi . .
132 $allocate-raw:increment-next-alloc-id:
133
134 ff 0/subop/increment 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32
135
136
137 8d/copy-address 1/mod/*+disp8 4/rm32/sib 0/base/eax 3/index/ebx . 0/r32/eax 4/disp8 .
138 3b/compare 1/mod/*+disp8 1/rm32/ecx . . . 0/r32/eax 4/disp8 .
139 73/jump-if->=-signed $allocate-raw:abort/disp8
140 $allocate-raw:commit:
141
142 89/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
143 $allocate-raw:end:
144
145 5f/pop-to-edi
146 5e/pop-to-esi
147 5b/pop-to-ebx
148 5a/pop-to-edx
149 59/pop-to-ecx
150 58/pop-to-eax
151
152 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
153 5d/pop-to-ebp
154 c3/return
155
156 $allocate-raw:abort:
157
158
159 68/push "allocate: failed\n"/imm32
160 68/push 2/imm32/stderr
161
162 e8/call _write/disp32
163
164 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
165
166 bb/copy-to-ebx 1/imm32
167 b8/copy-to-eax 1/imm32/exit
168 cd/syscall 0x80/imm8
169
170
171 test-allocate-raw-success:
172
173 55/push-ebp
174 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
175
176 68/push 0/imm32/limit
177 68/push 0/imm32/curr
178 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
179
180
181 51/push-ecx
182 68/push 0x200/imm32
183
184 e8/call new-segment/disp32
185
186 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
187
188 8b/copy 0/mod/indirect 1/rm32/ecx . . . 3/r32/ebx . .
189
190 68/push 0/imm32
191 68/push 0/imm32
192 89/copy 3/mod/direct 2/rm32/edx . . . 4/r32/esp . .
193
194 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 0x34/imm32
195
196
197 52/push-edx
198 68/push 3/imm32
199 51/push-ecx
200
201 e8/call allocate-raw/disp32
202
203 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
204
205
206 68/push "F - test-allocate-raw-success: sets alloc-id in handle"/imm32
207 68/push 0x34/imm32
208 ff 6/subop/push 0/mod/indirect 2/rm32/edx . . . . . .
209
210 e8/call check-ints-equal/disp32
211
212 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
213
214
215 68/push "F - test-allocate-raw-success: sets payload in handle"/imm32
216 53/push-ebx
217 ff 6/subop/push 1/mod/*+disp8 2/rm32/edx . . . . 4/disp8 .
218
219 e8/call check-ints-equal/disp32
220
221 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
222
223
224 68/push "F - test-allocate-raw-success: sets alloc-id in payload"/imm32
225 68/push 0x34/imm32
226 ff 6/subop/push 0/mod/indirect 3/rm32/ebx . . . . . .
227
228 e8/call check-ints-equal/disp32
229
230 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
231
232
233 68/push "F - test-allocate-raw-success: increments Next-alloc-id"/imm32
234 68/push 0x35/imm32
235 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32
236
237 e8/call check-ints-equal/disp32
238
239 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
240
241
242 68/push "F - test-allocate-raw-success: updates allocation descriptor"/imm32
243 68/push 7/imm32
244 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
245 29/subtract 3/mod/direct 0/rm32/eax . . . 3/r32/ebx . .
246 50/push-eax
247
248 e8/call check-ints-equal/disp32
249
250 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
251
252 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 0x100/imm32
253
254 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
255 5d/pop-to-ebp
256 c3/return
257
258 lookup:
259
260 55/push-ebp
261 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
262
263 51/push-ecx
264
265 31/xor 3/mod/direct 0/rm32/eax . . . 0/r32/eax . .
266
267 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 .
268
269 81 7/subop/compare 3/mod/direct 1/rm32/ecx . . . . . 0/imm32
270 74/jump-if-= $lookup:end/disp8
271
272 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 0xc/disp8 .
273
274 39/compare 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
275 75/jump-if-!= $lookup:abort/disp8
276
277 05/add-to-eax 4/imm32
278 $lookup:end:
279
280 59/pop-to-ecx
281
282 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
283 5d/pop-to-ebp
284 c3/return
285
286 $lookup:abort:
287
288
289 68/push "lookup failed\n"/imm32
290 68/push 2/imm32/stderr
291
292 e8/call _write/disp32
293
294 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
295
296 bb/copy-to-ebx 1/imm32/exit-status
297 b8/copy-to-eax 1/imm32/exit
298 cd/syscall 0x80/imm8
299
300 test-lookup-success:
301
302 55/push-ebp
303 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
304
305 68/push 0/imm32/limit
306 68/push 0/imm32/curr
307 89/copy 3/mod/direct 3/rm32/ebx . . . 4/r32/esp . .
308
309
310 53/push-ebx
311 68/push 0x200/imm32
312
313 e8/call new-segment/disp32
314
315 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
316
317 68/push 0/imm32/address
318 68/push 0/imm32/alloc-id
319 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
320
321 8b/copy 0/mod/indirect 3/rm32/ebx . . . 2/r32/edx . .
322
323
324 51/push-ecx
325 68/push 2/imm32/size
326 53/push-ebx
327
328 e8/call allocate-raw/disp32
329
330 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
331
332
333 ff 6/subop/push 1/mod/*+disp8 1/rm32/ecx . . . . 4/disp8 .
334 ff 6/subop/push 0/mod/indirect 1/rm32/ecx . . . . . .
335
336 e8/call lookup/disp32
337
338 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
339
340
341
342 68/push "F - test-lookup-success"/imm32
343 81 0/subop/add 3/mod/direct 2/rm32/edx . . . . . 4/imm32
344 52/push-edx
345 50/push-eax
346
347 e8/call check-ints-equal/disp32
348
349 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
350
351 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 0x100/imm32
352
353 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
354 5d/pop-to-ebp
355 c3/return
356
357 test-lookup-null-returns-null:
358
359 55/push-ebp
360 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
361
362 68/push 0/imm32/address
363 68/push 0/imm32/alloc-id
364 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
365
366
367 ff 6/subop/push 1/mod/*+disp8 1/rm32/ecx . . . . 4/disp8 .
368 ff 6/subop/push 0/mod/indirect 1/rm32/ecx . . . . . .
369
370 e8/call lookup/disp32
371
372 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
373
374
375 68/push "F - test-lookup-null-returns-null"/imm32
376 68/push 0/imm32
377 50/push-eax
378
379 e8/call check-ints-equal/disp32
380
381 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
382
383 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
384 5d/pop-to-ebp
385 c3/return
386
387 _pending-test-lookup-failure:
388
389 55/push-ebp
390 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
391
392 68/push 0/imm32/limit
393 68/push 0/imm32/curr
394 89/copy 3/mod/direct 6/rm32/esi . . . 4/r32/esp . .
395
396
397 56/push-esi
398 68/push 0x200/imm32
399
400 e8/call new-segment/disp32
401
402 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
403
404 68/push 0/imm32/address
405 68/push 0/imm32/alloc-id
406 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
407
408 8b/copy 0/mod/indirect 6/rm32/esi . . . 3/r32/ebx . .
409
410
411
412 51/push-ecx
413 68/push 2/imm32/size
414 56/push-esi
415
416 e8/call allocate/disp32
417
418 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
419
420 89/copy 0/mod/indirect 6/rm32/esi . . . 3/r32/ebx . .
421
422
423 68/push 0/imm32/address
424 68/push 0/imm32/alloc-id
425 89/copy 3/mod/direct 2/rm32/edx . . . 4/r32/esp . .
426
427
428 52/push-edx
429 68/push 2/imm32/size
430 56/push-esi
431
432 e8/call allocate/disp32
433
434 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
435
436
437 68/push "F - test-lookup-failure"/imm32
438 ff 6/subop/push 1/mod/*+disp8 2/rm32/ecx . . . . 4/disp8 .
439 ff 6/subop/push 1/mod/*+disp8 1/rm32/ecx . . . . 4/disp8 .
440
441 e8/call check-ints-equal/disp32
442
443 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
444
445
446 ff 6/subop/push 1/mod/*+disp8 1/rm32/ecx . . . . 4/disp8 .
447 ff 6/subop/push 0/mod/indirect 1/rm32/ecx . . . . . .
448
449 e8/call lookup/disp32
450
451
452 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
453
454 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 0x100/imm32
455
456 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
457 5d/pop-to-ebp
458 c3/return
459
460
461 handle-equal?:
462
463 55/push-ebp
464 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
465
466 51/push-ecx
467
468 b8/copy-to-eax 0/imm32/false
469 $handle-equal?:compare-alloc-id:
470
471 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 8/disp8 .
472
473 39/compare 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 0x10/disp8 .
474 75/jump-if-!= $handle-equal?:end/disp8
475 $handle-equal?:compare-address:
476
477 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 0xc/disp8 .
478
479 39/compare 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 0x14/disp8 .
480 75/jump-if-!= $handle-equal?:end/disp8
481 $handle-equal?:return-true:
482
483 b8/copy-to-eax 1/imm32/true
484 $handle-equal?:end:
485
486 59/pop-to-ecx
487
488 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
489 5d/pop-to-ebp
490 c3/return
491
492
493 allocate-region:
494
495 55/push-ebp
496 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
497
498 50/push-eax
499 51/push-ecx
500
501
502 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x10/disp8 .
503 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0xc/disp8 .
504 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
505
506 e8/call allocate/disp32
507
508 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
509
510 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 0x10/disp8 .
511 8b/copy 1/mod/*+disp8 0/rm32/eax . . . 0/r32/eax 4/disp8 .
512
513 05/add-to-eax 4/imm32
514
515 3d/compare-eax-and 0/imm32
516 74/jump-if-= $allocate-region:abort/disp8
517
518
519 89/copy 3/mod/direct 1/rm32/ecx . . . 0/r32/eax . .
520 81 0/subop/add 3/mod/direct 1/rm32/ecx . . . . . 8/imm32
521 89/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
522
523 89/copy 3/mod/direct 1/rm32/ecx . . . 0/r32/eax . .
524 03/add 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 0xc/disp8 .
525 89/copy 1/mod/*+disp8 0/rm32/eax . . . 1/r32/ecx 4/disp8 .
526
527 59/pop-to-ecx
528 58/pop-to-eax
529
530 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
531 5d/pop-to-ebp
532 c3/return
533
534
535
536
537
538
539
540 $allocate-region:abort:
541
542
543 68/push "allocate-region: failed to allocate\n"/imm32
544 68/push 2/imm32/stderr
545
546 e8/call _write/disp32
547
548 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
549
550 bb/copy-to-ebx 1/imm32
551 b8/copy-to-eax 1/imm32/exit
552 cd/syscall 0x80/imm8
553
554
555
556
557 allocate-array:
558
559 55/push-ebp
560 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
561
562 50/push-eax
563 51/push-ecx
564 52/push-edx
565
566 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 1/r32/ecx 0xc/disp8 .
567
568 8d/copy-address 1/mod/*+disp8 1/rm32/ecx . . . 2/r32/edx 4/disp8 .
569
570
571 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x10/disp8 .
572 52/push-edx
573 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
574
575 e8/call allocate/disp32
576
577 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
578
579 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 0x10/disp8 .
580 8b/copy 1/mod/*+disp8 0/rm32/eax . . . 0/r32/eax 4/disp8 .
581
582 05/add-to-eax 4/imm32
583
584 89/copy 0/mod/indirect 0/rm32/eax . . . 1/r32/ecx . .
585 $allocate-array:end:
586
587 5a/pop-to-edx
588 59/pop-to-ecx
589 58/pop-to-eax
590
591 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
592 5d/pop-to-ebp
593 c3/return
594
595 test-allocate-array:
596
597 55/push-ebp
598 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
599
600 68/push 0/imm32/limit
601 68/push 0/imm32/curr
602 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
603
604
605 51/push-ecx
606 68/push 0x200/imm32
607
608 e8/call new-segment/disp32
609
610 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
611
612 8b/copy 0/mod/indirect 1/rm32/ecx . . . 3/r32/ebx . .
613
614 68/push 0/imm32
615 68/push 0/imm32
616 89/copy 3/mod/direct 2/rm32/edx . . . 4/r32/esp . .
617
618 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 0x34/imm32
619
620
621 52/push-edx
622 68/push 3/imm32
623 51/push-ecx
624
625 e8/call allocate-array/disp32
626
627 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
628
629
630 68/push "F - test-allocate-array: sets alloc-id in handle"/imm32
631 68/push 0x34/imm32
632 ff 6/subop/push 0/mod/indirect 2/rm32/edx . . . . . .
633
634 e8/call check-ints-equal/disp32
635
636 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
637
638
639 68/push "F - test-allocate-array: sets payload in handle"/imm32
640 53/push-ebx
641 ff 6/subop/push 1/mod/*+disp8 2/rm32/edx . . . . 4/disp8 .
642
643 e8/call check-ints-equal/disp32
644
645 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
646
647
648 68/push "F - test-allocate-array: sets alloc-id in payload"/imm32
649 68/push 0x34/imm32
650 ff 6/subop/push 0/mod/indirect 3/rm32/ebx . . . . . .
651
652 e8/call check-ints-equal/disp32
653
654 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
655
656
657 68/push "F - test-allocate-array: sets array size in payload"/imm32
658 68/push 3/imm32
659 ff 6/subop/push 1/mod/*+disp8 3/rm32/ebx . . . . 4/disp8 .
660
661 e8/call check-ints-equal/disp32
662
663 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
664
665
666 68/push "F - test-allocate-array: increments Next-alloc-id"/imm32
667 68/push 0x35/imm32
668 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32
669
670 e8/call check-ints-equal/disp32
671
672 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
673
674
675 68/push "F - test-allocate-array: updates allocation descriptor"/imm32
676 68/push 0xb/imm32
677 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
678 29/subtract 3/mod/direct 0/rm32/eax . . . 3/r32/ebx . .
679 50/push-eax
680
681 e8/call check-ints-equal/disp32
682
683 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
684
685 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 1/imm32
686
687 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
688 5d/pop-to-ebp
689 c3/return
690
691 copy-array:
692
693 55/push-ebp
694 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
695
696 50/push-eax
697 51/push-ecx
698 52/push-edx
699 56/push-esi
700
701 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 0xc/disp8 .
702
703 8b/copy 0/mod/indirect 6/rm32/esi . . . 1/r32/ecx . .
704 81 0/subop/add 3/mod/direct 1/rm32/ecx . . . . . 4/imm32
705
706
707 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 0x10/disp8 .
708 51/push-ecx
709 ff 6/subop/push 1/mod/*+disp8 5/rm32/ebp . . . . 8/disp8 .
710
711 e8/call allocate/disp32
712
713 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
714
715 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 0/r32/eax 0x10/disp8 .
716 8b/copy 1/mod/*+disp8 0/rm32/eax . . . 0/r32/eax 4/disp8 .
717
718 05/add-to-eax 4/imm32
719
720 01/add 3/mod/direct 1/rm32/ecx . . . 0/r32/eax . .
721
722
723 8b/copy 0/mod/indirect 6/rm32/esi . . . 2/r32/edx . .
724 8d/copy-address 1/mod/*+disp8 4/rm32/sib 6/base/esi 2/index/edx . 2/r32/edx 4/disp8 .
725 52/push-edx
726
727 56/push-esi
728
729 51/push-ecx
730
731 50/push-eax
732
733 e8/call _append-4/disp32
734
735 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0x10/imm32
736 $copy-array:end:
737
738 5e/pop-to-esi
739 5a/pop-to-edx
740 59/pop-to-ecx
741 58/pop-to-eax
742
743 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
744 5d/pop-to-ebp
745 c3/return
746
747 test-copy-array:
748
749 55/push-ebp
750 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
751
752 68/push 5/imm32
753 68/push 4/imm32
754 68/push 3/imm32
755 68/push 0xc/imm32/size
756 89/copy 3/mod/direct 6/rm32/esi . . . 4/r32/esp . .
757
758 68/push 0/imm32/limit
759 68/push 0/imm32/curr
760 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
761
762
763 51/push-ecx
764 68/push 0x200/imm32
765
766 e8/call new-segment/disp32
767
768 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
769
770 8b/copy 0/mod/indirect 1/rm32/ecx . . . 3/r32/ebx . .
771
772 68/push 0/imm32
773 68/push 0/imm32
774 89/copy 3/mod/direct 2/rm32/edx . . . 4/r32/esp . .
775
776 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 0x34/imm32
777
778
779 52/push-edx
780 56/push-esi
781 51/push-ecx
782
783 e8/call copy-array/disp32
784
785 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
786
787
788 68/push "F - test-copy-array: sets alloc-id in handle"/imm32
789 68/push 0x34/imm32
790 ff 6/subop/push 0/mod/indirect 2/rm32/edx . . . . . .
791
792 e8/call check-ints-equal/disp32
793
794 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
795
796
797 68/push "F - test-copy-array: sets payload in handle"/imm32
798 53/push-ebx
799 ff 6/subop/push 1/mod/*+disp8 2/rm32/edx . . . . 4/disp8 .
800
801 e8/call check-ints-equal/disp32
802
803 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
804
805
806 68/push "F - test-copy-array: sets alloc-id in payload"/imm32
807 68/push 0x34/imm32
808 ff 6/subop/push 0/mod/indirect 2/rm32/edx . . . . . .
809
810 e8/call check-ints-equal/disp32
811
812 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
813
814
815 ff 6/subop/push 1/mod/*+disp8 2/rm32/edx . . . . 4/disp8 .
816 ff 6/subop/push 0/mod/indirect 2/rm32/edx . . . . . .
817
818 e8/call lookup/disp32
819
820 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
821
822
823 68/push "F - test-copy-array: sets array size in payload"/imm32
824 68/push 0xc/imm32
825 ff 6/subop/push 0/mod/indirect 0/rm32/eax . . . . . .
826
827 e8/call check-ints-equal/disp32
828
829 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
830
831
832 68/push "F - test-copy-array: increments Next-alloc-id"/imm32
833 68/push 0x35/imm32
834 ff 6/subop/push 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32
835
836 e8/call check-ints-equal/disp32
837
838 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
839
840
841 68/push "F - test-copy-array: updates allocation descriptor"/imm32
842 68/push 0x14/imm32
843 8b/copy 0/mod/indirect 1/rm32/ecx . . . 0/r32/eax . .
844 29/subtract 3/mod/direct 0/rm32/eax . . . 3/r32/ebx . .
845 50/push-eax
846
847 e8/call check-ints-equal/disp32
848
849 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
850
851 c7 0/subop/copy 0/mod/indirect 5/rm32/.disp32 . . . Next-alloc-id/disp32 1/imm32
852
853 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
854 5d/pop-to-ebp
855 c3/return
856
857
858 zero-out:
859
860
861
862
863
864
865
866
867
868
869 55/push-ebp
870 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
871
872 50/push-eax
873 51/push-ecx
874 52/push-edx
875 56/push-esi
876
877 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 6/r32/esi 8/disp8 .
878
879 31/xor 3/mod/direct 1/rm32/ecx . . . 1/r32/ecx . .
880
881 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 2/r32/edx 0xc/disp8 .
882 $zero-out:loop:
883
884 39/compare 3/mod/direct 1/rm32/ecx . . . 2/r32/edx . .
885 7d/jump-if->= $zero-out:end/disp8
886
887 c6 0/subop/copy 0/mod/direct 6/rm32/esi . . . . . 0/imm8
888
889 46/increment-esi
890
891 41/increment-ecx
892 eb/jump $zero-out:loop/disp8
893 $zero-out:end:
894
895 5e/pop-to-esi
896 5a/pop-to-edx
897 59/pop-to-ecx
898 58/pop-to-eax
899
900 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
901 5d/pop-to-ebp
902 c3/return
903
904 test-zero-out:
905
906 55/push-ebp
907 89/copy 3/mod/direct 5/rm32/ebp . . . 4/r32/esp . .
908
909 68/push 0x37363534/imm32
910 89/copy 3/mod/direct 1/rm32/ecx . . . 4/r32/esp . .
911
912
913 68/push 3/imm32/len
914 51/push-ecx
915
916 e8/call zero-out/disp32
917
918 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 8/imm32
919
920
921
922 68/push "F - test-zero-out"/imm32
923 68/push 0x37000000/imm32
924 ff 6/subop/push 0/mod/indirect 1/rm32/ecx . . . . . .
925
926 e8/call check-ints-equal/disp32
927
928 81 0/subop/add 3/mod/direct 4/rm32/esp . . . . . 0xc/imm32
929
930 89/copy 3/mod/direct 4/rm32/esp . . . 5/r32/ebp . .
931 5d/pop-to-ebp
932 c3/return
933
934