aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-10-06 18:49:05 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-10-06 18:49:05 +0200
commit63a2cced4238af7d171e0b8807d887c435b4656b (patch)
treee08a23b3700ccd540c053d7c4cbe24bf7cf53d6c /tests
parentf0cd9e4e8bc1e1b109fff627c75527ee7195c82e (diff)
downloadAGH-engineering-thesis-63a2cced4238af7d171e0b8807d887c435b4656b.tar.gz
AGH-engineering-thesis-63a2cced4238af7d171e0b8807d887c435b4656b.zip
add translation of relational operations and loops
Diffstat (limited to 'tests')
l---------tests/wasm_compile_loop/Makefile1
-rw-r--r--tests/wasm_compile_loop/instructions.wat25
l---------tests/wasm_compile_loop/test.v1
-rw-r--r--tests/wasm_compile_loop/words_to_verify.mem4
4 files changed, 31 insertions, 0 deletions
diff --git a/tests/wasm_compile_loop/Makefile b/tests/wasm_compile_loop/Makefile
new file mode 120000
index 0000000..e451c8b
--- /dev/null
+++ b/tests/wasm_compile_loop/Makefile
@@ -0,0 +1 @@
+../wasm_compile_simple_module/Makefile \ No newline at end of file
diff --git a/tests/wasm_compile_loop/instructions.wat b/tests/wasm_compile_loop/instructions.wat
new file mode 100644
index 0000000..02a75e0
--- /dev/null
+++ b/tests/wasm_compile_loop/instructions.wat
@@ -0,0 +1,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)))
diff --git a/tests/wasm_compile_loop/test.v b/tests/wasm_compile_loop/test.v
new file mode 120000
index 0000000..f0235d8
--- /dev/null
+++ b/tests/wasm_compile_loop/test.v
@@ -0,0 +1 @@
+../wasm_compile_simple_module/test.v \ No newline at end of file
diff --git a/tests/wasm_compile_loop/words_to_verify.mem b/tests/wasm_compile_loop/words_to_verify.mem
new file mode 100644
index 0000000..ef41c69
--- /dev/null
+++ b/tests/wasm_compile_loop/words_to_verify.mem
@@ -0,0 +1,4 @@
+// address value
+ 0FFFFC 23
+
+ 200 00000037