userland/src/lib: make this look pretty

This commit is contained in:
Cadey Ratio 2018-06-18 02:42:49 +00:00
parent eedf0b024d
commit d582c3b14b
1 changed files with 29 additions and 29 deletions

View File

@ -17,67 +17,67 @@
;; functions
(func $openFile (result i32)
;; open stdout
(i32.const 200)
(i32.const 42)
(call $open))
(call $open
(i32.const 200)
(i32.const 42)))
(func $writeHelloWorld (param $fd i32)
;; write hello world
(get_local $fd)
(i32.const 230)
(i32.const 14)
(call $write)
(call $write
(get_local $fd)
(i32.const 230)
(i32.const 14))
(drop))
(func $readHello (param $fd i32)
;; read hello world
(get_local $fd)
(i32.const 255)
(i32.const 14)
(call $read)
(call $read
(get_local $fd)
(i32.const 255)
(i32.const 14))
(drop))
(func $removeFile
(i32.const 200)
(call $unlink)
(call $unlink
(i32.const 200))
(drop))
(func $main (result i32)
(local $fd i32)
;; set $fd to the file descriptor
(call $openFile)
(set_local $fd)
(set_local $fd
(call $openFile))
(get_local $fd)
(call $writeHelloWorld)
(call $writeHelloWorld
(get_local $fd))
;; close file
(get_local $fd)
(call $close)
(call $close
(get_local $fd))
;; set $fd to the new file descriptor
(call $openFile)
(set_local $fd)
(set_local $fd
(call $openFile))
;; read Hello, World
(get_local $fd)
(call $readHello)
(call $readHello
(get_local $fd))
;; istty
(get_local $fd)
(call $istty)
(call $istty
(get_local $fd))
(drop)
;; close file again
(get_local $fd)
(call $close)
(call $close
(get_local $fd))
;; unlink filename
(call $removeFile)
;; return 0
(i32.const 0)
(set_local $fd)
(set_local $fd
(i32.const 0))
(drop))
(export "main" (func $main)))