Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
35
Task/Hello-world-Text/WebAssembly/hello-world-text.wasm
Normal file
35
Task/Hello-world-Text/WebAssembly/hello-world-text.wasm
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
(module $helloworld
|
||||
|
||||
;;Import fd_write from WASI, declaring that it takes 4 i32 inputs and returns 1 i32 value
|
||||
(import "wasi_unstable" "fd_write"
|
||||
(func $fd_write (param i32 i32 i32 i32) (result i32))
|
||||
)
|
||||
|
||||
;;Declare initial memory size of 32 bytes
|
||||
(memory 32)
|
||||
|
||||
;;Export memory so external functions can see it
|
||||
(export "memory" (memory 0))
|
||||
|
||||
;;Declare test data starting at address 8
|
||||
(data (i32.const 8) "Hello world!\n")
|
||||
|
||||
;;The entry point for WASI is called _start
|
||||
(func $main (export "_start")
|
||||
|
||||
;;Write the start address of the string to address 0
|
||||
(i32.store (i32.const 0) (i32.const 8))
|
||||
|
||||
;;Write the length of the string to address 4
|
||||
(i32.store (i32.const 4) (i32.const 13))
|
||||
|
||||
;;Call fd_write to print to console
|
||||
(call $fd_write
|
||||
(i32.const 1) ;;Value of 1 corresponds to stdout
|
||||
(i32.const 0) ;;The location in memory of the string pointer
|
||||
(i32.const 1) ;;Number of strings to output
|
||||
(i32.const 24) ;;Address to write number of bytes written
|
||||
)
|
||||
drop ;;Ignore return code
|
||||
)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue