Zilog Z80
The Zilog Z80 is a general-purpose 8-bit CPU. It is clocked at 3.58 MHz in the Mega Drive and is often used as the sound CPU, but is officially designated as the Co-Processor to the M68k. It has direct memory access to 8 kilobytes of dedicated sound RAM, as well as the YM2612 FM synthesis chip, and the SN76489 PSG chip. On top of this, it can access a 32KByte 'bank' of any area within M68k memory. This CPU is often used to run the code for the sound driver on many games, while some games only utilise it for DAC playback. The Z80's memory is laid out like the following:
Memory Map
Start | End | Description |
---|---|---|
0000h | 1FFFh | Z80 RAM |
2000h | 3FFFh | Reserved |
4000h | YM2612 A0 | |
4001h | YM2612 D0 | |
4002h | YM2612 A1 | |
4003h | YM2612 D1 | |
4004h | 5FFFh | Reserved |
6000h | Bank register | |
6001h | 7F10h | Reserved |
7F11h | SN76489 PSG | |
7F12h | 7FFFh | Reserved |
8000h | FFFFh | M68k memory bank |
The current bank to be at the $8000 and up region can be controlled by the banking register.
Programming the Z80
Registers
Seeing as the Z80 was developed to be byte compatible with Intel's 8080 chip, the standard 8080 registers are also present on the Z80:
- AF: 8-bit accumulator (A) and flag bits (F), and an Add/Subtract flag (usually called N)
- BC: 16-bit data/address register or two 8-bit registers (A hybrid of an ax and dx register on the M68k)
- DE: 16-bit data/address register or two 8-bit registers (A hybrid of an ax and dx register on the M68k)
- HL: 16-bit accumulator/address register or two 8-bit registers
- SP: stack pointer, 16 bits (This register is also present on the M68k)
- PC: program counter, 16 bits (This register is also present on the M68k)
The Z80 has these added registers:
- IX: 16-bit index or base register for 8-bit immediate offsets
- IY: 16-bit index or base register for 8-bit immediate offsets
- I: interrupt vector base register, 8 bits
- R: DRAM refresh counter,
- AF': alternate (or shadow) accumulator and flags
- BC', DE' and HL': alternate (or shadow) registers