AnatomyOf

Anatomy of a WebAssembly file

example.wat
1;; A minimal Wasm module. No garbage collector was harmed making this.
2(module
3 (type $double_t (func (param i32) (result i32)))
4
5 (func $double (type $double_t) (param $n i32) (result i32)
6 local.get $n ;; push n
7 i32.const 2 ;; push 2
8 i32.mul ;; pop, pop, multiply, push -- no registers were consulted
9 )
10
11 (export "double" (func $double))
12)
WebAssembly (Wasm) is a portable binary instruction format for a stack machine; these examples use its equivalent human-readable WebAssembly Text (WAT) representation.