Package libsidplay.components.mos6510
Klasse MOS6510
java.lang.Object
libsidplay.components.mos6510.MOS6510
- Bekannte direkte Unterklassen:
MOS6510Debug,MOS6510ViceSync
Cycle-exact 6502/6510 emulation core.
Code is based on work by Simon A. White <sidplay2@yahoo.com>. Original
Java port by Ken Händel. Later on, it has been hacked to improve
compatibility with Lorenz suite on VICE's test suite.
- Autor:
- Antti Lankila
-
Verschachtelte Klassen - Übersicht
Verschachtelte Klassen -
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprivate static final intThe result of the ANE opcode is A = ((A | CONST) & X & IMM), with CONST apparently being both chip- and temperature dependent.protected final EventSchedulerOur event context copy.protected BiConsumer<Integer, Byte> protected byteprotected intData regarding current instructionprotected intprotected intprotected intCurrent instruction and subcycle within instructionprivate booleanHack for Edge of Disgrace.private final EventWhen AEC signal is high, no stealing is possibleprivate final EventWhen AEC signal is low, steals permittedprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprivate final Runnable[]Table of CPU opcode implementationsprotected intWhen IRQ was triggered.protected booleanIRQ asserted on CPUprivate static final intIRQ/NMI magic limit values.protected booleanNMI requested?private final boolean[]true - Represents an instruction subcycle that writes.private booleanRDY pin state (stop CPU on read)protected byteprotected intprotected byteprotected byteprotected byteprotected booleanRST requested?protected static final byteStack page locationstatic final intStatus register interrupt bit. -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprivate voidprotected voidEvaluate when to execute an interrupt.final voidclearIRQ()Inform CPU that IRQ is no longer pulled low.static Stringcredits()Module Creditsprotected voiddoADC()BCD addingprotected voiddoSBC()BCD subtractingprotected voidFetch high address byte, increment PC (Absolute Addressing)
Low byte must have been obtained first!protected voidFetch high byte of address, add index register X to low address byte,
increment PC
Addressing Modes: Absolute Indexedprotected voidFetch high byte of address, add index register Y to low address byte,
increment PC
Addressing Modes: Absolute Indexedprotected voidFetch effective address high
Addressing Modes: Indirect Indexed Indirect (pre X)protected voidFetch effective address high, add Y to low byte of effective address
Addressing Modes: Indirect indexed (post Y)protected voidFetch pointer address high, increment PC
Addressing Modes: Absolute Indirectprotected voidFetch low address byte, increment PC
Addressing Modes: Stack Manipulation Absolute Zero Page Zero Page Indexed Absolute Indexed Absolute Indirectprotected voidRead from address, add index register X to it
Addressing Modes: Zero Page Indexedprotected voidRead from address, add index register Y to it
Addressing Modes: Zero Page Indexedprotected voidFetch effective address low
Addressing Modes: Indirect Indexed Indirect (pre X) Indirect indexed (post Y)protected voidFetch pointer address low, increment PC
Addressing Modes: Absolute Indirect Indirect indexed (post Y)protected voidvoidforcedJump(int address) Force CPU to start execution at given addressfinal EventSchedulerfinal byteWhen stalled by BA but not yet tristated by AEC, the CPU generates read requests to the PLA chip.private byteprivate voidInitialize CPU Emulation (Registers)protected voidprotected voidprotected voidprotected voidIncrement stack and pull program counter high byte from stack,protected voidPopLowPC()Increment stack and pull program counter low byte from stack,protected voidPopSR()increment S, Pop P off stackprotected voidPush Program Counter High Byte on stack, decrement Sprotected voidPush Program Counter Low Byte on stack, decrement Sprotected voidPushSR()Push P on stack, decrement Sprotected voidWrite Cycle_Data to effective address.voidsetEODHack(boolean hack) protected final voidsetFlagsNZ(byte value) Set N and Z flag values.voidsetFlagV(boolean flag) Set the value of V flag (often related to the SO pin)voidsetJmpJsrHandler(Consumer<Integer> jmpJsr) voidsetMemoryHandler(Function<Integer, Byte> cpuRead, BiConsumer<Integer, Byte> cpuWrite) final voidsetRDY(boolean rdy) Handle bus access signal.private voidsetStatusRegister(byte sr) voidfinal voidPull IRQ line low on CPU.final voidTrigger NMI interrupt on the CPU.final voidThis forces the CPU to abort whatever it is doing and immediately enter the RST interrupt handling sequence.
-
Felddetails
-
SR_INTERRUPT
public static final int SR_INTERRUPTStatus register interrupt bit.- Siehe auch:
-
SP_PAGE
protected static final byte SP_PAGEStack page location- Siehe auch:
-
MAX
private static final int MAXIRQ/NMI magic limit values. Need to be larger than about 0x103 << 3, but can't be min/max for Integer type.- Siehe auch:
-
EOD
private boolean EODHack for Edge of Disgrace. -
ANE_CONST
private static final int ANE_CONSTThe result of the ANE opcode is A = ((A | CONST) & X & IMM), with CONST apparently being both chip- and temperature dependent. The commonly used value for CONST in various documents is 0xee, which is however not to be taken for granted (as it is unstable). see here: http://visual6502 .org/wiki/index.php?title=6502_Opcode_8B_(XAA,_ANE) as seen in the list, there are several possible values, and its origin is still kinda unknown. instead of the commonly used 0xee we use 0xff here, since this will make the only known occurance of this opcode in actual code work. see here: https://sourceforge .net/tracker/?func=detail&aid=2110948 &group_id=223021&atid=1057617 FIXME: in the unlikely event that other code surfaces that depends on another CONST value, it probably has to be made configurable somehow if no value can be found that works for both.- Siehe auch:
-
context
Our event context copy. -
rdy
private boolean rdyRDY pin state (stop CPU on read) -
instrTable
Table of CPU opcode implementations -
processorCycleNoSteal
private final boolean[] processorCycleNoStealtrue - Represents an instruction subcycle that writes. Whereas false - represents an instruction subcycle that reads. -
cycleCount
protected int cycleCountCurrent instruction and subcycle within instruction -
Cycle_EffectiveAddress
protected int Cycle_EffectiveAddressData regarding current instruction -
Cycle_HighByteWrongEffectiveAddress
protected int Cycle_HighByteWrongEffectiveAddress -
Register_ProgramCounter
protected int Register_ProgramCounter -
Cycle_Pointer
protected int Cycle_Pointer -
Cycle_Data
protected byte Cycle_Data -
Register_Accumulator
protected byte Register_Accumulator -
Register_X
protected byte Register_X -
Register_Y
protected byte Register_Y -
Register_StackPointer
protected byte Register_StackPointer -
flagN
protected boolean flagN -
flagC
protected boolean flagC -
flagD
protected boolean flagD -
flagZ
protected boolean flagZ -
flagV
protected boolean flagV -
flagI
protected boolean flagI -
flagU
protected boolean flagU -
flagB
protected boolean flagB -
v
-
jmpJsr
-
cpuRead
-
cpuWrite
-
irqAssertedOnPin
protected boolean irqAssertedOnPinIRQ asserted on CPU -
interruptCycle
protected int interruptCycleWhen IRQ was triggered. -MAX means "during some previous instruction", MAX means "no IRQ" -
nmiFlag
protected boolean nmiFlagNMI requested? -
rstFlag
protected boolean rstFlagRST requested? -
eventWithoutSteals
When AEC signal is high, no stealing is possible -
eventWithSteals
When AEC signal is low, steals permitted
-
-
Konstruktordetails
-
MOS6510
Create new CPU emu- Parameter:
context- The Event Context
-
-
Methodendetails
-
setMemoryHandler
-
setJmpJsrHandler
-
setVFlagHandler
-
setFlagV
public void setFlagV(boolean flag) Set the value of V flag (often related to the SO pin)- Parameter:
flag- new V flag state
-
calculateInterruptTriggerCycle
protected void calculateInterruptTriggerCycle()Evaluate when to execute an interrupt. Calling this method can also result in the decision that no interrupt at all needs to be scheduled. -
Initialise
private void Initialise()Initialize CPU Emulation (Registers) -
interruptsAndNextOpcode
protected void interruptsAndNextOpcode() -
interrupt
protected void interrupt() -
interruptEnd
protected void interruptEnd() -
fetchNextOpcode
protected void fetchNextOpcode() -
FetchLowAddr
protected void FetchLowAddr()Fetch low address byte, increment PC
Addressing Modes:- Stack Manipulation
- Absolute
- Zero Page
- Zero Page Indexed
- Absolute Indexed
- Absolute Indirect
-
FetchLowAddrX
protected void FetchLowAddrX()Read from address, add index register X to it
Addressing Modes:- Zero Page Indexed
-
FetchLowAddrY
protected void FetchLowAddrY()Read from address, add index register Y to it
Addressing Modes:- Zero Page Indexed
-
FetchHighAddr
protected void FetchHighAddr()Fetch high address byte, increment PC (Absolute Addressing)
Low byte must have been obtained first!
Addressing Modes:- Absolute
-
FetchHighAddrX
protected void FetchHighAddrX()Fetch high byte of address, add index register X to low address byte,
increment PC
Addressing Modes:- Absolute Indexed
-
FetchHighAddrY
protected void FetchHighAddrY()Fetch high byte of address, add index register Y to low address byte,
increment PC
Addressing Modes:- Absolute Indexed
-
FetchLowEffAddr
protected void FetchLowEffAddr()Fetch effective address low
Addressing Modes:- Indirect
- Indexed Indirect (pre X)
- Indirect indexed (post Y)
-
FetchHighEffAddr
protected void FetchHighEffAddr()Fetch effective address high
Addressing Modes:- Indirect
- Indexed Indirect (pre X)
-
FetchHighEffAddrY
protected void FetchHighEffAddrY()Fetch effective address high, add Y to low byte of effective address
Addressing Modes:- Indirect indexed (post Y)
- Indirect indexed (post Y)
-
FetchLowPointer
protected void FetchLowPointer()Fetch pointer address low, increment PC
Addressing Modes:- Absolute Indirect
- Indirect indexed (post Y)
-
FetchHighPointer
protected void FetchHighPointer()Fetch pointer address high, increment PC
Addressing Modes:- Absolute Indirect
-
PutEffAddrDataByte
protected void PutEffAddrDataByte()Write Cycle_Data to effective address. -
PushLowPC
protected void PushLowPC()Push Program Counter Low Byte on stack, decrement S -
PushHighPC
protected void PushHighPC()Push Program Counter High Byte on stack, decrement S -
PushSR
protected void PushSR()Push P on stack, decrement S -
PopLowPC
protected void PopLowPC()Increment stack and pull program counter low byte from stack, -
PopHighPC
protected void PopHighPC()Increment stack and pull program counter high byte from stack, -
PopSR
protected void PopSR()increment S, Pop P off stack -
doADC
protected void doADC()BCD adding -
doSBC
protected void doSBC()BCD subtracting -
buildInstr
private void buildInstr() -
forcedJump
public void forcedJump(int address) Force CPU to start execution at given address- Parameter:
address- The address to start CPU execution at.
-
credits
Module Credits- Gibt zurück:
- credit string
-
setRDY
public final void setRDY(boolean rdy) Handle bus access signal. When RDY line is asserted, the CPU will pause when executing the next read operation.- Parameter:
rdy- new state for RDY signal
-
triggerRST
public final void triggerRST()This forces the CPU to abort whatever it is doing and immediately enter the RST interrupt handling sequence. The implementation is not compatible: instructions actually get aborted mid-execution. However, there is no possible way to trigger this signal from programs, so it's OK. -
triggerNMI
public final void triggerNMI()Trigger NMI interrupt on the CPU. Calling this method flags that CPU must enter the NMI routine at earliest opportunity. There is no way to cancel NMI request once given. -
triggerIRQ
public final void triggerIRQ()Pull IRQ line low on CPU. -
clearIRQ
public final void clearIRQ()Inform CPU that IRQ is no longer pulled low. -
setFlagsNZ
protected final void setFlagsNZ(byte value) Set N and Z flag values.- Parameter:
value- to set flags from
-
getStatusRegister
private byte getStatusRegister() -
setStatusRegister
private void setStatusRegister(byte sr) -
getStalledOnByte
public final byte getStalledOnByte()When stalled by BA but not yet tristated by AEC, the CPU generates read requests to the PLA chip. These reads likely concern whatever byte the CPU's current subcycle would need, but full emulation can be really tricky. We normally have this case only immediately after a write opcode, and thus the next read will concern the next opcode. Therefore, we fake it by reading the byte under the PC.- Gibt zurück:
- the value under PC
-
getEventScheduler
-
setEODHack
public void setEODHack(boolean hack)
-