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