{"id":18764470,"url":"https://github.com/tripplyons/wasm-subleq","last_synced_at":"2025-08-26T07:03:37.272Z","repository":{"id":81907876,"uuid":"270465317","full_name":"tripplyons/wasm-subleq","owner":"tripplyons","description":"A simple and fast Virtual Machine written in raw WebAssembly (WAT)","archived":false,"fork":false,"pushed_at":"2020-06-23T22:38:59.000Z","size":10,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-19T13:18:13.428Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"WebAssembly","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tripplyons.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-06-07T23:48:24.000Z","updated_at":"2021-07-02T12:28:41.000Z","dependencies_parsed_at":"2023-11-01T00:31:58.744Z","dependency_job_id":null,"html_url":"https://github.com/tripplyons/wasm-subleq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tripplyons/wasm-subleq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripplyons%2Fwasm-subleq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripplyons%2Fwasm-subleq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripplyons%2Fwasm-subleq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripplyons%2Fwasm-subleq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tripplyons","download_url":"https://codeload.github.com/tripplyons/wasm-subleq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripplyons%2Fwasm-subleq/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272186219,"owners_count":24888333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-07T18:29:56.594Z","updated_at":"2025-08-26T07:03:37.214Z","avatar_url":"https://github.com/tripplyons.png","language":"WebAssembly","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WASM Subleq\nA simple Virtual Machine written in raw WebAssembly (WAT)\n\n## Why?\n\n- It works in the browser (or other WASM environments\n- It is very fast: about **100,000,000 instructions/second** on my laptop's Chrome browser (twice as fast on Node.js on the same machine)\n- It is simple: anyone can program a compatible VM in less than 20 lines of JavaScript/Python code\n- It is so easy to port that you can run programs anywhere!\n\n## Usage\n\nUse the [subleq.wasm](subleq.wasm) module like any other WebAssembly module.\n\n## API\n\n```\nmodule.runInstr() - Run the current instruction\nmodule.runInstrs(num) - run runInstr num times (faster than looping in JS)\nmodule.set(position, value) - memory[position] = value\nmodule.get(position) - return memory[position]\nmodule.setIp(value) - instructionPointer = value\nmoudle.getIp() - return instructionPointer\n```\n\n## Development Setup\n\nRun the following commands to set things up to run `index.js`:\n\n```\ncd wasm-subleq\nnpm i\n```\n\nYou can also install [WABT](https://github.com/WebAssembly/wabt) if you want to compile the WAT file to WASM.\n\n## What is Subleq?\n\nSubleq is an [OISC](https://en.wikipedia.org/wiki/One-instruction_set_computer). An OISC is a computer that is fully operational with only one instruction.\n\n### How does it work?\n\nThis implementation uses a list of signed 32-bit integers as memory.\n\nEach instruction operates on 3 parameters (A, B, and C). It is implied which instruction you are using because there is only one.\n\nThe basic idea of instruction (C-like syntax)\n\n`*b -= *a; if(*b \u003c= 0) goto c;` **SUB**tract, and **L**ess than or **EQ**ual to\n\nJavaScript implementation pseudocode\n```javascript\nmemory = [1, 2, 3, ...]\ninstructionPointer = 0\n\nwhile(1) {\n    // SUB:\n    // *b -= *a\n    memory[memory[instructionPointer+1]] -= memory[memory[instructionPointer]]\n    // LEQ:\n    // if(*b \u003c= 0) {\n    if(memory[memory[instructionPointer+1]] \u003c= 0) {\n        // goto C\n        instructionPointer = memory[instructionPointer+1]\n    } else {\n        // move on to the next instruction\n        instructionPointer += 3\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftripplyons%2Fwasm-subleq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftripplyons%2Fwasm-subleq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftripplyons%2Fwasm-subleq/lists"}