全域性獲取
global.get 指令將全域性變數的值載入到堆疊上。
試一試
(module
(import "console" "log" (func $log (param i32)))
(global $var i32 (i32.const 10))
(func $main
global.get $var ;; load the value of $var variable onto the stack
call $log ;; log the result
)
(start $main)
)
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url), { console });
語法
wat
;; load the value of a global variable onto the stack
global.get $val
| 指令 | 二進位制操作碼 |
|---|---|
global.get |
0x23 |