You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
640 B
Plaintext
34 lines
640 B
Plaintext
(data $hello "Hello world.\0A")
|
|
|
|
(import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32)))
|
|
|
|
(func $start (export "_start") (result i32)
|
|
(local $stringLocation i32)
|
|
|
|
call $memory_init
|
|
|
|
;; allocate string location
|
|
i32.const 13
|
|
call $memory_alloc
|
|
local.set $stringLocation
|
|
|
|
;; copy string into memory
|
|
local.get $stringLocation ;; dest
|
|
i32.const 0 ;; index into string
|
|
i32.const 13 ;; length
|
|
memory.init $hello
|
|
|
|
;; print
|
|
local.get $stringLocation ;; location
|
|
i32.const 13 ;; length
|
|
call $print
|
|
|
|
;; free string
|
|
local.get $stringLocation
|
|
call $memory_free
|
|
|
|
call $proc_exit
|
|
unreachable
|
|
)
|
|
|