core

package
v0.0.0-...-97f5b4b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FlagS Sign flag (bit 7)
	FlagSshift = 7
	FlagS      = 1 << FlagSshift

	// FlagZ Zero flag (bit 6)
	FlagZshift = 6
	FlagZ      = 1 << FlagZshift

	// FlagH Half Carry flag (bit 4)
	FlagHshift = 4
	FlagH      = 1 << FlagHshift

	// FlagP Parity (bit 2) (set if the result byte has an even number of bits set)
	FlagPshift = 2
	FlagP      = 1 << FlagPshift

	// FlagV Overflow (bit 2)
	FlagVshift = FlagPshift
	FlagV      = 1 << FlagVshift

	// FlagN Add/Subtract flag (bit 1)
	FlagNshift = 1
	FlagN      = 1 << FlagNshift

	// FlagC Carry flag (bit 0)
	FlagCshift = 0
	FlagC      = 1 << FlagCshift
)

constants for the flag register F

View Source
const (
	NonZero    Condition = (FlagZ<<8 | 0)
	Zero                 = (FlagZ<<8 | FlagZ)
	NoCarry              = (FlagC<<8 | 0)
	Carry                = (FlagC<<8 | FlagC)
	ParityEven           = (FlagP<<8 | FlagP)
	ParityOdd            = (FlagP<<8 | 0)
	SignPos              = (FlagS<<8 | 0)
	SignNeg              = (FlagS<<8 | FlagS)
)

Constants for all possible conditions that can be tested for. High byte is mask, and low byte is result required for true evaluation

Variables

This section is empty.

Functions

func NewR16

func NewR16() (R16, R8, R8)

NewR16 creates a new R16 register and returns a pointer to it as well as the high and low R8 parts

Types

type Condition

type Condition uint16

Condition represents the possible conditions that can be tested for by the ALU

type OP

type OP struct {
	// contains filtered or unexported fields
}

OP splits an op-code into its different parts according to the description in http://www.z80.info/decoding.htm

type R16

type R16 *uint16

R16 represents a 16-bit register

func NewR16Single

func NewR16Single() R16

NewR16Single creates a new R16 register without returning any high and low R8 parts

type R8

type R8 *uint8

R8 represents a 8-bit register

func NewR8

func NewR8() R8

NewR8 creates a new R8 register, not linked to any R16 register

type RAM

type RAM struct {
	// contains filtered or unexported fields
}

RAM represents the RAM in the Z80

func NewRAM

func NewRAM() *RAM

NewRAM makes a new RAM object with size 64k and populates with the initial data supplied

func (*RAM) Dump

func (ram *RAM) Dump(start, length uint16) string

Dump prints the RAM contents to the provided writer

func (*RAM) Write

func (ram *RAM) Write(addr uint16, data *[]uint8)

type Z80

type Z80 struct {
	// the 16 bit registers
	AF, BC, DE, HL, IX, IY R16

	// their high and low parts
	A, F, B, C, D, E, H, L R8
	IXL, IXH, IYL, IYH     R8

	// and their alternatives
	AFa, BCa, DEa, HLa R16

	// the stack pointer and program counter
	SP, PC R16

	// memory and IO device
	Mem *RAM
	IO  io.Device

	// internal flags
	Halted, InterruptEnabled bool

	// EnableBDOS controls whether or not a CALL 5 will act as normal or go to the CP/M BDOS
	EnableBDOS bool
}

Z80 contains all internal registers and such for the Z80 processor

func NewZ80

func NewZ80() Z80

NewZ80 creates a new Z80 CPU instance with memory, and registers

func (*Z80) Step

func (z *Z80) Step()

Step causes the CPU to handle the next instruction

func (*Z80) String

func (z *Z80) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL