summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2023-12-17 23:38:13 +0100
committerHenry Gressmann <mail@henrygressmann.de>2023-12-17 23:38:13 +0100
commitee869abc8f7383b198f2033f940fdd5aa8839fed (patch)
treea411c033eebe6d65708f699178d20ffa58c45a7b /examples
parentfc97f2cab27658b81ef9409b3f388226a4745cee (diff)
chore: improve label handling
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'examples')
-rw-r--r--examples/wasm/call.wat52
1 files changed, 40 insertions, 12 deletions
diff --git a/examples/wasm/call.wat b/examples/wasm/call.wat
index 9d00151..b604c75 100644
--- a/examples/wasm/call.wat
+++ b/examples/wasm/call.wat
@@ -1,15 +1,43 @@
(module
- (func $check_input (param i32) (result i32)
- local.get 0
- i32.const 10
- i32.lt_s ;; Check if input is less than 10
- if (result i32) ;; If so,
- i32.const 1 ;; Set 1 to the stack
- return ;; And return immediately
- else ;; Otherwise,
- i32.const 0 ;; Set 0 to the stack
- return ;; And return immediately
- end) ;; End of the if/else block
+ ;; (func $check_input (param i32) (result i32)
+ ;; i64.const 0 ;; Set 0 to the stack
+ ;; local.get 0
+ ;; i32.const 10
+ ;; i32.lt_s ;; Check if input is less than 10
+ ;; if (param i64) (result i32) ;; If so,
+ ;; i32.const 1 ;; Set 1 to the stack
+ ;; return ;; And return immediately
+ ;; else ;; Otherwise,
+ ;; i32.const 0 ;; Set 0 to the stack
+ ;; return ;; And return immediately
+ ;; end) ;; End of the if/else block
- (export "check" (func $check_input))
+ (func (export "simple_block") (result i32)
+ (block (result i32)
+ (i32.const 0)
+ (i32.const 1)
+ (i32.add)
+ )
+ )
+
+ (func (export "checkloop") (result i32)
+ (block (result i32)
+ (i32.const 0)
+ (loop (param i32)
+ (block (br 2 (i32.const 18)))
+ (br 0 (i32.const 20))
+ )
+ (i32.const 19)
+ )
+ )
+
+
+ (func (export "param") (result i32)
+ (i32.const 1)
+ (loop (param i32) (result i32)
+ (i32.const 2)
+ (i32.add)
+ )
+ )
+ ;; (export "check" (func $check_input))
) \ No newline at end of file