z80test

package
v0.0.0-...-4374a33 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package z80test allows you to write test cases for z80 code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Core            z80asm.Z80Core
	MaxInstructions int // Maximum number of instructions to execute.

	// StackTop is the location of the stack.
	// The value 0 means the stack grows backwards from the top of memory.
	StackTop    uint16
	NextMachine *NextMachine
}

type ErrorHalt

type ErrorHalt struct{}

func (ErrorHalt) Error

func (ErrorHalt) Error() string

type ErrorMaxInstructions

type ErrorMaxInstructions struct {
	MaxInstructions int
}

ErrorMaxInstructions is an error that is returned when the code reached the maximum number of instructions (as set in the config).

func (ErrorMaxInstructions) Error

func (emi ErrorMaxInstructions) Error() string

type ErrorPanic

type ErrorPanic struct {
	Value interface{}
}

ErrorPanic is returned when the interpreter panics (for example, when it executes an unknown instruction).

func (ErrorPanic) Error

func (ep ErrorPanic) Error() string

type Memory

type Memory struct {
	RAM     []byte // 8k banks 0 to (up to) 223.
	ROM     [0x10000]byte
	Layer2  [256 * 192]byte
	Layer2_ [256 * 192]byte

	// Next memory is managed with 8 8k slots.
	// We store read and write slots separately, although
	// mostly they are the same.
	// But Layer2 paging can allow writes to slots 0 and 1
	// to go to layer2 (or shadow layer2) banks.
	// Also, we set the write slot for a ROM bank to nil.
	ReadSlots  [8][]byte
	WriteSlots [8][]byte
}

func NewMemory

func NewMemory(sizeKB int) (*Memory, error)

func (*Memory) Bank

func (mem *Memory) Bank(n int) []byte

func (*Memory) ContendRead

func (mem *Memory) ContendRead(address uint16, time int)

func (*Memory) ContendReadNoMreq

func (mem *Memory) ContendReadNoMreq(address uint16, time int)

func (*Memory) ContendReadNoMreq_loop

func (mem *Memory) ContendReadNoMreq_loop(address uint16, time int, count uint)

func (*Memory) ContendWriteNoMreq

func (mem *Memory) ContendWriteNoMreq(address uint16, time int)

func (*Memory) ContendWriteNoMreq_loop

func (mem *Memory) ContendWriteNoMreq_loop(address uint16, time int, count uint)

func (*Memory) CopyBank

func (mem *Memory) CopyBank(n int, bank *[1024 * 8]byte) error

func (*Memory) Data

func (mem *Memory) Data() []byte

func (*Memory) Read

func (mem *Memory) Read(address uint16) byte

func (*Memory) ReadByte

func (mem *Memory) ReadByte(address uint16) byte

func (*Memory) ReadByteInternal

func (mem *Memory) ReadByteInternal(address uint16) byte

func (*Memory) Write

func (mem *Memory) Write(address uint16, value byte, protectROM bool)

func (*Memory) WriteByte

func (mem *Memory) WriteByte(address uint16, value byte)

func (*Memory) WriteByteInternal

func (mem *Memory) WriteByteInternal(address uint16, value byte)

type NextMachine

type NextMachine struct {
	// RAM stores the banks of RAM in bank order.
	// The default banks stored in slots 0 to 7 are
	// ROM, ROM, 10, 11, 4, 5, 0, 1
	RAM []byte
	// contains filtered or unexported fields
}

func Call

func Call(c *Config, address uint16) (rm *NextMachine, re error)

Call calls the code at the given address (pushing a dummy PC return address onto the stack first). It finishes naturally when the corresponding `ret` is executed. The final machine state (whenever it's not nil) can be read from the returned machine.

func (*NextMachine) A

func (tc *NextMachine) A() Register8

func (*NextMachine) AF

func (tc *NextMachine) AF() Register16

func (*NextMachine) B

func (tc *NextMachine) B() Register8

func (*NextMachine) BC

func (tc *NextMachine) BC() Register16

func (*NextMachine) BC_

func (tc *NextMachine) BC_() Register16

func (*NextMachine) B_

func (tc *NextMachine) B_() Register8

func (*NextMachine) C

func (tc *NextMachine) C() Register8

func (*NextMachine) C_

func (tc *NextMachine) C_() Register8

func (*NextMachine) D

func (tc *NextMachine) D() Register8

func (*NextMachine) DE

func (tc *NextMachine) DE() Register16

func (*NextMachine) DE_

func (tc *NextMachine) DE_() Register16

func (*NextMachine) D_

func (tc *NextMachine) D_() Register8

func (*NextMachine) E

func (tc *NextMachine) E() Register8

func (*NextMachine) E_

func (tc *NextMachine) E_() Register8

func (*NextMachine) F

func (tc *NextMachine) F() Register8

func (*NextMachine) H

func (tc *NextMachine) H() Register8

func (*NextMachine) HL

func (tc *NextMachine) HL() Register16

func (*NextMachine) HL_

func (tc *NextMachine) HL_() Register16

func (*NextMachine) H_

func (tc *NextMachine) H_() Register8

func (*NextMachine) IX

func (tc *NextMachine) IX() Register16

func (*NextMachine) IY

func (tc *NextMachine) IY() Register16

func (*NextMachine) L

func (tc *NextMachine) L() Register8

func (*NextMachine) L_

func (tc *NextMachine) L_() Register8

func (*NextMachine) PC

func (tc *NextMachine) PC() Register16

func (*NextMachine) SP

func (tc *NextMachine) SP() Register16

type Register16

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

func (Register16) Get

func (r Register16) Get() uint16

func (Register16) High

func (r Register16) High() Register8

func (Register16) Low

func (r Register16) Low() Register8

func (Register16) Set

func (r Register16) Set(x int)

type Register8

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

func (Register8) Get

func (r Register8) Get() uint8

func (Register8) Set

func (r Register8) Set(x int)

Directories

Path Synopsis
The z80 package implements a Zilog Z80 emulator.
The z80 package implements a Zilog Z80 emulator.

Jump to

Keyboard shortcuts

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