
Emulator complexity for some popular CPUs in increasing order: 6502, 8080, Z80, 8086. XBYTE was designed to cater for the Z80, to which I will return fairly soon, then decide about a public release. The sheer quantity of instructions is the main issue. One self-contained cog can emulate the Z80, without a doubt.
6502 emulator free#
The cycle-accurate Z80 in particular could have a lot more free space for system hardware emulation. I need to modify my Z80 emulators to include auto-generated patterns and lessons learned from the 8086. Hello everyone Ive decided to share my simple 6502 Emulator, meant to be readable and understandable by people that want to dive into CPU emulation. I finished untested fast and slow (cycle-accurate) Z80 emulators before then, apart from the skip patterns. I stopped all work on the Z80 when starting the 8086. Was that Z80 emulator (that I think your were doing a while back) also completed ? I could have a use for that CPU if you plan to release that one to the public and if it is cycle accurate. Without it my 8086 emulator would have been a nightmare. Part of the Emulator mimics the function of the 6502 processor and its associated integrated circuits (the RAM-I/O chip, and the RAM and ROM), and the remainder. I have written a program to generate skip patterns automatically. This is a thing to do when you have a working code, otherwise it is a said: I spend few hours today optimizing the skip patterns, one group of instructions at a time, with repeated tests to make sure nothing broke. BBC 6502 Emulator emulates the BASIC ROM satisfactory, can do some OS calls, and simple text. I spent a lot of time trying to understand why an instruction wasn't working only to discover that I typed the pattern backward or that I have added an instruction and forgot to add the relative skip (or not-skip) bit in the pattern.
6502 emulator code#
This is a work in progress, I tend to make things working before doing any optimization, and the skip pattern gave me a lot of trouble, that's why the initial posted code is as it is (the woz monitor demo already has some changes). You will be amazed how much code disappears when using skipping as much as possible. Instead load a register with either (a) the address of the subroutine for the operation or (b) the skip pattern for the operation and combine code for similar operations in the same skip block. For example, you don't need to duplicate the fetch code for every arithmetic or logical operation.

There is big scope for code saving, freeing up space for hardware emulation.
