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