區域性設定
local.set 指令用於設定區域性變數的值。
試一試
(module
(import "console" "log" (func $log (param i32)))
(func $main
(local $var i32) ;; create a local variable named $var
(local.set $var (i32.const 10)) ;; set $var to 10
local.get $var ;; load $var onto the stack
call $log ;; log the result
)
(start $main)
)
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url), { console });
語法
wat
;; load the number 2 onto the stack
i32.const 2
;; store the number 2 in the variable $val
local.set $val
| 指令 | 二進位制操作碼 |
|---|---|
local.set |
0x21 |