Wasm Reference
  • Welcome
  • Nodejs WAT Compiler
  • Types
    • Functions
    • Globals
    • Linear Memory
    • Tables
    • Numbers
    • Text
  • Structures
    • IF
    • LOOP
  • Algorithms
    • Hello World
    • Estimate Pi
  • Maths Helper Algorithms
    • Pseudorandom Number Generator
    • Factorial
    • Dist
    • Map
    • Fract
    • RemF or ModF
    • Round
    • Clamp
    • Mix
    • Pow
    • Approx Sin
    • Approx Cos
    • Approx Tan
    • ToRad and ToDeg
Powered by GitBook
On this page

Was this helpful?

  1. Structures

IF

(func (export "testif") (result i32)
    (local $t i32)
    (set_local $t (i32.const 0))
    i32.const 0 
    i32.const 11 
    i32.eq 
    if $i0
      (set_local $t (i32.const 5)) 
    else 
      (set_local $t (i32.const 2))
    end
    get_local $t
  )

PreviousTextNextLOOP

Last updated 5 years ago

Was this helpful?