diff options
| author | Henry Gressmann <mail@henrygressmann.de> | 2023-12-07 01:18:06 +0100 |
|---|---|---|
| committer | Henry Gressmann <mail@henrygressmann.de> | 2023-12-07 01:18:06 +0100 |
| commit | b0292c766fe68482648023881639266f696fe472 (patch) | |
| tree | 5004ea717a16a23f37c87d0467021879ddc0b6d9 /examples | |
| parent | 0cf77f7347d551437baff6bfb7c5768930c50198 (diff) | |
feat: improve lable/block handling, add support for more arithmetic opcodes
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/wasm/loop.wat | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/examples/wasm/loop.wat b/examples/wasm/loop.wat index 02683e7..ecdf136 100644 --- a/examples/wasm/loop.wat +++ b/examples/wasm/loop.wat @@ -4,16 +4,31 @@ (i32.const 0) ;; Initialize 'i' to 0 (local.set 0) - (loop $loopStart ;; Start of the loop - (local.get 0) ;; Get the current value of 'i' - (i32.const 1) ;; Push 1 onto the stack - (i32.add) ;; Add 'i' and 1 - (local.set 0) ;; Update 'i' with the new value + ;; (loop $test + ;; (loop $test2 + ;; (local.get 0) + ;; (i32.const 1) + ;; (i32.add) + ;; (local.set 0) + ;; (br $test2) + ;; ) + ;; ) - (local.get 0) ;; Push the current value of 'i' to check the condition - (i32.const 10) ;; Push 10 onto the stack - (i32.lt_s) ;; Check if 'i' is less than 10 - (br_if $loopStart) ;; If 'i' < 10, continue the loop + + (loop $blockStart + (loop $blockStart2 + (loop $loopStart ;; Start of the loop + (local.get 0) ;; Get the current value of 'i' + (i32.const 1) ;; Push 1 onto the stack + (i32.add) ;; Add 'i' and 1 + (local.set 0) ;; Update 'i' with the new value + + (local.get 0) ;; Push the current value of 'i' to check the condition + (i32.const 10) ;; Push 10 onto the stack + (i32.lt_s) ;; Check if 'i' is less than 10 + (br_if $blockStart) ;; If 'i' < 10, continue the loop + ) + ) ) (local.get 0) ;; After the loop, get the value of 'i' to be returned |
