wasm-as
The wasm-as
tool converts WAST into WASM. Let's look at the steps:
- Let's create a new folder, called
binaryen-playground
, and go into the folder:$ mkdir binaryen-playground $ cd binaryen-playground
- Create a
.wat
file calledadd.wat
:$ touch add.wat
- Add the following contents to
add.wat
:(module (func $add (param $x i32) (param $y i32) (result i32) (i32.add (local.get $x) (local.get $y) ) ) )
- Convert the Web Assembly text format into a WebAssembly module, using the
wasm-as
binary:$ /path/to/build/directory/of/binaryen/wasm-as add.wat
This generates the add.wasm
file:
00 61 73 6d 01 00 00 00 01 07 01 60 02 7f 7f 01 7f 03...