WebAssembly Instruction Set Architecture Guide

This article provides a comprehensive overview of the primary instructions that make up the WebAssembly (Wasm) instruction set architecture. WebAssembly is designed as a low-level, stack-based virtual machine, and understanding its core instruction categories—including numeric, parametric, variable, memory, and control flow instructions—is essential for understanding how Wasm executes code with near-native speed and security.

The Stack-Based Design

Before diving into the instruction categories, it is important to note that WebAssembly operates on a conceptual operand stack. Most instructions pop their arguments off this stack, perform an operation, and push the result back onto the stack.


1. Numeric Instructions

Numeric instructions perform basic arithmetic, bitwise operations, comparisons, and type conversions. WebAssembly supports four primary numeric types: 32-bit integers (i32), 64-bit integers (i64), 32-bit floats (f32), and 64-bit floats (f64).


2. Variable Instructions

Variable instructions provide access to local variables within a function, as well as global variables accessible across the entire module.


3. Parametric Instructions

Parametric instructions are generic operations that manipulate values on the operand stack regardless of their specific Wasm data type.


4. Memory Instructions

WebAssembly utilizes a flat, linear memory model represented as a contiguous array of raw bytes. Memory instructions allow the virtual machine to read from and write to this space.


5. Control Flow Instructions

Unlike traditional assembly languages that use arbitrary jumps (like goto), WebAssembly enforces structured control flow. This makes validation faster and ensures execution safety.