WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications. For more information on WebAssembly, see the WebAssembly website.
There are different assemblers available, from Wabt, emscripten.org and LLVM. The expected format is a slightly different between those two:
(module (func $add (param $lhs i32) (param $rhs i32) (result i32) local.get $lhs local.get $rhs i32.add ) (export "add" (func $add)) )
According to the official site "Wabt" is using it's own format of the Wasm. It's slightly different from the official documentation. The most current version of Wabt matches the specs, as well as supports the old syntax.
Online studio, that's using the older version of wabt syntax. https://webassembly.studio/
For example. instead of
The assembler is recommended for the use in a compiler by the WebAssembly.org
(module (func $add (param $lhs i32) (param $rhs i32) (result i32) ( local.get $lhs local.get $rhs i32.add ) ) (export "add" (func $add)) )
This is the assembler from the LLVM project. It uses a GAS-like syntax.
Use on the Wiki
WebAssembly is using s-expressions as its textual format (for either Wabt or Emscript) . it's handy to use syntax highlighter for the code and use "lisp" language to set colors.
<source lang="lisp"> ;; web assembly goes here </source>
- WebAssembly/Compiler - getting the compiler
- WebAssembly/Instructions - Instructions of the WASM code
- https://webassembly.org/ - the official site
- https://webassembly.github.io/spec/core/text/index.html - text format (S-Expression) specs
- https://webassembly.github.io/spec/core/binary/index.html - binary format specs
- https://rsms.me/wasm-intro - introduction to webassembly