https://github.com/akkartik/mu/blob/master/apps/ex12.subx
 1 # Example showing mmap syscall.
 2 # Create a new segment using mmap, save the address, write to it.
 3 #
 4 # To run:
 5 #   $ ./bootstrap translate init.linux apps/ex12.subx -o apps/ex12
 6 #   $ ./bootstrap run apps/ex12
 7 # You shouldn't get a segmentation fault.
 8 
 9 == code
10 #   instruction                     effective address                                                   register    displacement    immediate
11 # . op          subop               mod             rm32          base        index         scale       r32
12 # . 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
13 
14 Entry:
15     # mmap(Mmap-new-segment->len)
16     bb/copy-to-ebx  Mmap-new-segment/imm32
17     e8/call  syscall_mmap/disp32
18 
19     # write to *eax to check that we have access to the newly-allocated segment
20     c7          0/subop/copy        0/mod/direct    0/rm32/eax    .           .             .           .           .               0x34/imm32        # copy to *eax
21 
22     # exit(eax)
23     89/copy                         3/mod/direct    3/rm32/ebx    .           .             .           0/r32/eax   .               .                 # copy eax to ebx
24     e8/call  syscall_exit/disp32
25 
26 == data
27 
28 # various constants used here were found in the Linux sources (search for file mman-common.h)
29 Mmap-new-segment:  # type mmap_arg_struct
30     # addr
31     0/imm32
32     pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #