diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-06-04 21:30:43 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-06-04 21:30:43 -0700 |
commit | 536058af78a1f3f7dfd9bae6e3da7281941cb01c (patch) | |
tree | 541a1d0b459e34d0b9d62a855057afeeabe4ab9b /prototypes/browse/18/main.mu | |
parent | cde591e03e3e94415ebc2f3a094507edef940c02 (diff) | |
download | mu-536058af78a1f3f7dfd9bae6e3da7281941cb01c.tar.gz |
6467
Diffstat (limited to 'prototypes/browse/18/main.mu')
-rw-r--r-- | prototypes/browse/18/main.mu | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/prototypes/browse/18/main.mu b/prototypes/browse/18/main.mu new file mode 100644 index 00000000..e2b41b73 --- /dev/null +++ b/prototypes/browse/18/main.mu @@ -0,0 +1,34 @@ +fn main args: (addr array (addr array byte)) -> exit-status/ebx: int { + # initialize fs from args[1] + var filename/eax: (addr array byte) <- first-arg args +#? print-string filename +#? print-string "\n" + var file-state-storage: file-state + var fs/esi: (addr file-state) <- address file-state-storage + init-file-state fs, filename + render fs + exit-status <- copy 0 +} + +fn render fs: (addr file-state) { + render-normal fs +} + +fn render-normal fs: (addr file-state) { + { + var c/eax: byte <- next-char fs + # if (c == EOF) break + compare c, 0xffffffff # EOF marker + break-if-= + # + print-byte c + # + loop + } +} + +fn first-arg args-on-stack: (addr array (addr array byte)) -> out/eax: (addr array byte) { + var args/eax: (addr array (addr array byte)) <- copy args-on-stack + var result/eax: (addr addr array byte) <- index args, 1 + out <- copy *result +} |