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
(module
(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
)
)
)
@viniciusCamargo

This comment has been minimized.

Show comment Hide comment
@viniciusCamargo

viniciusCamargo Jul 25, 2016

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

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

@icefox

This comment has been minimized.

Show comment Hide comment
@icefox

icefox Aug 2, 2016

See my blog entry that embeds this for how you can run it and more information: http://benjamin-meyer.blogspot.com/2016/07/webassembly-hello-world.html

Owner

icefox commented Aug 2, 2016

See my blog entry that embeds this for how you can run it and more information: http://benjamin-meyer.blogspot.com/2016/07/webassembly-hello-world.html

@donpdonp

This comment has been minimized.

Show comment Hide comment
@donpdonp

donpdonp Dec 20, 2017

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")
    ^^^^^^^

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