{"id":27066085,"url":"https://github.com/maxrt101/xvm","last_synced_at":"2026-02-14T13:01:17.885Z","repository":{"id":133619867,"uuid":"467237987","full_name":"maxrt101/xvm","owner":"maxrt101","description":"X Virtual Machine","archived":false,"fork":false,"pushed_at":"2025-01-16T10:18:54.000Z","size":178,"stargazers_count":3,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T18:51:31.479Z","etag":null,"topics":["assembly","cpp17","vm"],"latest_commit_sha":null,"homepage":"","language":"C++","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/maxrt101.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":"2022-03-07T19:49:08.000Z","updated_at":"2023-01-06T22:16:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"648c4134-0666-4554-b29e-c45b47787e3a","html_url":"https://github.com/maxrt101/xvm","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/maxrt101/xvm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxrt101%2Fxvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxrt101%2Fxvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxrt101%2Fxvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxrt101%2Fxvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxrt101","download_url":"https://codeload.github.com/maxrt101/xvm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxrt101%2Fxvm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29444022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T12:43:28.304Z","status":"ssl_error","status_checked_at":"2026-02-14T12:43:14.160Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["assembly","cpp17","vm"],"created_at":"2025-04-05T18:34:57.488Z","updated_at":"2026-02-14T13:01:17.854Z","avatar_url":"https://github.com/maxrt101.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"```\n ██╗  ██╗██╗   ██╗███╗   ███╗\n ╚██╗██╔╝██║   ██║████╗ ████║\n  ╚███╔╝ ██║   ██║██╔████╔██║\n  ██╔██╗ ╚██╗ ██╔╝██║╚██╔╝██║\n ██╔╝ ██╗ ╚████╔╝ ██║ ╚═╝ ██║\n ╚═╝  ╚═╝  ╚═══╝  ╚═╝     ╚═╝\n \n X Virtual Machine\n```\n\n## About\nThis is a custom virtual machine with custom instruction set \u0026 assembly language.  \n\n## How To Install\nPrerequisites: `clang` or `gcc`, `make`  \nSteps:  \n  - Clone the repo\n  - Run `make`\n  - Run `./build/bin/xvm help`\n\n## Instruction Set\n\n```\nMNEMONIC      ARGS          MODES         DESC\npush          VALUE         IMM           Pushes value onto stack\npop           [COUNT]       IMM           Pops COUNT values from stack (defalt 1)\ndup                         IMM           Dups top value\nrol                         IMM           Rolls 2 top values\nrol3                        IMM           Rolls 3 top values\nderef8        [ADDR]        IMM     STK   Dereferences an address (pointer to byte)\nderef16       [ADDR]        IMM     STK   Dereferences an address (pointer to short)\nderef32       [ADDR]        IMM     STK   Dereferences an address (pointer to int)\nstore8        [ADDR]        IMM     STK   Stores 8 bits from top stack value to ADDR\nstore16       [ADDR]        IMM     STK   Stores 16 bits from top stack value to ADDR\nstore32       [ADDR]        IMM     STK   Stores 32 bits from top stack value to ADDR\nload8         [ADDR]        IMM     STK   Pushes 8 bits from ADDR onto stack\nload16        [ADDR]        IMM     STK   Pushes 16 bits from ADDR onto stack\nload32        [ADDR]        IMM     STK   Pushes 32 bits from ADDR onto stack\nadd           [OP1 [OP2]]   IMM IND STK   Adds 2 values (IMM or from stack)\nsub           [OP1 [OP2]]   IMM IND STK   Subtracts 2 values (IMM or from stack)\nmul           [OP1 [OP2]]   IMM IND STK   Multiplies 2 values (IMM or from stack)\ndiv           [OP1 [OP2]]   IMM IND STK   Divides 2 values (IMM or from stack)\nequ           [OP1 [OP2]]   IMM IND STK   Compares 2 values (IMM or from stack)\nlt            [OP1 [OP2]]   IMM IND STK   Less Then 2 values (IMM or from stack)\ngt            [OP1 [OP2]]   IMM IND STK   Greater Then 2 values (IMM or from stack)\ndec           [ADDR]            IND STK   Decrement\ninc           [ADDR]            IND STK   Increment\nshl           [COUNT]           IND STK   Shift Left\nshr           [COUNT]           IND STK   Shift Right\nand           [OP1 [OP2]]   IMM     STK   Bitwise And\nor            [OP1 [OP2]]   IMM     STK   Bitwise Or\njump          [ADDR/LABEL]  IMM IND STK   Jumps to address/label (IMM or from stack)\njumpt         [ADDR/LABEL]  IMM IND STK   Jumps if top stack value is true\njumpf         [ADDR/LABEL]  IMM IND STK   Jumps if top stack value is false\ncall          [ADDR/LABEL]  IMM IND STK   Calls an address/label (IMM or from stack)\nsyscall       NUMBER        IMM           Calls a system function\nret                         IMM           Returns from procedure\nnop                         IMM           No Operation\nhalt                        IMM           Halts execution\nreset                       IMM           Resets VM\n```\n```\nIMM - Immediate\nIND - Indirect\nSTK - Stack\n```\n\n## Helper Instructions\n```\n%def TYPE NAME VALUE\n%include \"FILE\"\n%syscall NAME NUMBER\n%data TYPE NAME VALUE...\n%repeat TYPE VALUE ADDRESS\n%repeat_until TYPE VALUE ADDRESS\n%define NAME VALUE\n%undef\n%ifdef NAME\n%ifndef NAME\n%else\n%endif\n```\n\n## Assembly\n#### Instructions\nInstruction's mnemonics are typed in followed by 0 or more parameters, that given instruction can take\n```\npush    10\nadd     50\nsub     9   5\nmul\nhalt\n```\n\n#### Lables\nLabels are declared by typing in lable name folowed by a colon. When a label is mentioned somewhere in code, its address is used\n```\nlabel:\njump    label\n```\n\n#### Stack\nStack is key a component of the vm. It serves as a temporary storage for variables. There are several stack manipulation instructions\n```\npush    10      ; Pushes a value onto the stack\npop             ; Pops a value from the stack\nrol             ; Switches 2 top values\n```\n\n#### Variables \u0026 Data\nData is stored in RAM (which also holds program code). There are 4 basic types `i8` `i16` `i32` `str`. Variables are declared using `%def` helper instruction. Usage: `%def TYPE NAME VALUE`. When the variable is referenced, its address is used.\n```\n%def i8  c  'A'\n%def i8  x  156\n%def i16 y  1024\n%def i32 z  16384\n%def str s  \"Hello, World!\"\n```\nTo load \u0026 store values on the stack there are `loadX` and `storeX` instructions\n```\nload8     c\nload8     x\nload16    y\nload32    z\nload8     s    ; Will load first character of 's'\n\npush      10\nstore8    c\npush      10\nstore8    x\npush      10\nstore16   y\npush      10\nstore32   z\n```\nTo manually dereference an address use `derefX` instruction\n```\npush      s\nderef8\npush      y\nderef16\npush      z\nderef32\n```\nTo declare an array, use `%data`. Usage: `%data TYPE NAME VALUE..`\n```\n%data i16 a 10 38 183 28\n```\n\n#### Conditions\nThere are `equ`, `lt` and `gt` for comparing values\n\n#### Control Flow\nUnconditional jump is performed using `jump` instruction. To jump only if top stack value is true, use `jumpt`, otherwise - `jumpf`\n\n#### Functions \u0026 Calls\nFunctions are declared with labels. To call a function use `call` instruction, to return from a function `ret` is used.\nTo pass or return parameters, use the stack.\n```\ncall print_newline\n...\nprint_newline:\n  push '\\n'\n  syscall putc\n  ret\n```\n\n#### Syscalls\nSyscalls are the bridge to the C++, through them xvm program can interface with the host system and perform, for example, io operations.\nTo invoke a syscall use `syscall` instruction. To create an alias for syscall, use `%syscall`. Usage: `%syscall NAME NUMBER`\n```\n%syscall putc 20\nsyscall putc\n```\n\n#### Preprocessor\nxvm assembler supports C-like macros (to some extent).  \nSupported macros are `%define`, `%undef`, `%ifdef`, `%ifndef`, `%else`, `%endif`\n\n#### Code Manipulation\n`%repeat TYPE VALUE COUNT`  \n`%repeat_until TYPE VALUE ADDRESS`  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxrt101%2Fxvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxrt101%2Fxvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxrt101%2Fxvm/lists"}