{"id":25031735,"url":"https://github.com/ThatOneGin/choi-toolkit","last_synced_at":"2025-10-20T19:30:26.504Z","repository":{"id":275974497,"uuid":"927094945","full_name":"ThatOneGin/choi","owner":"ThatOneGin","description":"Simple and low memory usage virtual machine.","archived":false,"fork":false,"pushed_at":"2025-02-05T15:02:46.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T16:20:50.973Z","etag":null,"topics":["assembler","c","compiler","toolkit","virtual-machine"],"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/ThatOneGin.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":"2025-02-04T11:53:34.000Z","updated_at":"2025-02-05T15:02:49.000Z","dependencies_parsed_at":"2025-02-05T16:20:56.525Z","dependency_job_id":"6a8cd1f0-b78e-461f-a419-5fc3ed032ac0","html_url":"https://github.com/ThatOneGin/choi","commit_stats":null,"previous_names":["thatonegin/choi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThatOneGin%2Fchoi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThatOneGin%2Fchoi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThatOneGin%2Fchoi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThatOneGin%2Fchoi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThatOneGin","download_url":"https://codeload.github.com/ThatOneGin/choi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237387085,"owners_count":19301898,"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":["assembler","c","compiler","toolkit","virtual-machine"],"created_at":"2025-02-05T22:44:19.400Z","updated_at":"2025-10-20T19:30:26.486Z","avatar_url":"https://github.com/ThatOneGin.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Choi VM\n\nChoivm is a virtual machine with a goal of being small and portable.\nIt has its own assembly language called casm (choi assembly, a interface with pratically no abstraction for its bytecode)\n\n## Building:\n\nCompile cbone.c and execute.\n\n```shell\n$ cc -o cbone cbone.c \u0026\u0026 ./cbone\n```\n\nExecuting cbone will generate these following 3 executables:\n\nchoivm: the virtual machine bytecode interpreter.\n\nchoiasm: the assembly compiler.\n\nchoi_disasm: the disassembler.\n\n## Syntax:\n\nchoi_assembly:\n\n```\n@proc main\n  @mem R1 \"Hello, choi!\"\n  write R1\n```\n\n## quickstart\n\n### Operands\n\n```push```\n\npush a value to a register.\n\n```\n  push R1 69\n```\n\n```mov```\n\nmove values between registers.\n\n```\n  mov R1 R2\n```\n\n```add```\n\nsum two registers as integers.\n\n```\n  add R1 R2\n```\n\n```sub```\n\nsubtract two registers as integers\n\n```\n  sub R1 R2\n```\n\n```div```\n\ndivide two registers as integers.\n\n```\n  div R1 R2\n```\n\n```mul```\n\nmultiply two registers as integers.\n\n```\n  mul R1 R2\n```\n\n```dump```\n\ndump a register to stdout as integer\n\n```\n  dump R1\n```\n\n```jmp```\n\nChange the instruction pointer to a certain location.\n\n```\n  jmp hello-procedure\n```\n\n```jz```\n\nChange the instruction pointer to a certain location if the last element in the stack is zero.\n\n```\n  jz hello-procedure\n```\n\n```jnz```\n\nChange the instruction pointer to a certain location if the last element in the stack is not zero.\n\n```\n  jnz hello-procedure\n```\n\n```call```\n\nCall a procedure, operand call makes the use of ret instruction possible by pushing the current address in the program.\n\n```\n  call hello-procedure\n```\n\n```drop```\n\nset a register to zero\n\n```\n  drop R1\n```\n\n```write```\n\nwrites N bytes of an certain address in the constant pool\n\n```\n  write R1\n```\n\n```syscall```\n\nlooks up at the registers and execute a special function based on the R1 register.\n\n```\n  push R1 1\n  push R2 0\n  @mem R3 \"Hello, world!\"\n  syscall\n```\n\n```halt```\n\nstop execution and ends the program.\n\n```\n  halt\n```\n\n```cmp```\n\nsubtract two registers and push result to the stack\n\n```\n  cmp R1 R2\n```\n\n```inc```\n\nincrement a register by one\n\n```\n  inc R3\n```\n\n### Special operands (operate stack, pool and procedures)\n\n```@proc```\n\ndeclares a procedure, while not visible at bytecode itself, it can be useful for cross referencing blocks\n\n```\n  @proc hello-procedure\n```\n\n```@mem```\n\npush pointer/string to constant pool and its length to a register.\n\n\n```\n  @mem R1 \"Hello, world\"\n```\n\n```@pop```\n\npops an element of the stack to a register\n\n```\n  @pop R1\n```\n\n```@push```\n\npush a value to the stack\n\n```\n  @push 69\n```\n\n## confusion\n\noperators preceded with '@' are different.\n\npush is not the same as @push\n\npush will push a value to a register\n\n@push will push a value to the stack\n\n## Todos\n\n- [ ] meta programming features to the assembly.\n\n- [ ] handle strings like a sane person.\n\n- [ ] a debugger for the bytecode.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThatOneGin%2Fchoi-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FThatOneGin%2Fchoi-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThatOneGin%2Fchoi-toolkit/lists"}