https://github.com/akkartik/mu/blob/main/baremetal/120allocate.subx
 1 #   instruction                     effective address                                                   register    displacement    immediate
 2 # . op          subop               mod             rm32          base        index         scale       r32
 3 # . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes
 4 
 5 # Fill a region of memory with zeroes.
 6 zero-out:  # start: (addr byte), size: int
 7     # pseudocode:
 8     #   curr/esi = start
 9     #   i/ecx = 0
10     #   while true
11     #     if (i >= size) break
12     #     *curr = 0
13     #     ++curr
14     #     ++i
15     #
16     # . prologue
17     55/push-ebp
18     89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
19     # . save registers
20     50/push-eax
21     51/push-ecx
22     52/push-edx
23     56/push-esi
24     # curr/esi = start
25     8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .             .           6/r32/esi   8/disp8         .                 # copy *(ebp+8) to esi
26     # var i/ecx: int = 0
27     31/xor                          3/mod/direct    1/rm32/ecx    .           .             .           1/r32/ecx   .               .                 # clear ecx
28     # edx = size
29     8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .             .           2/r32/edx   0xc/disp8       .                 # copy *(ebp+12) to edx
30 $zero-out:loop:
31     # if (i >= size) break
32     39/compare                      3/mod/direct    1/rm32/ecx    .           .             .           2/r32/edx   .               .                 # compare ecx with edx
33     7d/jump-if->=  $zero-out:end/disp8
34     # *curr = 0
35     c6          0/subop/copy-byte   0/mod/direct    6/rm32/esi    .           .             .           .           .               0/imm8            # copy byte to *esi
36     # ++curr
37     46/increment-esi
38     # ++i
39     41/increment-ecx
40     eb/jump  $zero-out:loop/disp8
41 $zero-out:end:
42     # . restore registers
43     5e/pop-to-esi
44     5a/pop-to-edx
45     59/pop-to-ecx
46     58/pop-to-eax
47     # . epilogue
48     89/copy                         3/mod/direct    4/rm32/esp    .           .             .           5/r32/ebp   .               .                 # copy ebp to esp
49     5d/pop-to-ebp
50     c3/return
51 
52 # . . vim:nowrap:textwidth=0