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

Max Module - Wat Typing CST Test

Loading…

Max Module — Wat Code

A WAT module that returns the maximum of two numbers.

# wat/demo/max.wat
(module
	(func $max (param $a i32) (param $b i32) (result i32)
		local.get $a
		local.get $b
		i32.gt_s
		if (result i32)
		then local.get $a
		else local.get $b
		end)
	(export "max" (func $max))
)

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 Subtract ModuleWAT Factorial ModuleWAT Fibonacci ModuleWAT Min ModuleWAT Even Check ModuleWAT Odd Check ModuleWAT Toggle Module

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher