Documentation ¶
Overview ¶
The z80 package implements a Zilog Z80 emulator.
Index ¶
- Constants
- Variables
- type MemoryAccessor
- type MemoryReader
- type NextRegisterAccessor
- type PortAccessor
- type Z80
- func (z80 *Z80) BC() uint16
- func (z80 *Z80) BC_() uint16
- func (z80 *Z80) DE() uint16
- func (z80 *Z80) DE_() uint16
- func (z80 *Z80) DecBC()
- func (z80 *Z80) DecBC_()
- func (z80 *Z80) DecDE()
- func (z80 *Z80) DecDE_()
- func (z80 *Z80) DecHL()
- func (z80 *Z80) DecHL_()
- func (z80 *Z80) DecIX()
- func (z80 *Z80) DecIY()
- func (z80 *Z80) DecPC(value uint16)
- func (z80 *Z80) DecSP()
- func (z80 *Z80) DoOpcode()
- func (z80 *Z80) HL() uint16
- func (z80 *Z80) HL_() uint16
- func (z80 *Z80) IR() uint16
- func (z80 *Z80) IX() uint16
- func (z80 *Z80) IY() uint16
- func (z80 *Z80) IncBC()
- func (z80 *Z80) IncBC_()
- func (z80 *Z80) IncDE()
- func (z80 *Z80) IncDE_()
- func (z80 *Z80) IncHL()
- func (z80 *Z80) IncHL_()
- func (z80 *Z80) IncIX()
- func (z80 *Z80) IncIY()
- func (z80 *Z80) IncPC(value uint16)
- func (z80 *Z80) IncSP()
- func (z80 *Z80) Interrupt()
- func (z80 *Z80) NonMaskableInterrupt()
- func (z80 *Z80) PC() uint16
- func (z80 *Z80) Reset()
- func (z80 *Z80) SP() uint16
- func (z80 *Z80) SetBC(value uint16)
- func (z80 *Z80) SetBC_(value uint16)
- func (z80 *Z80) SetDE(value uint16)
- func (z80 *Z80) SetDE_(value uint16)
- func (z80 *Z80) SetHL(value uint16)
- func (z80 *Z80) SetHL_(value uint16)
- func (z80 *Z80) SetIX(value uint16)
- func (z80 *Z80) SetIY(value uint16)
- func (z80 *Z80) SetPC(value uint16)
- func (z80 *Z80) SetSP(value uint16)
Constants ¶
const FLAG_3 = 0x08
const FLAG_5 = 0x20
const FLAG_C = 0x01
The flags
const FLAG_H = 0x10
const FLAG_N = 0x02
const FLAG_P = 0x04
const FLAG_S = 0x80
const FLAG_V = FLAG_P
const FLAG_Z = 0x40
const SHIFT_0xCB = 256
const SHIFT_0xDD = 768
const SHIFT_0xDDCB = 1024
const SHIFT_0xED = 512
const SHIFT_0xFD = 1280
const SHIFT_0xFDCB = 1024
Variables ¶
var ( OpcodesMap [1536]func(z80 *Z80) OpcodesDisMap [1536]func(memory MemoryReader, address uint16, shift int) (string, uint16, int) )
Functions ¶
This section is empty.
Types ¶
type MemoryAccessor ¶
type MemoryAccessor interface { // ReadByte reads a byte from address taking into account // contention. ReadByte(address uint16) byte // ReadByteInternal reads a byte from address without taking // into account contention. ReadByteInternal(address uint16) byte // WriteByte writes a byte at address taking into account // contention. WriteByte(address uint16, value byte) // WriteByteInternal writes a byte at address without taking // into account contention. WriteByteInternal(address uint16, value byte) // ContendRead increments the Tstates counter by time as a // result of a memory read at the given address. ContendRead(address uint16, time int) ContendReadNoMreq(address uint16, time int) ContendReadNoMreq_loop(address uint16, time int, count uint) ContendWriteNoMreq(address uint16, time int) ContendWriteNoMreq_loop(address uint16, time int, count uint) Read(address uint16) byte Write(address uint16, value byte, protectROM bool) // Data returns the memory content. Data() []byte }
MemoryAccessor is an interface to access memory addressed by the Z80. It defines four read/write method for accessing memory, taking into account contention when needed. In systems where memory contention is not an issue ReadByte and WriteByte should simply call ReadByteInternal and WriteByteInternal.
type MemoryReader ¶
MemoryReader is a simple interface that defines only a ReadByte method. It's used mainly by the disassembler.
type NextRegisterAccessor ¶
type NextRegisterAccessor interface { ReadRegister(reg uint8) byte WriteRegister(reg uint8, b byte) }
NextRegisterAccessor provides an interface to read and write ZX spectrum next hardware registers.
type PortAccessor ¶
type Z80 ¶
type Z80 struct {
A, F, B, C, D, E, H, L byte
A_, F_, B_, C_, D_, E_, H_, L_ byte
IXH, IXL, IYH, IYL byte
I, IFF1, IFF2, IM byte
// The highest bit (bit 7) of the R register
R7 byte
// The low 7 bits of the R register. 16 bits long so it can
// also act as an RZX instruction counter.
R uint16
EventNextEvent int
// Number of tstates since the beginning of the last frame.
// The value of this variable is usually smaller than TStatesPerFrame,
// but in some unlikely circumstances it may be >= than that.
Tstates int
Halted bool
// contains filtered or unexported fields
}
func NewZ80 ¶
func NewZ80(memory MemoryAccessor, ports PortAccessor, registers NextRegisterAccessor) *Z80
NewZ80 creates a new Z80 instance.
func (*Z80) DoOpcode ¶
func (z80 *Z80) DoOpcode()
Execute a single instruction at the program counter.
func (*Z80) NonMaskableInterrupt ¶
func (z80 *Z80) NonMaskableInterrupt()
Process a Z80 non-maskable interrupt.