{"id":13670643,"url":"https://github.com/philipaconrad/mini-vm","last_synced_at":"2025-04-27T13:32:39.809Z","repository":{"id":8289860,"uuid":"9829043","full_name":"philipaconrad/mini-vm","owner":"philipaconrad","description":"A small, register-based virtual machine (bytecode interpreter) in C. [MIT License]","archived":true,"fork":false,"pushed_at":"2015-11-25T21:35:25.000Z","size":1074,"stargazers_count":66,"open_issues_count":0,"forks_count":32,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-11T08:43:05.467Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"philipaconrad.github.io/mini-vm/","language":"C","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/philipaconrad.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-03T05:00:59.000Z","updated_at":"2024-10-20T17:53:42.000Z","dependencies_parsed_at":"2022-08-17T21:50:48.148Z","dependency_job_id":null,"html_url":"https://github.com/philipaconrad/mini-vm","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipaconrad%2Fmini-vm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipaconrad%2Fmini-vm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipaconrad%2Fmini-vm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipaconrad%2Fmini-vm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philipaconrad","download_url":"https://codeload.github.com/philipaconrad/mini-vm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251145652,"owners_count":21543075,"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":[],"created_at":"2024-08-02T09:00:46.995Z","updated_at":"2025-04-27T13:32:34.790Z","avatar_url":"https://github.com/philipaconrad.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"mini-vm\r\n=======\r\n\r\nA small, register-based virtual machine (bytecode interpreter) in C.\r\n\r\n\r\n### How it works\r\n\r\nEach bytecode instruction is 4 bytes long.\r\n\r\n      0   1   2   3\r\n    +---+---+---+---+\r\n    | A | B | C | D |\r\n    +---+---+---+---+\r\n\r\n    A - Instruction ID. This is the index of the function in the function table you wish to call.\r\n    B - Register #1. (usually the destination register)\r\n    C - Register #2. (usually an argument source register)\r\n    D - Register #3. (usually an argument source register)\r\n\r\nInstead of the usual switch/case-based architecture most bytecode interpreters \r\nuse, I chose to go with a table of function pointers whose indices correspond \r\nwith particular instruction IDs.\r\n\r\nAn interpreter can be initialized by calling `initVMContext()` and supplying \r\nthe appropriate parameters.\r\n\r\nThe interpreter's state has to be advanced one instruction at a time by \r\nby calling `stepVMContext()` repeatedly. In the example programs, this is \r\ntypically done with a simple `while` loop.\r\n\r\nTermination is not accounted for by default. Adding a custom **halt** \r\ninstruction or some sort of status register are both plausible solutions.\r\n\r\n\r\n### Build\r\n\r\n - On *nix platforms, just type `make` to build mini-vm as a static library. To build the examples, just type `make test` in each example's directory.\r\n - For Windows: An MSVC 2010 Project file is provided under `/msvc`. Double click on it to generate a solution file.\r\n\r\n\r\n### Documentation\r\n\r\n - Look under the `/examples` folder to see examples of mini-vm in action.\r\n - Also worth reading: [the project's site][1]. The bytecode format and the structure of the VM are explained here.\r\n\r\n\r\n### MIT License\r\n\r\nCopyright (c) 2013 Philip Conrad.\r\nAll rights reserved.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE.\r\n\r\n\r\n   [1]: http://philipaconrad.github.io/mini-vm/\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilipaconrad%2Fmini-vm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilipaconrad%2Fmini-vm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilipaconrad%2Fmini-vm/lists"}