- Notifications
You must be signed in to change notification settings - Fork 258
/
Copy pathmemory.wat
32 lines (32 loc) · 713 Bytes
/
memory.wat
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
26
27
28
29
30
31
32
(module
(memory (import"js""mem") 1)
(func (export"accumulate") (param$ptri32) (param$leni32) (resulti32)
(local$endi32)
(local$sumi32)
(local.set$end
(i32.add
(local.get$ptr)
(i32.mul
(local.get$len)
(i32.const4))))
(block$break
(loop$top
(br_if$break
(i32.eq
(local.get$ptr)
(local.get$end)))
(local.set$sum
(i32.add
(local.get$sum)
(i32.load
(local.get$ptr))))
(local.set$ptr
(i32.add
(local.get$ptr)
(i32.const4)))
(br$top)
)
)
(local.get$sum)
)
)