Skip to content

Instantly share code, notes, and snippets.

@soma-arc
Created October 24, 2015 13:04
Show Gist options
  • Select an option

  • Save soma-arc/f29182340b6d95bbde60 to your computer and use it in GitHub Desktop.

Select an option

Save soma-arc/f29182340b6d95bbde60 to your computer and use it in GitHub Desktop.
(module
(func $double-loop (param $width i32) (param $height i32) (result i32)
(local $x i32)
(local $y i32)
(local $sum i32)
(loop $x-loop
(set_local $y (i32.const 0))
(loop $y-loop
(set_local $sum (i32.add (get_local $sum) (i32.const 1)))
(set_local $y (i32.add (get_local $y) (i32.const 1)))
(if (i32.eq (get_local $y) (get_local $height))
(break $y-loop)))
(set_local $x (i32.add (get_local $x) (i32.const 1)))
(if (i32.eq (get_local $x) (get_local $width))
(break $x-loop)))
(return (get_local $sum)))
(export "test" $test)
(func $test (result i32)
(call $double-loop (i32.const 10) (i32.const 10))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment