28 lines
666 B
WebAssembly Text Format
28 lines
666 B
WebAssembly Text Format
(module
|
|
;; Correct module name: stdio, not stdout
|
|
(import "wasi:cli/stdio@0.2.6" "get-stdout"
|
|
(func $get_stdout (result i32)))
|
|
|
|
;; Write and flush a buffer.
|
|
(import "wasi:io/streams@0.2.0" "blocking-write-and-flush"
|
|
(func $bwrite (param i32 i32 i32) (result i32)))
|
|
|
|
(memory (export "memory") 1)
|
|
|
|
(data (i32.const 0) "Hello, World!\n")
|
|
|
|
(func (export "main")
|
|
(local $stdout i32)
|
|
;; Get the stdout stream handle
|
|
call $get_stdout
|
|
local.set $stdout
|
|
|
|
;; Write "Hello, World!\n" (14 bytes) to stdout
|
|
local.get $stdout
|
|
i32.const 0
|
|
i32.const 14
|
|
call $bwrite
|
|
drop ;; ignore the return value (0 = success)
|
|
)
|
|
)
|