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