{"id":16323681,"url":"https://github.com/im-rises/cpu_intel_8080_emulator","last_synced_at":"2025-05-14T14:35:08.052Z","repository":{"id":162390148,"uuid":"628759949","full_name":"Im-Rises/cpu_intel_8080_emulator","owner":"Im-Rises","description":"CPU emulation of the intel 8080 in rust 🦀","archived":false,"fork":false,"pushed_at":"2023-05-06T04:34:55.000Z","size":51,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-17T04:26:22.844Z","etag":null,"topics":["8080","cpu","emulation","intel","intel8080","rust","space-invaders"],"latest_commit_sha":null,"homepage":"https://im-rises.github.io/space-invaders-arcade-emulator-website/","language":"Rust","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/Im-Rises.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":"2023-04-16T23:13:08.000Z","updated_at":"2023-05-10T17:15:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"7e13f703-a727-4eaf-b402-86153ac0ea43","html_url":"https://github.com/Im-Rises/cpu_intel_8080_emulator","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/Im-Rises%2Fcpu_intel_8080_emulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Im-Rises%2Fcpu_intel_8080_emulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Im-Rises%2Fcpu_intel_8080_emulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Im-Rises%2Fcpu_intel_8080_emulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Im-Rises","download_url":"https://codeload.github.com/Im-Rises/cpu_intel_8080_emulator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254160631,"owners_count":22024574,"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":["8080","cpu","emulation","intel","intel8080","rust","space-invaders"],"created_at":"2024-10-10T22:55:24.347Z","updated_at":"2025-05-14T14:35:08.032Z","avatar_url":"https://github.com/Im-Rises.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cpu_intel_8080_emulator\n\n\u003cp align=\"center\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/Rust-000000?style=for-the-badge\u0026logo=rust\u0026logoColor=white\" alt=\"rustLogo\" style=\"height:60px;\"/\u003e\n\u003c/p\u003e\n\n## Description\n\nHere is a Cycle-accurate Intel 8080 CPU emulator written in Rust.\n\nI used this processor for my Space Invaders project. You can find\nit 🚀🚀[here](https://github.com/Im-Rises/space_invaders_arcade_emulator)🚀🚀.\n\nAnd also the web version 🚀🚀[here](https://im-rises.github.io/space-invaders-arcade-emulator-website/)🚀🚀.\n\nThis emulator passed all the tests of the Intel 8080 CPU. You can find the tests roms in the `test_roms` folder.\n\n- [x] cpudiag.bin\n- [x] TST8080.COM\n- [x] 8080PRE.COM\n- [x] CPUTEST.COM\n- [x] 8080EXER.COM\n- [x] 8080EXM.COM\n\nYou can find some screenshots and video gameplay of the Space Invaders emulator below.\n\n## Images\n\n| Title screen                                                                                                           | Game screen                                                                                                            |\n|------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|\n| ![title_screen](https://user-images.githubusercontent.com/59691442/181736212-8d8cfa4e-4c85-48ce-92ac-1165dcb73891.png) | ![playing_demo](https://user-images.githubusercontent.com/59691442/181736224-da769503-2a2e-45d6-af2c-9204a96e78e1.png) |\n\n| Taito Cop Easter Egg                                                                                                           | Score advance table with Invaders                                                                                             |\n|--------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| ![taito_cop_easter_egg](https://user-images.githubusercontent.com/59691442/183047666-97f9711c-e2a4-4659-86df-410db5562450.png) | ![score_advance_table](https://user-images.githubusercontent.com/59691442/183058044-b5d532d6-bad2-4629-a55c-f669c82a5e29.png) |\n\n## Videos\n\nhttps://user-images.githubusercontent.com/59691442/183045566-0a3df947-06e7-4c46-9fc6-9d2b8f7d9a46.mp4\n\n## Quick start\n\n### Architecture \n\nThe CPU is composed of 5 files:\n- `cpu.rs`: The main file of the CPU. It contains the CPU structure to fetch, decode and execute the opcodes.\n- `register.rs`: The file that contains a model of the CPU register for an easy-to-use API.\n- `opcode.rs`: The file that contains all the opcodes' implementation.\n- `interrupt.rs`: The file that contains the interrupt implementation.\n- `cpu_disassembly.rs`: The file that contains the disassembly of the CPU, it is a big array that make a mapping between the opcode and the instruction name operation (ex: 0x00 -\u003e NOP).\n\n### How to use\n\nThe opcode table is fully assembled, except for the input and output instructions, which vary depending on the specific device that utilizes the CPU. Therefore, it will be necessary to implement these instructions on your own for your project.\n\nIn my own Space Invaders project, I first determine whether a given instruction is an input or output command. If it is not, then I proceed to execute the opcode using the CPU. For a more detailed explanation, you can refer to the Space Invaders Emulator project on GitHub [here](https://github.com/Im-Rises/space_invaders_arcade_emulator).\n\nYou will also need to check the `halted` flag of the CPU. If it is set to true, then the CPU is waiting for an interrupt to be triggered. If it is set to false, then the CPU is ready to execute the next instruction.\n\n```rust\n// Handle CPU\nwhile sdl2_video.get_window_active(self) {\n    if !self.cpu.get_halted() {\n        if self.cpu.get_cycles() == 0 {\n            let opcode = self.cpu.fetch_opcode();\n            if opcode == 0xDB {\n                let port = self.cpu.fetch_byte();\n                let a = self.inputs(port, self.cpu.get_a());\n                self.cpu.set_a(a);\n                self.cpu.set_cycles(10);\n            } else if opcode == 0xd3 {\n                let port = self.cpu.fetch_byte();\n                self.outputs(port, self.cpu.get_a(), \u0026mut sdl2_video);\n                self.cpu.set_cycles(10);\n            } else {\n                let cycles = self.cpu.compute_opcode(opcode);\n                self.cpu.set_cycles(cycles);\n            }\n        }\n        self.cpu.set_cycles(self.cpu.get_cycles() - 1);\n    }\n    frequency_counter += 1;\n```\n\nIn all the cases, you will need a working MMU. The project is provided with a simple MMU that can be used for testing purposes. You can find it in the `mmu.rs` file.\n\nTo test the good behaviour of the CPU, a set of CPU tests have been used, they show examples of the use of the CPU and the MMU. You can find them in the `cpu.rs` file.\nMode details about the tests can be found in the `Run tests` section below.\n\n## Rust tests\n\nYou can test the good behaviour of the project by typing the commands onf of the following command. It will start the\nunit test of the CPU.\n\nIt will start a test rom for the Intel 8080 CPU. You can find it in the link below:  \n\u003chttps://altairclone.com/downloads/cpu_tests/\u003e\n\n```bash\ncargo test\n```\n\nor \n\n```bash\ncargo test --release\n```\n\nCurrently, the CPU is passing the following tests:\n\n- [x] cpudiag.bin\n- [x] TST8080.COM\n- [x] 8080PRE.COM\n- [x] CPUTEST.COM\n- [x] 8080EXER.COM\n- [x] 8080EXM.COM\n\nThe tests are named:\n\n- cpu_test_rom_cpudiag\n- cpu_test_rom_tst8080\n- cpu_test_rom_8080pre\n- cpu_test_rom_cputest\n- cpu_test_rom_8080exer\n- cpu_test_rom_8080exm\n\nYou can start them individuality by typing:\n\n```bash\ncargo test \u003ctest_name\u003e\n```\n\nor\n\n```bash\ncargo test \u003ctest_name\u003e --release\n```\n\nExample: If you want to start the cpu_test_rom_tst8080 test.\n\n```bash\ncargo test cpu_test_rom_tst8080\n```\n\nor\n\n```bash\ncargo test cpu_test_rom_tst8080 --release\n```\n\nTo show the CPU test logs, you can use the `--show-output` flag.\n\n```bash\ncargo test --release -- --show-output\n```\n\nYou can also debug disassembly by uncommenting the two following lines in the `cpu.rs` file in the `test`\nmodule.\n\n~~~\n// let mut f = File::create(\"test_roms/my_output.log\").expect(\"Cannot create debug log file\");  \n~~~\n\n~~~\n// write_debug_to_file(\u0026mut cpu_debug, \u0026mut f, cycles_counter);\n~~~\n\nThis will output the complete disassembly of the CPU in the `test_roms/my_output.log` file.\n\n\u003e **Note**  \n\u003e Depending on the test the output is different. Refer to this project for more explanation about how they work.  \n\u003e https://github.com/superzazu/8080  \n\u003e http://www.emulator101.com/full-8080-emulation.html\n\u003e\n\u003e The last test (cpu_test_rom_8080exm) can take a lot of time in debug mode, you should test it in release mode, use the\n\u003e command below:\n\u003e ```bash\n\u003e cargo test cpu_test_rom_8080exm --release\n\u003e ```\n\n## GitHub Actions\n\n[![Rust](https://github.com/Im-Rises/cpu_intel_8080_emulator/actions/workflows/rust.yml/badge.svg?branch=main)](https://github.com/Im-Rises/cpu_intel_8080_emulator/actions/workflows/rust.yml)\n[![rust-clippy analyze](https://github.com/Im-Rises/cpu_intel_8080_emulator/actions/workflows/rust-clippy.yml/badge.svg?branch=main)](https://github.com/Im-Rises/cpu_intel_8080_emulator/actions/workflows/rust-clippy.yml)\n[![rustfmt check](https://github.com/Im-Rises/cpu_intel_8080_emulator/actions/workflows/rustfmt.yml/badge.svg?branch=main)](https://github.com/Im-Rises/cpu_intel_8080_emulator/actions/workflows/rustfmt.yml)\n\nThe project is set with a set of different scripts:\n\n- rust : Check the code compilation.\n- rust-clippy analyze : Evaluate the code quality (error, warnings, etc...).\n- rustfmt check :  Check the code good formatting\n\n## Documentation\n\nemulator101:  \n\u003chttp://www.emulator101.com\u003e\n\nComputer Archeology:  \n\u003chttps://www.computerarcheology.com/Arcade/SpaceInvaders/Hardware.html\u003e\n\nEmudev.de:  \n\u003chttps://emudev.de/q00-si/a-short-fun-project/\u003e\n\nRust:  \n\u003chttps://doc.rust-lang.org/book\u003e\n\nrust-clippy:  \n\u003chttps://github.com/rust-lang/rust-clippy\u003e\n\nrustfmt:  \n\u003chttps://github.com/rust-lang/rustfmt\u003e\n\nIntel 8080 documentations:  \n\u003chttps://archive.org/details/8080Datasheet\u003e  \n\u003chttps://altairclone.com/downloads/manuals/8080%20Programmers%20Manual.pdf\u003e\n\u003chttp://bitsavers.org/components/intel/MCS80/9800301D_8080_8085_Assembly_Language_Programming_Manual_May81.pdf\u003e\n\nIntel 8080 opcodes table:  \n\u003chttps://www.pastraiser.com/cpu/i8080/i8080_opcodes.html\u003e\n\nWikipedia:  \n\u003chttps://en.wikipedia.org/wiki/Intel_8080\u003e\n\nTest Roms for the Intel 8080:  \n\u003chttps://github.com/superzazu/8080/\u003e  \n\u003chttps://altairclone.com/downloads/cpu_tests/\u003e  \n\u003chttp://www.emulator101.com/full-8080-emulation.html\u003e\n\n## Contributors\n\nQuentin MOREL :\n\n- @Im-Rises\n- \u003chttps://github.com/Im-Rises\u003e\n\n[![GitHub contributors](https://contrib.rocks/image?repo=Im-Rises/cpu_intel_8080_emulator)](https://github.com/Im-Rises/cpu_intel_8080_emulator/graphs/contributors)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fim-rises%2Fcpu_intel_8080_emulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fim-rises%2Fcpu_intel_8080_emulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fim-rises%2Fcpu_intel_8080_emulator/lists"}