1. Home
  2. /
  3. Wat
  4. /
  5. Subtract Module

Subtract Module - Wat Typing CST Test

Loading…

Subtract Module — Wat Code

A WAT module that subtracts two numbers.

# wat/demo/subtract.wat
(module
	(func $subtract (param $a i32) (param $b i32) (result i32)
		local.get $a
		local.get $b
		i32.sub)
	(export "subtract" (func $subtract))
)

Wat Language Guide

WAT (WebAssembly Text Format) is the human-readable, assembly-like syntax used to represent WebAssembly binaries. It allows developers to write, inspect, debug, and understand Wasm modules using a clear, text-based format before compiling to .wasm.

Primary Use Cases

  • ▸Learning WebAssembly internals
  • ▸Debugging or inspecting Wasm modules
  • ▸Creating tiny hand-crafted Wasm binaries
  • ▸Reverse engineering WebAssembly
  • ▸Testing Wasm instructions or host bindings

Notable Features

  • ▸Human-readable text representation of Wasm
  • ▸Direct 1:1 mapping to WebAssembly binary
  • ▸Minimal syntax with S-expression format
  • ▸Precise control over memory, tables, types, and functions
  • ▸Perfect for inspection, debugging, and educational use

Origin & Creator

WebAssembly was created by engineers from Mozilla, Google, Microsoft, and Apple. WAT is part of the core WebAssembly specification managed by the W3C WebAssembly Community Group.

Industrial Note

WAT is essential for low-level debugging, reverse engineering, creating minimal Wasm modules, and understanding how higher-level languages compile to WebAssembly.

More Wat Typing Exercises

Simple WAT ModuleWAT Multiply ModuleWAT Factorial ModuleWAT Fibonacci ModuleWAT Max ModuleWAT Min ModuleWAT Even Check ModuleWAT Odd Check ModuleWAT Toggle Module

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher