{"id":13418736,"url":"https://github.com/gto76/comp-cpp","last_synced_at":"2025-10-25T19:12:30.708Z","repository":{"id":32637074,"uuid":"36223284","full_name":"gto76/comp-cpp","owner":"gto76","description":"Comp Mark I – Simple 4-bit virtual computer","archived":false,"fork":false,"pushed_at":"2024-03-09T01:16:19.000Z","size":307,"stargazers_count":344,"open_issues_count":0,"forks_count":32,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-29T20:06:18.142Z","etag":null,"topics":["educational-software","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gto76.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":"2015-05-25T09:52:20.000Z","updated_at":"2025-03-16T06:58:28.000Z","dependencies_parsed_at":"2024-10-26T21:17:35.075Z","dependency_job_id":"451195d2-9cc9-4f03-bdac-cfc8a4e14c7c","html_url":"https://github.com/gto76/comp-cpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gto76%2Fcomp-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gto76%2Fcomp-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gto76%2Fcomp-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gto76%2Fcomp-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gto76","download_url":"https://codeload.github.com/gto76/comp-cpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399877,"owners_count":20932876,"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":["educational-software","virtual-machine"],"created_at":"2024-07-30T22:01:06.301Z","updated_at":"2025-10-25T19:12:25.646Z","avatar_url":"https://github.com/gto76.png","language":"C++","funding_links":[],"categories":["TODO scan for Android support in followings"],"sub_categories":[],"readme":"Comp\n====\n\n#### Simple 4-bit/1 Hz virtual computer for learning purposes\n\n![screenshot](doc/screenshot.png)\n\nFor quick start see [**HOW TO RUN**](#how-to-run-on).\n\nMemory\n------\n```\ninstructions - 4 bits\n  |  +-- addresses - 4 bits\n  v  v\n----***-  \u003c- 0  ----\n--*-**-*  \u003c- 1  ---*\n---***--  \u003c- 2  --*-\n---*****  \u003c- 3  --**\n----***-  \u003c- 4  -*--\n---***-*  \u003c- 5  -*-*\n----**--  \u003c- 6  -**-\n---****-  \u003c- 7  -***\n-***---*  \u003c- 8  *---\n-*--****  \u003c- 9  *--*\n--------  \u003c- 10 *-*-\n--------  \u003c- 11 *-**\n--------  \u003c- 12 **--\n-------*  \u003c- 13 **-*\n-------*  \u003c- 14 ***-\n\u003cOUTPUT\u003e  \u003c- 15 ****\n```\n\n* Execution starts at the first address (0). \n* Execution stops when program reaches last address (15).\n* Whatever gets written to the last address is sent to the printer.\n* When reading from the last address (15), we get a random byte value.\n* CPU has one 8 bit register.\n\nInstruction set\n---------------\n\n* `READ     ----` - Copies the value at the specified address into register.  \n* `WRITE    ---*` - Copies value of the register to the specified address.  \n* `ADD      --*-` - Adds value at the specified address to the value of the register, and writes result to the register. If the result is bigger than the maximum possible value (255 = ********) then 255 gets written.  \n* `SUBTRACT --**` - Subtracts value at the speicfied address from the value of the register, and writes result to the register. If the result is smaller than 0 then 0 gets written.  \n* `JUMP     -*--`  - Changes the value of the program counter to the specified address, meaning that in the next cycle execution will continue at that address.  \n* `IF MAX   -*-*` - Jumps to the specified address if register has value 255 = `********`. \n* `IF MIN   -**-` - Jumps to the specified address if register has value 0 = `--------`. \n* `SHIFT R -***` - Moves every bit of the register one spot to the right. This way rightmost bit gets lost, and a leftmost becomes '*-*'. This is the only instruction that doesn't use the address part, making the last four bits irrelevant.  \n* Any instruction that is not defined above is interpreted as `READ ----` instruction.\n\nHow to run on…\n--------------\n\n### Windows\n\n* Install *Tiny Core Linux* on *VirtualBox* using this [**instructions**](https://github.com/gto76/my-linux-setup/tree/gh-pages/conf-files/tiny-core-linux).\n* Run the *UNIX* commands.\n\n### UNIX\n```\n$ git clone https://github.com/gto76/comp-cpp.git\n$ cd comp-cpp\n$ ./run\n```\n\nOther versions\n--------------\n* [**Mark II**](https://github.com/gto76/comp-m2), model with separate address space for code and data, and with more instructions. Programs can be saved and loaded and it can run without the interface (instead of a printer, it then uses stdout). Also input can be piped in.  \n\n![screenshot](https://github.com/gto76/comp-m2/raw/master/doc/screenshot.png)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgto76%2Fcomp-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgto76%2Fcomp-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgto76%2Fcomp-cpp/lists"}