https://github.com/akkartik/mu/blob/master/apps/print-file.mu
 1 # accept a filename on the commandline, read it and print it out to screen
 2 # only ascii right now, just like the rest of Mu
 3 #
 4 # To run:
 5 #   $ ./translate_mu apps/print-file.mu
 6 #   $ echo abc > x
 7 #   $ ./a.elf x
 8 #   abc
 9 
10 fn main _args: (addr array (addr array byte)) -> exit-status/ebx: int {
11   var args/eax: (addr array (addr array byte)) <- copy _args
12 $main-body: {
13     var n/ecx: int <- length args
14     compare n, 1
15     {
16       break-if->
17       print-string-to-screen "usage: cat <filename>\n"
18       break $main-body
19     }
20     {
21       break-if-<=
22       var filename/edx: (addr addr array byte) <- index args 1
23       var in: (handle buffered-file)
24       {
25         var addr-in/eax: (addr handle buffered-file) <- address in
26         open *filename, 0, addr-in
27       }
28       var _in-addr/eax: (addr buffered-file) <- lookup in
29       var in-addr/ecx: (addr buffered-file) <- copy _in-addr
30       {
31         var c/eax: byte <- read-byte-buffered in-addr
32         compare c, 0xffffffff  # EOF marker
33         break-if-=
34         print-byte-to-screen c
35         loop
36       }
37     }
38   }
39   exit-status <- copy 0
40 }