Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
WebAssembly hello world
;; WebAssembly WASM AST Hello World! program
(memory 1
(segment 8 "hello world!\n")
(import $__fwrite "env" "_fwrite" (param i32 i32 i32 i32) (result i32))
(import $_get__stdout "env" "get__stdout" (param) (result i32))
(export "main" $main)
(func $main (result i32)
(local $stdout i32)
(set_local $stdout (call_import $_get__stdout))
(return (call_import $__fwrite
(i32.const 8) ;; void *ptr => Address of our string
(i32.const 1) ;; size_t size => Data size
(i32.const 13) ;; size_t nmemb => Length of our string
(get_local $stdout)) ;; stream

hey, icefox! how are you doing? did you write somewhere about the setup necessary to run this script?


icefox commented Aug 2, 2016

See my blog entry that embeds this for how you can run it and more information:

has wast changed a lot since this post?

wabt-1.0.0 $ ./wast2wasm hello.wast 
hello.wast:5:5: error: unexpected token "segment"
   (segment 8 "hello world!\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment