(loop...)
Creates a code block that can be used to loop execution, repeating the same inner code a number of times. When the instruction comes to the end of the loop it will not automatically move to the top again. You have to manually branch to the top of the loop using either the br or br_if instructions.

Syntax

(loop $label (param...) (result...))
loop $label (param...) (result...)
  ...
end

Parameters

$label Optional
The name of the loop. This is used with the branch instructions br and br_if. Each code block, both loop and block, are given an index. The inner most code block will have index 0 and its parent will have index 1, and so on.

Example

;; Create loop section
loop $name_of_loop_section
  ;; Do something

  ;; We want to do it again
  br $name_of_loop_section
end