diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/wasm/call.wat | 27 |
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 |
