hello.wat (654B)
- ;; SPDX-FileCopyrightText: 2021 Stephan Avenwedde <https://opensource.com/article/21/3/hello-world-webassembly>
- ;; SPDX-License-Identifier: CC-BY-SA-4.0
- (module
- ;; Imports from JavaScript namespace
- (import "console" "log" (func $log (param i32 i32))) ;; Import log function
- (import "js" "mem" (memory 1)) ;; Import 1 page of memory (54kb)
- ;; Data section of our module
- (data (i32.const 0) "Hello World from WebAssembly!")
- ;; Function declaration: Exported as helloWorld(), no arguments
- (func (export "helloWorld")
- i32.const 0 ;; pass offset 0 to log
- i32.const 29 ;; pass length 29 to log (strlen of sample text)
- call $log
- )
- )