{"id":25635104,"url":"https://github.com/rybarix/lilvm","last_synced_at":"2025-02-22T23:19:20.790Z","repository":{"id":218776330,"uuid":"747322995","full_name":"rybarix/lilvm","owner":"rybarix","description":"Little toy virtual machine written in javascript.","archived":false,"fork":false,"pushed_at":"2024-03-15T08:43:18.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-20T00:49:53.054Z","etag":null,"topics":["javascript","javascript-vm","vm"],"latest_commit_sha":null,"homepage":"https://rybarix.github.io/lilvm/","language":"JavaScript","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/rybarix.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}},"created_at":"2024-01-23T17:49:39.000Z","updated_at":"2024-03-15T08:43:05.000Z","dependencies_parsed_at":"2024-01-23T19:41:55.793Z","dependency_job_id":null,"html_url":"https://github.com/rybarix/lilvm","commit_stats":null,"previous_names":["sandrorybarik/lilvm","rybarix/lilvm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rybarix%2Flilvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rybarix%2Flilvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rybarix%2Flilvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rybarix%2Flilvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rybarix","download_url":"https://codeload.github.com/rybarix/lilvm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240246218,"owners_count":19771079,"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","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":["javascript","javascript-vm","vm"],"created_at":"2025-02-22T23:19:20.036Z","updated_at":"2025-02-22T23:19:20.761Z","avatar_url":"https://github.com/rybarix.png","language":"JavaScript","readme":"# lilVM\n\n- lilVM is implementation of small virtual machine including tokenizer, parser and vm itself.\n- lilVM does not try emulate real hardware or CPU\n\n## Running the VM\n\nEither go to [lilVM online playground](http://rybarix.github.io/lilvm)\n\nor run locally:\n\n```js\nimport { VirtualMachine } from './vm.js';\nconst vm = new VirtualMachine({ onLog: (value) =\u003e {\n\t console.info(value) // onLog is called when `PRINT :REGISTER:` is called.\n\t},\n\tregisterCount: 10, // registers = Int32Array(10) (10 is max)\n\tmemorySize: 1024, // memory = Int32Array(1024)\n\tmaxSteps: 10000, // avoiding infinite loops\n});\nvm.load(`YOUR CODE HERE`);\nvm.run();\n```\n\n## Supported instructions\n\nAvailable registers by default: `R0` - `R9`.\n\n\n|Instruction|:Description|\n|:-------------|:-------------|\n|`INC` RX \t| Increments value at register RX |\n|`DEC` RX \t| Decrements value at register RX |\n|`SET` :number: RX \t| Sets decimal number value in register RX |\n|`LOAD` RA RD \t| Loads value from memory at address RA (register value) to destination register RD. |\n|`LOADIM` :number: RD \t| Loads decimal number value to destination register RD. |\n|`STORE` RA RV \t| Stores value to memory at address RA (register value) from value register RV. |\n|`EQ` RX RY @:label: \t| Compares RX, RY values and if RX == RY jumps to @:label: |\n|`NEQ` RX RY @:label: \t| Compares RX, RY values and if RX != RY jumps to @:label: |\n|`LT` RX RY @:label: \t| Compares RX, RY values and if RX \u003c RY jumps to @:label: |\n|`LTE` RX RY @:label: \t| Compares RX, RY values and if RX \u003c= RY jumps to @:label: |\n|`GT` RX RY @:label: \t| Compares RX, RY values and if RX \u003e RY jumps to @:label: |\n|`GTE` RX RY @:label: \t| Compares RX, RY values and if RX \u003e= RY jumps to @:label: |\n|`ADD` RA RB RC \t| Adds registers RA, RB. RC = RA + RB |\n|`SUB` RA RB RC \t| Subtracts registers RA, RB. RC = RA - RB. |\n|`MUL` RA RB RC \t| Integer multiplication of registers RA, RB. RC = RA * RB. |\n|`DIV` RA RB RC \t| Integer division of registers RA, RB. RC = RA / RB. |\n|`MOD` RA RB RC \t| Mod division of registers RA, RB. RC = RA % RB. |\n\n## Limitations\n- Integer overflows are not handled.\n- Supports only integer arithmetic.\n- Writing out of bounds memory is undefined behavior.\n\n## Example program\n\n```txt\nSET 0 R0            ; init registers for loop\nSET 100 R1\n\nlooplab:            ; loop label\n\nSTORE R0 R0         ; at addr R0 store R0\nINC R0              ; increment R0\n\nNEQ R0 R1 @looplab  ; if R0 != R1 jump\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frybarix%2Flilvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frybarix%2Flilvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frybarix%2Flilvm/lists"}