cpu

package
v0.0.0-...-a6bb76f Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteRegister

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

ByteRegister is an 8 bit register

func (*ByteRegister) Dec

func (r *ByteRegister) Dec()

Dec decreases the value of a 8 bit register by one TODO: Masked registers might have strange behaviours with inc/dec

func (*ByteRegister) DecBy

func (r *ByteRegister) DecBy(q uint8)

DecBy decreases the value of a 8 bit register by q TODO: Masked registers might have strange behaviours with inc/dec

func (*ByteRegister) Get

func (r *ByteRegister) Get() uint8

Get gets the value of a 8 bit register

func (*ByteRegister) GetMask

func (r *ByteRegister) GetMask() uint8

GetMask returns the mask applied to this register

func (*ByteRegister) Inc

func (r *ByteRegister) Inc()

Inc increases the value of a 8 bit register by one TODO: Masked registers might have strange behaviours with inc/dec

func (*ByteRegister) IncBy

func (r *ByteRegister) IncBy(q uint8)

IncBy increases the value of a 8 bit register by q TODO: Masked registers might have strange behaviours with inc/dec

func (*ByteRegister) Set

func (r *ByteRegister) Set(data uint8)

Set sets the value of a 8 bit register

func (*ByteRegister) SetMask

func (r *ByteRegister) SetMask(mask uint8)

SetMask sets a mask to this register

type CPU

type CPU struct {
	AF, BC, DE, HL, SP, PC *WordRegister
	A, F, B, C, D, E, H, L *ByteRegister
	// contains filtered or unexported fields
}

CPU structure

func New

func New(memory Memory) *CPU

New initialises a new Z80 cpu

func (*CPU) DebugDisable

func (cpu *CPU) DebugDisable()

DebugDisable disables CPU debugging

func (*CPU) DebugEnable

func (cpu *CPU) DebugEnable()

DebugEnable enables CPU debugging

func (*CPU) DisableInterrupts

func (cpu *CPU) DisableInterrupts()

DisableInterrupts clears the interrupt master enable flag

func (*CPU) EnableInterrupts

func (cpu *CPU) EnableInterrupts()

EnableInterrupts sets the interrupt master enable flag

func (*CPU) FlagC

func (cpu *CPU) FlagC() bool

FlagC returns the status of the Carry flag

func (*CPU) FlagH

func (cpu *CPU) FlagH() bool

FlagH returns the status of the Half-Carry flag

func (*CPU) FlagN

func (cpu *CPU) FlagN() bool

FlagN returns the status of the Negative flag

func (*CPU) FlagZ

func (cpu *CPU) FlagZ() bool

FlagZ returns the status of the Zero flag

func (*CPU) InterruptsEnabled

func (cpu *CPU) InterruptsEnabled() bool

InterruptsEnabled reads the status of the interrupt master enable flag

func (*CPU) SetFlagC

func (cpu *CPU) SetFlagC(value bool)

SetFlagC sets or clears the Carry Flag

func (*CPU) SetFlagH

func (cpu *CPU) SetFlagH(value bool)

SetFlagH sets or clears the Half-Carry Flag

func (*CPU) SetFlagN

func (cpu *CPU) SetFlagN(value bool)

SetFlagN sets or clears the Negative Flag

func (*CPU) SetFlagZ

func (cpu *CPU) SetFlagZ(value bool)

SetFlagZ sets or clears the Zero Flag

func (*CPU) SetStatus

func (cpu *CPU) SetStatus(state State)

SetStatus sets CPU status

func (*CPU) Status

func (cpu *CPU) Status() State

Status returns the CPU register status

func (*CPU) Step

func (cpu *CPU) Step() (int, error)

Step executes next instruction and returns cycles consumed

type Memory

type Memory interface {
	Read(address uint16) byte
	Write(address uint16, data byte)
}

Memory defines the interface for memory interaction

type State

type State struct {
	AF, BC, DE, HL, SP, PC uint16
	IME                    bool
}

State reflects the CPU status

type WordRegister

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

WordRegister is an 16 bit register, composed of two 8 bit registers

func (*WordRegister) Dec

func (r *WordRegister) Dec()

Dec decreases the value of a 16 bit register by one TODO: Masked registers might have strange behaviours with inc/dec

func (*WordRegister) DecBy

func (r *WordRegister) DecBy(q uint16)

DecBy decreases the value of a 16 bit register by q TODO: Masked registers might have strange behaviours with inc/dec

func (*WordRegister) Get

func (r *WordRegister) Get() uint16

Get gets the value of a 16 bit register

func (*WordRegister) GetMask

func (r *WordRegister) GetMask() uint16

GetMask returns the mask applied to this register

func (*WordRegister) H

func (r *WordRegister) H() *ByteRegister

H gets the high byte register of a 16 bit register

func (*WordRegister) Inc

func (r *WordRegister) Inc()

Inc increases the value of a 16 bit register by one TODO: Masked registers might have strange behaviours with inc/dec

func (*WordRegister) IncBy

func (r *WordRegister) IncBy(q uint16)

IncBy increases the value of a 16 bit register by q TODO: Masked registers might have strange behaviours with inc/dec

func (*WordRegister) L

func (r *WordRegister) L() *ByteRegister

L gets the low byte register of a 16 bit register

func (*WordRegister) Set

func (r *WordRegister) Set(data uint16)

Set sets the value of a 16 bit register

func (*WordRegister) SetMask

func (r *WordRegister) SetMask(mask uint16)

SetMask sets a mask to this register

Directories

Path Synopsis
Package cpu_mock is a generated GoMock package.
Package cpu_mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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