m6502

package
v0.0.0-...-20a4c11 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package m6502 is the MOS Technology 6502 series processor.

Index

Constants

View Source
const (
	// FlagC is the carry flag
	FlagC = uint8(1 << 0)

	// FlagZ is the zero flag
	FlagZ = uint8(1 << 1)

	// FlagI is the interrupt disable flag
	FlagI = uint8(1 << 2)

	// FlagD is the decimal mode flag
	FlagD = uint8(1 << 3)

	// FlagB is the break flag
	FlagB = uint8(1 << 4)

	// Flag5 is the 5th bit flag, always on
	Flag5 = uint8(1 << 5)

	// FlagV is the overflow flag
	FlagV = uint8(1 << 6)

	// FlagN is the signed/negative flag
	FlagN = uint8(1 << 7)
)

Variables

This section is empty.

Functions

func Formatter

func Formatter() rcs.CodeFormatter

func Reader

func Reader(e rcs.StmtEval)

Types

type CPU

type CPU struct {
	Name string

	A  uint8 // accumulator
	X  uint8 // x register
	Y  uint8 // y register
	SP uint8 // stack pointer
	SR uint8 // status register

	IRQ bool // interrupt request

	BreakFunc  func()
	WatchIRQ   bool
	WatchBRK   bool
	WatchStack bool
	// contains filtered or unexported fields
}

CPU is the MOS Technology 6502 series processor.

func New

func New(mem *rcs.Memory) *CPU

New creates a new CPU with a view of the provided memory.

func (*CPU) Load

func (c *CPU) Load(dec *rcs.Decoder)

func (*CPU) Memory

func (c *CPU) Memory() *rcs.Memory

Memory is the memory that can been seen by this CPU.

func (*CPU) NewDisassembler

func (c *CPU) NewDisassembler() *rcs.Disassembler

NewDisassembler creates a disassembler that can handle 6502 machine code.

func (*CPU) Next

func (c *CPU) Next()

Next executes the next instruction.

func (*CPU) Offset

func (c *CPU) Offset() int

Offset is the value to be added to the program counter to get the address of the next instruction. The value is 1 for this CPU since the program counter is incremented before fetching the opcode.

func (*CPU) PC

func (c *CPU) PC() int

PC returns the value of the program counter.

func (*CPU) Save

func (c *CPU) Save(enc *rcs.Encoder)

func (*CPU) SetPC

func (c *CPU) SetPC(addr int)

SetPC sets the value of the program counter.

func (*CPU) String

func (c *CPU) String() string

String returns the status of the CPU in the form of:

 pc  sr ac xr yr sp  n v - b d i z c
1234 20 00 00 00 ff  . . * . . . . .

Jump to

Keyboard shortcuts

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