Klasse MOS6510

java.lang.Object
libsidplay.components.mos6510.MOS6510
Bekannte direkte Unterklassen:
MOS6510Debug, MOS6510ViceSync

public class MOS6510 extends Object
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
  • Felddetails

    • SR_INTERRUPT

      public static final int SR_INTERRUPT
      Status register interrupt bit.
      Siehe auch:
    • SP_PAGE

      protected static final byte SP_PAGE
      Stack page location
      Siehe auch:
    • MAX

      private static final int MAX
      IRQ/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 EOD
      Hack for Edge of Disgrace.
    • ANE_CONST

      private static final int ANE_CONST
      The 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

      protected final EventScheduler context
      Our event context copy.
    • rdy

      private boolean rdy
      RDY pin state (stop CPU on read)
    • instrTable

      private final Runnable[] instrTable
      Table of CPU opcode implementations
    • processorCycleNoSteal

      private final boolean[] processorCycleNoSteal
      true - Represents an instruction subcycle that writes. Whereas false - represents an instruction subcycle that reads.
    • cycleCount

      protected int cycleCount
      Current instruction and subcycle within instruction
    • Cycle_EffectiveAddress

      protected int Cycle_EffectiveAddress
      Data 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

      protected Function<Boolean,Boolean> v
    • jmpJsr

      protected Consumer<Integer> jmpJsr
    • cpuRead

      protected Function<Integer,Byte> cpuRead
    • cpuWrite

      protected BiConsumer<Integer,Byte> cpuWrite
    • irqAssertedOnPin

      protected boolean irqAssertedOnPin
      IRQ asserted on CPU
    • interruptCycle

      protected int interruptCycle
      When IRQ was triggered. -MAX means "during some previous instruction", MAX means "no IRQ"
    • nmiFlag

      protected boolean nmiFlag
      NMI requested?
    • rstFlag

      protected boolean rstFlag
      RST requested?
    • eventWithoutSteals

      private final Event eventWithoutSteals
      When AEC signal is high, no stealing is possible
    • eventWithSteals

      private final Event eventWithSteals
      When AEC signal is low, steals permitted
  • Konstruktordetails

    • MOS6510

      public MOS6510(EventScheduler context)
      Create new CPU emu
      Parameter:
      context - The Event Context
  • Methodendetails

    • setMemoryHandler

      public void setMemoryHandler(Function<Integer,Byte> cpuRead, BiConsumer<Integer,Byte> cpuWrite)
    • setJmpJsrHandler

      public void setJmpJsrHandler(Consumer<Integer> jmpJsr)
    • setVFlagHandler

      public void setVFlagHandler(Function<Boolean,Boolean> v)
    • 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)
      • 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

        public static String 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

        public final EventScheduler getEventScheduler()
      • setEODHack

        public void setEODHack(boolean hack)