summaryrefslogtreecommitdiff
path: root/examples/wasm
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2023-11-28 20:06:41 +0100
committerHenry Gressmann <mail@henrygressmann.de>2023-11-28 20:06:41 +0100
commitfe76d91f33b2441de87597ae5885ea9005f35b1c (patch)
treebda08242444d91dbf55e5e96233ae826c5e4e376 /examples/wasm
parent1256c4248d2a3a9f73c2a14d997a337ba0eee2b4 (diff)
refactor: seperate cli crate
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'examples/wasm')
-rw-r--r--examples/wasm/helloworld.wasmbin0 -> 115 bytes
-rw-r--r--examples/wasm/helloworld.wat15
2 files changed, 15 insertions, 0 deletions
diff --git a/examples/wasm/helloworld.wasm b/examples/wasm/helloworld.wasm
new file mode 100644
index 0000000..a5c95d0
--- /dev/null
+++ b/examples/wasm/helloworld.wasm
Binary files differ
diff --git a/examples/wasm/helloworld.wat b/examples/wasm/helloworld.wat
new file mode 100644
index 0000000..b74c98f
--- /dev/null
+++ b/examples/wasm/helloworld.wat
@@ -0,0 +1,15 @@
+(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
+ )
+) \ No newline at end of file