summaryrefslogtreecommitdiff
path: root/examples/wasm
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2023-12-17 15:20:27 +0100
committerHenry Gressmann <mail@henrygressmann.de>2023-12-17 15:20:27 +0100
commit8bd7b4fa01915a4b8b8313f78935ca9762e7bcf9 (patch)
treeb13b74027d3a52f2b654d8ed72743584db76c63b /examples/wasm
parent386a073ea094f7aa00c90657eb99dea6544d5b3e (diff)
feat: if/else
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'examples/wasm')
-rw-r--r--examples/wasm/call.wat27
1 files changed, 13 insertions, 14 deletions
diff --git a/examples/wasm/call.wat b/examples/wasm/call.wat
index 247b976..9d00151 100644
--- a/examples/wasm/call.wat
+++ b/examples/wasm/call.wat
@@ -1,16 +1,15 @@
(module
- (func $add_fn (param $a i32) (param $b i32) (result i32)
- local.get $a
- local.get $b
- i32.add
- )
-
- (func $add (param $x i32) (param $y i32) (result i32)
- local.get $x
- local.get $y
- call $add_fn
- )
-
- (export "add" (func $add))
-)
+ (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
+ (export "check" (func $check_input))
+) \ No newline at end of file