Documentation
¶
Index ¶
- Constants
- Variables
- type Accumulator
- type AddressingMode
- type Cpu
- func (cpu *Cpu) AddressAbX() (memory.Ptr, int)
- func (cpu *Cpu) AddressAbY() (memory.Ptr, int)
- func (cpu *Cpu) AddressAbs() (memory.Ptr, int)
- func (cpu *Cpu) AddressImm() (memory.Ptr, int)
- func (cpu *Cpu) AddressInd() (memory.Ptr, int)
- func (cpu *Cpu) AddressIzx() (memory.Ptr, int)
- func (cpu *Cpu) AddressIzy() (memory.Ptr, int)
- func (cpu *Cpu) AddressOperand(am AddressingMode) (memory.Ptr, int)
- func (cpu *Cpu) AddressRel() (memory.Ptr, int)
- func (cpu *Cpu) AddressZP() (memory.Ptr, int)
- func (cpu *Cpu) AddressZPX() (memory.Ptr, int)
- func (cpu *Cpu) AddressZPY() (memory.Ptr, int)
- func (cpu *Cpu) ExecADC(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecAND(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecASL(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecASLA(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecBCC(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecBCS(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecBEQ(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecBIT(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecBMI(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecBNE(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecBPL(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecBRK(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecBVC(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecBVS(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecCLC(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecCLD(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecCLI(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecCLV(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecCMP(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecCPX(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecCPY(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecDEC(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecDEX(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecDEY(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecEOR(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecINC(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecINX(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecINY(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecIRQ()
- func (cpu *Cpu) ExecJMP(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecJSR(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecLDA(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecLDX(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecLDY(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecLSR(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecLSRA(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecNMI()
- func (cpu *Cpu) ExecNOP(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecORA(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecOneInstruction() (cycles int)
- func (cpu *Cpu) ExecPHA(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecPHP(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecPLA(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecPLP(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecROL(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecROLA(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecROR(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecRORA(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecRTI(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecRTS(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecSBC(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecSEC(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecSED(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecSEI(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecSTA(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecSTX(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecSTY(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecTAX(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecTAY(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecTSX(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecTXA(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecTXS(operandAddr memory.Ptr) int
- func (cpu *Cpu) ExecTYA(operandAddr memory.Ptr) int
- func (cpu *Cpu) Pop() byte
- func (cpu *Cpu) PopW() uint16
- func (cpu *Cpu) PowerUp()
- func (cpu *Cpu) Push(b byte)
- func (cpu *Cpu) PushW(w uint16)
- func (cpu *Cpu) ReadInterruptVector(iv InterruptVector) memory.Ptr
- func (cpu *Cpu) Reset()
- func (cpu *Cpu) Test()
- type IndexRegister
- type InstructionExecutor
- type InstructionHandler
- type InstructionInfo
- type InterruptVector
- type ProcessorStatus
- type ProgramCounter
- type StackPointer
Constants ¶
View Source
const (
SP_BASE uint16 = 0x100
)
Variables ¶
View Source
var InstructionInfos = [256]InstructionInfo{}/* 256 elements not displayed */
Functions ¶
This section is empty.
Types ¶
type Accumulator ¶
type Accumulator = uint8
The accumulator is the main register for arithmetic and logic
operations. Unlike the index registers X and Y, it has a direct connection to the Arithmetic and Logic Unit (ALU). This is why many operations are only available for the accumulator, not the index registers.
type AddressingMode ¶
type AddressingMode int
const ( IMP AddressingMode = iota IMM ZP ZPX ZPY IZX IZY ABS ABX ABY IND REL )
func Decode ¶
func Decode(opcode byte) (string, AddressingMode)
func (AddressingMode) GetArgumentCount ¶
func (i AddressingMode) GetArgumentCount() uint16
type Cpu ¶
type Cpu struct {
// registers
PC ProgramCounter
P ProcessorStatus
SP StackPointer
A Accumulator
X, Y IndexRegister
// memory
Memory memory.Memory
// interrupts
NMI bool
IRQ bool
// waitCycles
Wait int
}
func (*Cpu) AddressOperand ¶
func (cpu *Cpu) AddressOperand(am AddressingMode) (memory.Ptr, int)
func (*Cpu) ExecOneInstruction ¶
func (*Cpu) ReadInterruptVector ¶
func (cpu *Cpu) ReadInterruptVector(iv InterruptVector) memory.Ptr
type InstructionExecutor ¶
type InstructionHandler ¶
type InstructionHandler struct {
Executor InstructionExecutor
AddressingMode AddressingMode
}
type InstructionInfo ¶
type InstructionInfo struct {
OpCode byte
Nemonics string
AddressingMode AddressingMode
Cycles int
VariableCycles bool
}
type InterruptVector ¶
const ( IV_NMI InterruptVector = 0xFFFA IV_RESET InterruptVector = 0xFFFC IV_IRQ InterruptVector = 0xFFFE IV_BRK InterruptVector = 0xFFFE )
type ProcessorStatus ¶
type ProcessorStatus uint8
This 8-bit register stores the state of the processor. The bits in
this register are called flags. Most of the flags have something to do with arithmetic operations.
const ( // Carry flag PFLAG_C ProcessorStatus = 1 << iota // Zero flag PFLAG_Z // Interrupt disable flag PFLAG_I // Decimal mode flag. // 2A03 does not support BCD mode so although the flag can be set, its value will be ignored. PFLAG_D // Break flag PFLAG_B // unused flag, alway 1 PFLAG_UNUSED // oVerflow flag PFLAG_V // Negative flag PFLAG_N )
func (*ProcessorStatus) Set ¶
func (p *ProcessorStatus) Set(flag ProcessorStatus, val bool)
func (ProcessorStatus) String ¶
func (p ProcessorStatus) String() string
type ProgramCounter ¶
type ProgramCounter = uint16
This register points the address from which the next instruction
byte (opcode or parameter) will be fetched. Unlike other registers, this one is 16 bits in length. The low and high 8-bit halves of the register are called PCL and PCH, respectively. The Program Counter may be read by pushing its value on the stack. This can be done either by jumping to a subroutine or by causing an interrupt.
type StackPointer ¶
type StackPointer = uint8
The NMOS 65xx processors have 256 bytes of stack memory, ranging
from $0100 to $01FF. The S register is a 8-bit offset to the stack page. In other words, whenever anything is being pushed on the stack, it will be stored to the address $0100+S. The Stack pointer can be read and written by transfering its value to or from the index register X (see below) with the TSX and TXS instructions.
Click to show internal directories.
Click to hide internal directories.