https://github.com/akkartik/mu/blob/master/apps/print-file.mu
1
2
3
4
5
6
7
8
9
10 fn main _args: (addr array addr array byte) -> _/ebx: int {
11 var args/eax: (addr array addr array byte) <- copy _args
12 var n/ecx: int <- length args
13 compare n, 1
14 {
15 break-if->
16 print-string 0, "usage: cat <filename>\n"
17 return 0
18 }
19 {
20 break-if-<=
21 var filename/edx: (addr addr array byte) <- index args 1
22 var in: (handle buffered-file)
23 {
24 var addr-in/eax: (addr handle buffered-file) <- address in
25 open *filename, 0, addr-in
26 }
27 var _in-addr/eax: (addr buffered-file) <- lookup in
28 var in-addr/ecx: (addr buffered-file) <- copy _in-addr
29 {
30 var c/eax: byte <- read-byte-buffered in-addr
31 compare c, 0xffffffff
32 break-if-=
33 var g/eax: grapheme <- copy c
34 print-grapheme 0, g
35 loop
36 }
37 }
38 return 0
39 }