Skip to content

hbcbh1999/wasm-wat-samples

 
 

Repository files navigation

WebAssembly WAT samples

Some sample WebAssembly Text programs.

WebAssembly defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for facilitating interactions between such programs and their host environment.

The text format (WAT) is, essentially, an assembly language. While most people will not write WAT directly (just as most programmers don't write assembly code directly), familiarity this format is important if you seek a deep understanding of WASM mechanisms and related toolchains.

How to run these samples

Unless otherwise stated, each sample consists of a single .wat file and an accompanying test.js file. When the setup is more complicated, the directory's own README will have additional information.

First, start by compiling the WAT file to WASM with wabt or some other WASM toolchain:

$ wat2wasm somefile.wat

This creates a somefile.wasm binary, which test.js expects to find in its own directory. To load and test the WASM, you'll need a recent Node.js installed, and run:

$ node test.js

This will typically emit some output; if the loading failed or the loaded WASM behaves unexpectedly, the test.js script will report an error.

WASI documentation

Useful sources of documentation about WASI host calls:

About

Samples of WebAssembly Text programs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • WebAssembly 64.6%
  • JavaScript 33.8%
  • C 1.4%
  • Shell 0.2%