

“read not write” pin ( rw), where a 1 indicates a read access, and a 0 Here the columns indicate the cycle number the value output on the physicalĪddress bus ( addr) the data on the data bus ( data) the value on the Let’s go through a quick example, calculating a very simple checksum over ten The zero page can also be treated as an array of 16-bit index pointers. Instructions accessing the zero page are encoded differentlyĪnd run a little faster (as they don’t need to encode two address bytes). The 6502 treats the 256 bytes at the bottom of RAM (the “zero As almost every clock cycle needsĪccess to memory (to read instructions or data) this is generally a win.Īgain, this is an important fact which leads to some unusual behaviour we must To save costs this was left off of the 6502. Most CPUs have a physical pin dedicated to indicate “I need to access memory”, but This has importantĬonsequences that we’ll talk about later. Has a very simple pipeline - the fetch for the next instruction happensĭuring the execution of the previous instruction. Processors, instructions are fetched from RAM and executed in turn. The 6502 at the heart of the Beeb is simple but powerful.

Let’s delve a little into that: Life of an instruction Particular cycles within an instruction that need to be correct. Needs to be correct, but the fact that the memory reads and writes happen on Worse still, it’s not just how many CPU cycles each instruction takes that
6502 EMULATOR T CODE
Of the decryption code and the hardware timers has to be emulated absolutely In order to decrypt correctly the relative timing The code would often use XORs with hardware timers (amongst other things) to make itĭifficult to decrypt manually. The game code would be encrypted first and would be decrypted at runtime byĬode. These would be used to prevent disassembly, copying and cheats. The most challenging example of timings were games protection systems. Required intimate knowledge of the instruction and hardware timings that if anĮmulator didn’t account for them properly, some things wouldn’t work right. IĬovered some of this in the first post, but so many tricks on the BBC Getting the instruction timings right is paramount for good emulation. Getting the timings spot on in jsbeeb was invaluable. Legendary - he still writes games for it even now. Have been programming together since we met. He and I have been friends since we were twelve years old and

This time around the thanks really have to go to my good chum Rich I’ll cover how interrupts and hardware timers fit into the mix. Will cover the subtleties of the 6502’s instruction timings. Stuff, or the second part which focuses on the video hardware. Might find it instructive to read the first part which covers general
6502 EMULATOR T SERIES
This is the third post in my series on emulating a BBC Micro in Javascript.
