br_if
Branch to the top of a (loop...)
or to the bottom of a (block...)
if a condition was met.
This will pop an i32
value off the stack and check its value. If it is not zero then it will branch.
But if the value is zero then nothing will happen and the following instruction will be performed.
Parameters
$label
The name of the code block to branch to. You can also use the index of the code block.
Stack In
i32 |
The control condition value. |
Example
loop $name_of_loop_section
local.get $keepLooping
br_if $name_of_loop_section
end
block $name_of_block_section
local.get $age
i32.const 18
i32.lt_u
br_if $name_of_block_section
end