{"id":18373656,"url":"https://github.com/dcas796/micro_6502","last_synced_at":"2025-08-03T12:09:09.591Z","repository":{"id":221200434,"uuid":"753721543","full_name":"dcas796/micro_6502","owner":"dcas796","description":"A functioning 6502 microprocessor emulator.","archived":false,"fork":false,"pushed_at":"2024-05-26T11:46:58.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T03:04:43.496Z","etag":null,"topics":["6502","6502-emulation","6502-processor","rust","rust-lang","rust-lib","rust-library"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/dcas796.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,"zenodo":null}},"created_at":"2024-02-06T17:08:55.000Z","updated_at":"2024-05-26T11:47:01.000Z","dependencies_parsed_at":"2024-02-06T18:32:08.884Z","dependency_job_id":"9f42bfc7-5265-44e6-b801-8b5999fc8a97","html_url":"https://github.com/dcas796/micro_6502","commit_stats":null,"previous_names":["dcas796/micro_6502"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/dcas796/micro_6502","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcas796%2Fmicro_6502","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcas796%2Fmicro_6502/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcas796%2Fmicro_6502/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcas796%2Fmicro_6502/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcas796","download_url":"https://codeload.github.com/dcas796/micro_6502/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcas796%2Fmicro_6502/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268541902,"owners_count":24266797,"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","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"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":["6502","6502-emulation","6502-processor","rust","rust-lang","rust-lib","rust-library"],"created_at":"2024-11-06T00:11:14.929Z","updated_at":"2025-08-03T12:09:09.560Z","avatar_url":"https://github.com/dcas796.png","language":"Rust","readme":"# micro_6502\n\nA functioning 6502 microprocessor emulator.\n\nThis crate contains a library and an executable that also serves as an example.\n\n## Usage (library)\n\nThe main component of this library is the `Emulator` struct. This struct contains all the logic that runs the virtual CPU. To initialize a new instance of this struct, you will need a struct that implements the `ReadWritable` trait.\n\nThe `ReadWritable` trait provides a simple interface that allows the user to implement their own buses and connect the virtual CPU to peripherals. This library comes built in with a default `ReadWritable` struct—the `Memory` struct—that delivers a byte buffer that the CPU can access.\n\nThe following code instantiates a new virtual 6502 processor that runs the user-specified program:\n\n```rust\nuse std::{fs::read, path::PathBuf};\n\nuse micro_6502::{\n    emulator::Emulator,\n    mem::{Memory, MEM_SIZE},\n};\n\nfn main() {\n    assert!(\n        std::env::args().len() == 2,\n        \"You need to provide a binary to run.\"\n    );\n    let program_bytes: [u8; MEM_SIZE] = {\n        let args: Vec\u003cString\u003e = std::env::args().collect();\n        let program_path: PathBuf = args[1].clone().try_into().expect(\"Cannot parse file path.\");\n        let bytes_vec = read(\u0026program_path)\n            .expect(format!(\"Cannot access the file at '{}'\", program_path.display()).as_str());\n        bytes_vec.try_into().expect(\n            format!(\n                \"The file at '{}' must be {MEM_SIZE} bytes.\",\n                program_path.display()\n            )\n            .as_str(),\n        )\n    };\n\n    let memory = Memory::new_from_bytes(program_bytes);\n    let mut emulator = Emulator::new(Box::from(memory));\n    emulator.run_until_break();\n\n    println!(\"Registers: {}\", emulator.get_regs());\n}\n```\n\n## Usage (executable)\n\nTo run a program using the emulator, run:\n\n```\ncargo run --features build-binary -- path/to/prog.bin\n```\n\nYou can also specify the registers to initialize the program with:\n\n```\ncargo run --features build-binary -- path/to/prog.bin --regs x=3,y=2\n```\n\n## Examples\n\nThere is an `examples/` directory that contain some example programs.\n\n### Fibonacci\n\nComputes the nth fibonacci number contained in the `x` register, outputting the result in the `y` register.\n\nNote: due to the limitations of the architecture of the 6502 processor, the largest number you can generate is the 13th number in the sequence, i.e. 233.\n\n```\ncargo run --features build-binary -- examples/fibonacci.bin --regs x=(whatever)\n```\n\n---\n\nMade by [dcas796](https://dcas796.github.com/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcas796%2Fmicro_6502","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcas796%2Fmicro_6502","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcas796%2Fmicro_6502/lists"}