global.set
Pops a value off the stack and sets a variable's value with it.

Syntax

global.set $label

Parameters

$label
The label name of the global variable. This can also be the index of the global variable. The variable will be set to the value on the stack. The value on the stack must be the same data type as the variable.

Stack In

* The value to be stored in the global variable. The data type must be the same as the variable used.

Stack Out

NONE

Example

;; Global variable (mutable, can be changed)
(global $vectorX (mut f64) (f64.const 0))

;; Scale vector X
(func $scaleVectorX (param $scaler f64)
    ;; Multiple vectorX by the scaler
    global.get $vectorX
    local.get $scaler
    f64.mul

    ;; Update the $vectorX value
    global.set $vectorX
)