常量

const 指令用於宣告數字。

試一試

(module
  (import "console" "log" (func $log (param i32)))
  (func $main

    i32.const 10 ;; load a number onto the stack
    call $log ;; log the number

  )
  (start $main)
)
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url), { console });

語法

wat
;; push `5` onto the stack
i32.const 5
指令 二進位制操作碼
i32.const 0x41
i64.const 0x42
f32.const 0x43
f64.const 0x44