blob: 02a75e0e8bd2802bb65ee7db9c66f5533a121471 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
(module
(memory 0 2)
(func $main
(local $counter i32)
;; prepare offset for store operation later
(i32.const 0x0)
;; initialize counter
(set_local $counter (i32.const 0))
;; add numbers from 1 to 10
(i32.const 0)
(loop $again (param i32) (result i32)
(set_local $counter (i32.add
(get_local $counter)
(i32.const 1)))
(i32.add (get_local $counter))
(br_if $again (i32.lt_u
(get_local $counter)
(i32.const 10))))
;; write computed sum (55 in dec, 37 in hex) at MEMORY_BOTTOM_ADDR
(i32.store offset=0x0 align=2))
(export "main" (func $main)))
|