Skip to content

Instantly share code, notes, and snippets.

@axic
Last active May 4, 2017 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axic/ca1cb385e193d7cacfe38e86766d4dea to your computer and use it in GitHub Desktop.
Save axic/ca1cb385e193d7cacfe38e86766d4dea to your computer and use it in GitHub Desktop.
Sample clang compiled webassembly
main() {
char buf[4096] = { 0 };
unsigned long long x = 1;
printf("hello %lld", x);
}
(module
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(import "env" "printf" (func $printf (param i32 i32) (result i32)))
(table 0 anyfunc)
(memory $0 1)
(data (i32.const 4) " \00\00")
(data (i32.const 16) "hello %lld\00")
(export "memory" (memory $0))
(export "main" (func $main))
(func $main (result i32)
(local $0 i32)
(i32.store offset=4
(i32.const 0)
(tee_local $0
(i32.sub
(i32.load offset=4
(i32.const 0)
)
(i32.const 16)
)
)
)
(i64.store
(get_local $0)
(i64.const 1)
)
(drop
(call $printf
(i32.const 16)
(get_local $0)
)
)
(i32.store offset=4
(i32.const 0)
(i32.add
(get_local $0)
(i32.const 16)
)
)
(i32.const 0)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment