https://github.com/akkartik/mu/blob/master/subx/examples/ex4.subx
 1 # Read a character from stdin, save it to a global, write it to stdout.
 2 #
 3 # To run (from the subx directory):
 4 #   $ ./subx translate examples/ex4.subx -o examples/ex4
 5 #   $ ./subx run examples/ex4
 6 
 7 == data 0x0a000000
 8 
 9 # the global variable we save to
10 X:
11     0/imm32  # space for read() to write to
12 
13 == code 0x09000000
14 
15 # syscall(read, stdin, X, 1)
16 # . fd = 0 (stdin)
17 bb/copy-to-EBX  0/imm32
18 # . data = X (location to write result to)
19 b9/copy-to-ECX  X/imm32
20 # . size = 1 character
21 ba/copy-to-EDX  1/imm32
22 # . syscall
23 b8/copy-to-EAX  3/imm32/read
24 cd/syscall  0x80/imm8
25 
26 # syscall(write, stdout, X, 1)
27 # . fd = 1 (stdout)
28 bb/copy-to-EBX  1/imm32
29 # . initialize X (location to read from)
30 b9/copy-to-ECX  X/imm32
31 # . size = 1 character
32 ba/copy-to-EDX  1/imm32
33 # . syscall
34 b8/copy-to-EAX  4/imm32/write
35 cd/syscall  0x80/imm8
36 
37 # syscall(exit, EBX)
38 b8/copy-to-EAX  1/imm32/exit
39 cd/syscall  0x80/imm8
40 
41 # . . vim:nowrap:textwidth=0