{"id":18835661,"url":"https://github.com/tgsstdio/hello-webassembly","last_synced_at":"2026-04-24T16:01:47.006Z","repository":{"id":94238547,"uuid":"93997758","full_name":"tgsstdio/Hello-WebAssembly","owner":"tgsstdio","description":"\"Hello World\" WebAssembly examples in WasmFiddle ","archived":false,"fork":false,"pushed_at":"2017-06-11T11:30:42.000Z","size":5,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-29T19:01:09.266Z","etag":null,"topics":["c","javascript","webassembly"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tgsstdio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-11T10:40:19.000Z","updated_at":"2020-10-14T15:44:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"d5390103-1d8a-43ef-8749-688a861f2533","html_url":"https://github.com/tgsstdio/Hello-WebAssembly","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tgsstdio/Hello-WebAssembly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgsstdio%2FHello-WebAssembly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgsstdio%2FHello-WebAssembly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgsstdio%2FHello-WebAssembly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgsstdio%2FHello-WebAssembly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tgsstdio","download_url":"https://codeload.github.com/tgsstdio/Hello-WebAssembly/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgsstdio%2FHello-WebAssembly/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32230421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","javascript","webassembly"],"created_at":"2024-11-08T02:16:50.348Z","updated_at":"2026-04-24T16:01:47.001Z","avatar_url":"https://github.com/tgsstdio.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hello-WebAssembly\n\n\"Hello World\" WebAssembly examples written in the [WasmFiddle](https://wasdk.github.io/WasmFiddle/) HTML browser editor\n\n## Examples\n- [Option 1](#option-1) - Print HELLO WORLD by reading hardcoded data [LINK](https://wasdk.github.io/WasmFiddle/?wvzhb)\n\n- [Option 2](#option-2) - Using an js import function to output 'HELLO WORLD' [LINK](https://wasdk.github.io/WasmFiddle/?jn7tx)\n\n- [Option 3](#option-3) - Writing out 'HELLO WORLD' into memory and observing the change via dumps [LINK](https://wasdk.github.io/WasmFiddle/?15zq3v)\n\n- [Option 4](#option-4) - Printing HELLO WORLD by reading memory (i.e. similar to Option 3) [LINK](https://wasdk.github.io/WasmFiddle/?1hayln)\n\n-----\n\n## Option 1 \n\n\u003e Print HELLO WORLD by reading hardcoded data\n\n[WASMFIDDLE](https://wasdk.github.io/WasmFiddle/?wvzhb)\n\n### C source (.c)\n\n``` C\nchar* hello() {\n  return \"Hello World\";\n}\n```\n\n### WebAssembly syntax tree (.wast)\n\n``` LISP\n(module\n  (table 0 anyfunc)\n  (memory $0 1)\n  (data (i32.const 16) \"Hello World\\00\")\n  (export \"memory\" (memory $0))\n  (export \"hello\" (func $hello))\n  (func $hello (result i32)\n    (i32.const 16)\n  )\n)\n```\n\n### Browser/client end (.js)\n\n``` javascript\nfunction utf8ToString(h, p) {\n  let s = \"\";\n  for (i = p; h[i]; i++) {\n    s += String.fromCharCode(h[i]);\n  }\n  return s;\n}\n\nlet m = new WebAssembly.Instance(new WebAssembly.Module(buffer));\nlet h = new Uint8Array(m.exports.memory.buffer);\nlet p = m.exports.hello();\nlog(utf8ToString(h, p))\n```\n\n### Output\n```\nHello World\n```\n\n[Back to top](#examples)\n\n-----\n\n## Option 2\n\n\u003e Using an js import function\n\n[WasmFiddle](https://wasdk.github.io/WasmFiddle/?jn7tx)\n\n### C source (.c)\n\n``` C\nvoid printHW();\n\nvoid hello() {\n  printHW();\n}\n```\n\n### WebAssembly syntax tree (.wast)\n\n``` LISP\n(module\n  (type $FUNCSIG$v (func))\n  (import \"env\" \"printHW\" (func $printHW))\n  (table 0 anyfunc)\n  (memory $0 1)\n  (export \"memory\" (memory $0))\n  (export \"hello\" (func $hello))\n  (func $hello\n    (call $printHW)\n  )\n)\n```\n\n### Browser/client end (.js)\n\n``` Javascript \nfunction printHW() {\n  log(\"HELLO WORLD\");\n}\n\nlet i = { env:{ printHW: printHW } };\nlet m = new WebAssembly.Instance(new WebAssembly.Module(buffer), i);\nlet h = new Uint8Array(m.exports.memory.buffer);\nm.exports.hello();\n```\n\n### Output\n\n```\nHELLO WORLD\n```\n\n[Back to top](#examples)\n\n-----\n\n## Option 3\n\n\u003e Writing out 'HELLO WORLD' into memory and observing the change via dumps \n\n[WasmFiddle](https://wasdk.github.io/WasmFiddle/?15zq3v)\n\n### C source (.c)\n\n``` C \nchar inputs[128];\n\nchar* getInputs() {\n  return \u0026inputs[0];\n}\n\nint main() {\n  int i = 0;\n  inputs[i++] = 'H';\n  inputs[i++] = 'E';\n  inputs[i++] = 'L';\n  inputs[i++] = 'L';  \n  inputs[i++] = 'O';\n  inputs[i++] = ' ';\n  inputs[i++] = 'W';\n  inputs[i++] = 'O';\n  inputs[i++] = 'R';\n  inputs[i++] = 'L';  \n  inputs[i++] = 'D';  \n  inputs[i++] = 0;\n  return 42;\n}\n```\n\n### WebAssembly syntax tree (.wast)\n\n``` LISP\n(module\n  (table 0 anyfunc)\n  (memory $0 1)\n  (export \"memory\" (memory $0))\n  (export \"getInputs\" (func $getInputs))\n  (export \"main\" (func $main))\n  (func $getInputs (result i32)\n    (i32.const 16)\n  )\n  (func $main (result i32)\n    (i32.store offset=16\n      (i32.const 0)\n      (i32.const 1280066888)\n    )\n    (i32.store16 offset=20\n      (i32.const 0)\n      (i32.const 8271)\n    )\n    (i32.store offset=22 align=2\n      (i32.const 0)\n      (i32.const 1280462679)\n    )\n    (i32.store16 offset=26\n      (i32.const 0)\n      (i32.const 68)\n    )\n    (i32.const 42)\n  )\n)\n```\n\n### Browser/client end (.js)\n\n``` javascript\nvar wasmModule = new WebAssembly.Module(wasmCode);\nvar imp = { };\nvar wasmInstance = new WebAssembly.Instance(wasmModule, imp);\nconst arrayBuffer = wasmInstance.exports.memory.buffer;\nconst buffer = new Uint8Array(arrayBuffer);\nconst BYTE_LENGTH = 64;\nlet offset = wasmInstance.exports.getInputs();\nlib.dumpMemory(buffer, offset, BYTE_LENGTH);\nlog(wasmInstance.exports.main());\nlib.dumpMemory(buffer, offset, BYTE_LENGTH);\n```\n\n### OUTPUT\n\n```\n00000010 00000000000000000000000000000000 ................\n00000020 00000000000000000000000000000000 ................\n00000030 00000000000000000000000000000000 ................\n00000040 00000000000000000000000000000000 ................\n\n42\n00000010 48454C4C4F20574F524C440000000000 HELLO WORLD.....\n00000020 00000000000000000000000000000000 ................\n00000030 00000000000000000000000000000000 ................\n00000040 00000000000000000000000000000000 ................\n\n```\n\n[Back to top](#examples)\n\n-----\n\n## Option 4\n\n\u003e Print HELLO WORLD by reading memory\n\n[WasmFiddle](https://wasdk.github.io/WasmFiddle/?1hayln)\n\n### C source (.c)\n\n``` C\nchar inputs[128];\n\nchar* getInputs() {\n  return \u0026inputs[0];\n}\n\nint setMessage() {\n  int i = 0;\n  inputs[i++] = 'H';\n  inputs[i++] = 'E';\n  inputs[i++] = 'L';\n  inputs[i++] = 'L';  \n  inputs[i++] = 'O';\n  inputs[i++] = ' ';\n  inputs[i++] = 'W';\n  inputs[i++] = 'O';\n  inputs[i++] = 'R';\n  inputs[i++] = 'L';  \n  inputs[i++] = 'D';  \n  inputs[i] = 0;\n  return i;\n}\n```\n\n### WebAssembly syntax tree (.wast)\n\n``` LISP\n(module\n  (table 0 anyfunc)\n  (memory $0 1)\n  (export \"memory\" (memory $0))\n  (export \"getInputs\" (func $getInputs))\n  (export \"setMessage\" (func $setMessage))\n  (func $getInputs (result i32)\n    (i32.const 16)\n  )\n  (func $setMessage (result i32)\n    (i32.store offset=16\n      (i32.const 0)\n      (i32.const 1280066888)\n    )\n    (i32.store16 offset=20\n      (i32.const 0)\n      (i32.const 8271)\n    )\n    (i32.store offset=22 align=2\n      (i32.const 0)\n      (i32.const 1280462679)\n    )\n    (i32.store16 offset=26\n      (i32.const 0)\n      (i32.const 68)\n    )\n    (i32.const 11)\n  )\n```\n\n### Browser/client end (.js)\n\n``` Javascript\nfunction utf8ToString(h, p) {\n  let s = \"\";\n  for (i = p; h[i]; i++) {\n    s += String.fromCharCode(h[i]);\n  }\n  return s;\n}\n\nvar wasmModule = new WebAssembly.Module(wasmCode);\nvar imp = { };\nvar wasmInstance = new WebAssembly.Instance(wasmModule, imp);\nconst arrayBuffer = wasmInstance.exports.memory.buffer;\nconst buffer = new Uint8Array(arrayBuffer);\nconst BYTE_LENGTH = 64;\nlet offset = wasmInstance.exports.getInputs();\nlog(wasmInstance.exports.setMessage());\nlog(utf8ToString(buffer, offset));\n```\n\n### OUTPUT\n\n```\n11\nHELLO WORLD\n```\n\n[Back to top](#examples)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgsstdio%2Fhello-webassembly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftgsstdio%2Fhello-webassembly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgsstdio%2Fhello-webassembly/lists"}