{"id":29506563,"url":"https://github.com/fernando-cabrera-gonzalez/sz80e","last_synced_at":"2026-07-02T07:31:33.157Z","repository":{"id":304336333,"uuid":"1018470342","full_name":"fernando-cabrera-gonzalez/sz80e","owner":"fernando-cabrera-gonzalez","description":"Simple Z80 Emulator","archived":false,"fork":false,"pushed_at":"2025-08-17T19:11:14.000Z","size":300,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-17T21:15:05.036Z","etag":null,"topics":["c","makefile","vscode","z80","z80-emulator"],"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/fernando-cabrera-gonzalez.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,"zenodo":null}},"created_at":"2025-07-12T10:30:09.000Z","updated_at":"2025-08-17T19:11:18.000Z","dependencies_parsed_at":"2025-08-17T21:10:14.609Z","dependency_job_id":"53d8498f-757d-450b-a1e3-4dedad03c174","html_url":"https://github.com/fernando-cabrera-gonzalez/sz80e","commit_stats":null,"previous_names":["fernando-cabrera-gonzalez/sz80e"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fernando-cabrera-gonzalez/sz80e","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernando-cabrera-gonzalez%2Fsz80e","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernando-cabrera-gonzalez%2Fsz80e/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernando-cabrera-gonzalez%2Fsz80e/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernando-cabrera-gonzalez%2Fsz80e/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fernando-cabrera-gonzalez","download_url":"https://codeload.github.com/fernando-cabrera-gonzalez/sz80e/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fernando-cabrera-gonzalez%2Fsz80e/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35038239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["c","makefile","vscode","z80","z80-emulator"],"created_at":"2025-07-16T02:02:18.536Z","updated_at":"2026-07-02T07:31:33.145Z","avatar_url":"https://github.com/fernando-cabrera-gonzalez.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Simple Z80 Emulator (sz80e)\n\nThis project implements an emulator for the Zilog Z80 microprocessor, written in C. The goal is to provide an educational and functional base to understand the internal workings of this classic processor, as well as to serve as a starting point for developments related to embedded systems, retrocomputing, or emulation.\n\n## Features\n\n- Emulation of the documented [Z80 instruction set](https://clrhome.org/table/).\n- Runs as a standalone program or linked as a static library.\n- Modular and easy-to-understand structure.\n- Includes tests and debugging utilities.\n- Compatible with binaries and [.Z80](https://worldofspectrum.org/faq/reference/z80format.htm) / [.SNA](https://worldofspectrum.org/faq/reference/formats.htm) snapshots.\n- Passes all ZEXDOC tests (see https://github.com/agn453/ZEXALL), which are included.\n- Visual Studio Code tasks provided for building and debugging.\n\n## Project Structure\n\n- `src/`: Source code of the emulator.\n- `inc/`: Header files.\n- `bin/`: Binaries (ROM and test files).\n- `makefile`: Alternative build script.\n- `README.md`: This file.\n\n## Requirements\n\n- GCC for compiling.\n- LD for linking.\n- AR for building the static library (optional).\n- Compatible operating system (Windows or Linux).\n- Recommended: GNU make and Visual Studio Code with C/C++ extension by Microsoft.\n\n## Standalone\n\nBuild the Z80 core + test as a standalone program:\n- run VS Code task \"Build z80 emulator\" or\n- run \"make z80emu\" or\n- run:\n\n```sh\ngcc -g ./src/main.c ./src/dbg.c ./src/mem_test.c ./src/opcodes.c ./src/opcodes_bit.c ./src/opcodes_ext.c ./src/opcodes_ix.c ./src/opcodes_iy.c ./src/opcodes_main.c ./src/utl.c ./src/z80.c -I./inc -o ./z80emu\n```\n\n- You can run the emulator with the following commands.\u003cbr\u003eIf no argument is given, only the ROM will be loaded (use ./bin/zexdoc.com for running the ZEXDOC test suite):\n\n```sh\nz80emu.exe [binary / .z80 / .sna file]    (Windows)\nz80emu     [binary / .z80 / .sna file]    (Linux)\n```\n## Static library + TEST\n\nBuild the Z80 core as a static library that can be linked from external programs (see TEST):\n- run VS Code task \"Build z80emu static library\" or\n- run \"make libz80emu.a\" or\n- run:\n\n```sh\ngcc -c ./src/dbg.c ./src/opcodes.c ./src/opcodes_bit.c ./src/opcodes_ext.c ./src/opcodes_ix.c ./src/opcodes_iy.c ./src/opcodes_main.c ./src/utl.c ./src/z80.c -I./inc\nar rcs libz80emu.a dbg.o opcodes.o opcodes_bit.o opcodes_ext.o opcodes_ix.o opcodes_iy.o opcodes_main.o utl.o z80.o\n```\n\nBuild the Z80 static library test:\n- run VS Code task \"Build z80emu library test executable\" or\n- run \"make z80emu_test\" or\n- run:\n\n```sh\ngcc ./src/main.c ./src/mem_test.c -I./inc -L. -lz80emu -o ./z80emu_test \n```\n\n- You can run the static library test with the following commands.\u003cbr\u003eIf no argument is given, only the ROM will be loaded (use ./bin/zexdoc.com for running the ZEXDOC test suite):\n\n```sh\nz80emu_test.exe [binary / .z80 / .sna file]    (Windows)\nz80emu_test     [binary / .z80 / .sna file]    (Linux)\n```\n## How to add the Z80 core to your projects\n\nIf you want to use the Z80 core in your personal projects follow these steps:\n1) Build the static library.\n\n2) Add to your project both the library and the public header file 'z80_public.h' (for access to the main emulator features).\u003cbr\u003e\n   Optionally, you can also add 'utl_public.h' to your project, which provides a keyboard handler and triggers the user debugger when 'd' is pressed.\n\n3) You will need to implement a memory model for the Z80 to work (see 'mem_test.h', mem_test.c and main.c for an example):\n    - Provide a 64k memory buffer (16k ROM + 48k RAM).\n    - Implement the methods of the memory interface, provided in the 'MEM INTERFACE' section of 'z80_public.h'.\n\n4) From your project you will need to call the 2 functions in the 'Z80 INTERFACE' section of 'z80_public.h':\n    - Call 'z80_init()' at the beginning for initializing the z80 emulator providing:\n        - A file to load in memory in one of these formats and that can be provided in the first argument of command line:\n            - A binary that will be loaded at address 0x000 of the memory.\n            - A .z80 or a .sna file with a snapshot that will be loaded at address 0x4000 or higher, keeping the ROM at address from 0x000 to 0x3FFF.\n            - If no file is provided, only the ROM will be loaded at address 0x000.\n        - A pointer to a Z80InitData struct (see 'z80_public.h') with:\n            - A pointer to the memory buffer you defined.\n            - Pointers to the read and write memory functions you implemented.\n        - Optionally, you can provide:\n            - Pointers for I/O read and write functions (see 'I/O INTERFACE' in 'z80_public.h')\n            - Pointer to a render function that will be called every time an interrupt is triggered.\n            - A start address, that will be used as the initial value for the PC.\n    - Optionally, call 'utl_check_keyboard()' which will read the keyboard, triggering the user debugger if 'd' is pressed (it also returns the key pressed).\n    - Call the 'z80_update()' function every time you want to update the emulator state. It will return the number of cycles elapsed.\n      Optionally, if memory contention is present, you can add the additional number of contended cycles to the total, as in the example.\n\n## Debugger\n\nThe emulator comes with an internal debugger that has 3 possible levels:\n\n#### - DEBUG_LEVEL_NONE: \nBest performance, no debugging at all.\n\n#### - DEBUG_LEVEL_USER:\n\nAt any point during execution, you can press ESC to invoke the debugger. Once inside, the following commands are available:\n```text\nhelp             List avalilable commands.\nbr+ \u003caddress\u003e    Add a breakpoint at the specified address.\nbr- \u003caddress\u003e    Remove breakpoint at the specified address.\nbrl              List breakpoints.\nz80              Show z80 state.\nrun [num_steps]  Run N z80 instructions (resume if no num_steps).\nml  \u003caddress\u003e    List contents of memory at specified address.\n```\n\n#### - DEBUG_LEVEL_FULL: \nOutputs every single opcode and interrupt info.\u003cbr\u003e\nWarning: keys can become non-responding when this level is set. Redirect stdout to a file, but be careful... they'll grow fast!\n\n## Author\n\nFernando Cabrera González\n- LinkedIn: [Fernando Cabrera González](https://www.linkedin.com/in/fernando-cabrera-gonzález-3b256620)\n- X: [@fcabrera_77](https://x.com/fcabrera_77)\n- CommodoreSpain: [El Rincón de Fer](https://www.commodorespain.es/el-rincon-de-fer/)\n- Series on the AmigaWave YouTube channel:\n    - [How were games made on the Amiga?](https://youtube.com/playlist?list=PLJGQC1clVHNFnwfmWUz3W2uoJgx0Pj6u2\u0026si=RM6vIbvmaD15IcuX)\n    - [Basic Assembly Programming Course for the Amiga.](https://youtube.com/playlist?list=PLJGQC1clVHNH7jb3hanudeT_BnQs2Ilv0\u0026si=VeIlJY8tVfef84P_)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernando-cabrera-gonzalez%2Fsz80e","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffernando-cabrera-gonzalez%2Fsz80e","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernando-cabrera-gonzalez%2Fsz80e/lists"}