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.
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
f64.const 3.142
f64.const 2.718
i32.const 1
select