select
Used to pick between two items on the stack depending on condition. You push two values onto the stack. These both have to be of the same data type. You then push a control condition onto the stack. When calling the instruction, if the condition is not zero then the first item is pushed onto the stack. If the condition is zero then the second item is pushed onto the stack.

Syntax

select

Stack In

* The first value.
* The second value. This must be the same data type as the first.
i32 The condition value.

Stack Out

* If the condition is not zero then the first value is given. If the condition is zero then the second value is given. The data type will be the same too.

Example

;; Add two values onto the stack
f64.const 3.142
f64.const 2.718

;; Push the condition value onto the stack
i32.const 1

;; Select the f64 value depending on the condition
select

;; The stack contains a f64 value of 2.718 (the second was selected)