Hello World
(module
(import "console" "log" (func $log (param i32 i32)))
(import "js" "mem" (memory 1))
(data (i32.const 0) "Hello World")
(func (export "hello")
i32.const 0
i32.const 11
call $log))
Imports
var memory = new WebAssembly.Memory({initial:1});
function consoleLogString(offset, length) {
var bytes = new Uint8Array(memory.buffer, offset, length);
var string = new TextDecoder('utf8').decode(bytes);
console.log(string);
}
var importObject = { console: { log: consoleLogString }, js: { mem: memory } };
Last updated
Was this helpful?