Search⌘ K
AI Features

Converting WAST into WASM

Explore converting WebAssembly text format WAST into binary WASM files using the wat2wasm tool from the WebAssembly Binary Toolkit. Learn how to create .wat files, generate .wasm binaries, validate inputs, and examine binary structure with verbose output.

We'll cover the following...

The wat2wsam

wat2wasm helps to convert the WAST format into WASM. Let’s take it for a spin:

  1. Create a new folder called wabt-playground and go into the folder:

Shell
mkdir wabt-playground
cd wabt-playground
  1. Create a .wat file called add.wat:

C++
touch add.wat
  1. Add the following contents to add.wat:

C++
(module
(func $add (param $lhs i32) (param $rhs i32) (result i32)
local.get $lhs
local.get $rhs
i32.add
)
)
    ...