Files
wasm2elf-mb/examples/hello.wat
2026-11-21 01:03:32 -08:00

17 lines
708 B
WebAssembly Text Format

;; Core module for a wasi:cli/command component.
;; Build with: just run-component hello
(module
(import "wasi:cli/stdout@0.2.0" "get-stdout" (func $get_stdout (result i32)))
(import "wasi:io/streams@0.2.0" "[method]output-stream.blocking-write-and-flush"
(func $write (param i32 i32 i32 i32)))
(memory (export "memory") 1)
(data (i32.const 16) "Hello from wasi:cli!\0a")
(func (export "wasi:cli/run@0.2.0#run") (result i32)
(call $write
(call $get_stdout) ;; self: output-stream handle
(i32.const 16) ;; ptr
(i32.const 21) ;; len
(i32.const 64)) ;; retptr for result<_, stream-error>
(i32.load8_u (i32.const 64)))) ;; 0 = ok -> exit code 0