Class NMOS6502

java.lang.Object
  |
  +--NMOS6502
Direct Known Subclasses:
N2A03, NMOS6510

public abstract class NMOS6502
extends java.lang.Object

The NMOS6502 class emulates the standard NMOS 6502 microprocessor.
This is an early version that has not been completely tested !!
So it is buggy. ;o)
Unofficial opcodes and addressing modes are not implemented.
IRQ implementation is incomplete. I would like to thank all the people who helped (huge list).
This code is GPL. :o)
This version is fast enough.
It can be extended to other CPU quite easily (you will have to modify this code a little bit if you plan to port Juergen's code, i will try to explain it later, or maybe i will do it).
Why not port Mame/Mess to Java ??
Copyright (c) 2000 Brice Fines.

  • This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
  • This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.
  • You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  • Based on :
    m6502
    Portable 6502/65c02/65sc02/6510/n2a03 emulator V1.2
    Copyright (c) 1998 Juergen Buchmueller, all rights reserved.
    65sc02 core Copyright (c) 2000 Peter Trauner.
  • This source code is released as freeware for non-commercial purposes.
  • You are free to use and redistribute this code in modified or unmodified form, provided you list me in the credits.
  • If you modify this source code, you must add a notice to each modified source file that it has been changed. If you're a nice person, you will clearly mark each change too. :)
  • If you wish to use this for commercial purposes, please contact me at pullmoll@t-online.de
  • The author of this copywritten work reserves the right to change the terms of its usage and license at any time, including retroactively
  • This entire notice must remain in the source code.
  • Version:
    0.2005 06/06/00
    Author:
    Jarod CANAL
    See Also:
    "A good documentation on NMOS 6502 for more details.", "The Gnu Public License."

    Field Summary
    protected  UInt8 accumulator
              Accumulator register.
    private  int after_cli
              Pending IRQ and last instruction cleared I.
    private  int CLEAR_LINE
              Clear line value.
    protected  Pair effectiveAddress
              Effective address.
    private  int F_B
              B flag value.
    protected  int F_C
              C flag value.
    protected  int F_D
              D flag value.
    private  int F_I
              I flag value.
    protected  int F_N
              N flag value.
    private  int F_T
              T flag value.
    protected  int F_V
              V flag value.
    protected  int F_Z
              Z flag value.
    protected  int iCount
              Number of cycles left.
    private  int irq_callback
              IRQ callbak.
    private  int irq_state
              IRQ state.
    private  int M6502_INT_IRQ
              IRQ interrupt value.
    private  int M6502_INT_NMI
              NMI interrupt value.
    private  int M6502_INT_NONE
              No interrupt value.
    private  int M6502_IRQ_VEC
              IRQ vector value.
    private  int M6502_NMI_VEC
              NMI vector value.
    private  int M6502_RST_VEC
              Reset vector value.
    private  int M6502_SET_OVERFLOW
              SET_OVERFLOW value.
    private  int nmi_state
              NMI state.
    protected  int pending_irq
              Nonzero if a NMI or IRQ is pending.
    private  Pair previousProgramCounter
              Previous program counter.
    protected  UInt8 processorStatus
              Processor status register.
    protected  Pair programCounter
              Program counter.
    private  int so_state
              Set overflow state.
    protected  Pair stackPointer
              Stack pointer.
    protected  int tmp
              Temporary variable used in adressing modes.
    protected  UInt8 xIndexRegister
              X index register.
    protected  UInt8 yIndexRegister
              Y index register.
    private  Pair zeroPageAddress
              Zero page address.
     
    Constructor Summary
    NMOS6502()
              Constructor.
     
    Method Summary
    protected  void ADC()
              Add with carry.
    private  void AND()
              Logical AND.
    private  void ASL()
              Arithmetic shift left.
    private  void BCC()
              Branch if carry clear.
    private  void BCS()
              Branch if carry set.
    private  void BEQ()
              Branch if equal.
    private  void BIT()
              Bit test.
    private  void BMI()
              Branch if minus.
    private  void BNE()
              Branch if not equal.
    private  void BPL()
              Branch if plus.
    private  void BRA(boolean condition)
              Branch relative.
    private  void BRK()
              Break.
    private  void BVC()
              Branch if overflow clear.
    private  void BVS()
              Branch if overflow set.
    private  void changePC16(int value)
              This is provided as a dummy function.
    private  void CLC()
              Clear carry flag.
    private  void CLD()
              Clear decimal flag.
    private  void CLI()
              Clear interrupt flag.
    private  void CLV()
              Clear overflow flag.
    private  void CMP()
              Compare accumulator.
    private  void CPX()
              Compare index X.
    private  void CPY()
              Compare index Y.
    protected  void debugRegisters()
              Display the different registers.
    private  void DEC()
              Decrement memory.
    private  void DEX()
              Decrement index X.
    private  void DEY()
              Decrement index Y.
    private  void EA_ABS()
              Effective address = absolute address.
    protected  void EA_ABX()
              Effective address = absolute address + X.
    protected  void EA_ABY()
              Effective address = absolute address + Y.
    private  void EA_IDX()
              Effective address = zero page + X indirect.
    private  void EA_IDY()
              Effective address = zero page indirect + Y (post indexed).
    private  void EA_IND()
              Effective address = indirect.
    private  void EA_ZPG()
              Effective address = zero page address.
    private  void EA_ZPX()
              Effective address = zero page address + X.
    private  void EA_ZPY()
              Effective address = zero page address + Y.
    private  void EOR()
              Logical exclusive OR.
    protected  int execute(int cycles)
              Main loop.
    private  void ILL()
              Illegal opcode.
    private  void INC()
              Increment memory.
    private  void INX()
              Increment index X.
    private  void INY()
              Increment index Y.
    private  void JMP()
              Jump to address.
    private  void JSR()
              Jump to subroutine.
    private  void LDA()
              Load accumulator.
    private  void LDX()
              Load index X.
    private  void LDY()
              Load index Y.
    protected  void LSR()
              Logic shift right.
    private  void m6502_set_irq_callback(int callback)
              Set IRQ callback.
    protected  void NOP()
              No operation.
    private  void opcode0x02()
              Opcode 0x02.
    private  void opcode0x03()
              Opcode 0x03.
    private  void opcode0x04()
              Opcode 0x04.
    private  void opcode0x07()
              Opcode 0x07.
    private  void opcode0x0B()
              Opcode 0x0B.
    private  void opcode0x0C()
              Opcode 0x0C.
    private  void opcode0x0F()
              Opcode 0x0F.
    private  void opcode0x12()
              Opcode 0x12.
    private  void opcode0x13()
              Opcode 0x13.
    private  void opcode0x14()
              Opcode 0x14.
    private  void opcode0x17()
              Opcode 0x17.
    private  void opcode0x1A()
              Opcode 0x1A.
    private  void opcode0x1B()
              Opcode 0x1B.
    private  void opcode0x1C()
              Opcode 0x1C.
    private  void opcode0x1F()
              Opcode 0x1F.
    private  void opcode0x22()
              Opcode 0x22.
    private  void opcode0x23()
              Opcode 0x23.
    private  void opcode0x27()
              Opcode 0x27.
    private  void opcode0x2B()
              Opcode 0x2B.
    private  void opcode0x2F()
              Opcode 0x2F.
    private  void opcode0x32()
              Opcode 0x32.
    private  void opcode0x33()
              Opcode 0x33.
    private  void opcode0x34()
              Opcode 0x34.
    private  void opcode0x37()
              Opcode 0x37.
    private  void opcode0x3A()
              Opcode 0x3A.
    private  void opcode0x3B()
              Opcode 0x3B.
    private  void opcode0x3C()
              Opcode 0x3C.
    private  void opcode0x3F()
              Opcode 0x3F.
    private  void opcode0x42()
              Opcode 0x42.
    private  void opcode0x43()
              Opcode 0x43.
    private  void opcode0x44()
              Opcode 0x44.
    private  void opcode0x47()
              Opcode 0x47.
    private  void opcode0x4B()
              Opcode 0x4B.
    private  void opcode0x4F()
              Opcode 0x4F.
    private  void opcode0x52()
              Opcode 0x52.
    private  void opcode0x53()
              Opcode 0x53.
    private  void opcode0x54()
              Opcode 0x54.
    private  void opcode0x57()
              Opcode 0x57.
    private  void opcode0x5A()
              Opcode 0x5A.
    private  void opcode0x5B()
              Opcode 0x5B.
    private  void opcode0x5C()
              Opcode 0x5C.
    private  void opcode0x5F()
              Opcode 0x5F.
    private  void opcode0x62()
              Opcode 0x62.
    private  void opcode0x63()
              Opcode 0x63.
    private  void opcode0x64()
              Opcode 0x64.
    private  void opcode0x67()
              Opcode 0x67.
    private  void opcode0x6B()
              Opcode 0x6B.
    private  void opcode0x6F()
              Opcode 0x6F.
    private  void opcode0x72()
              Opcode 0x72.
    private  void opcode0x73()
              Opcode 0x73.
    private  void opcode0x74()
              Opcode 0x74.
    private  void opcode0x77()
              Opcode 0x77.
    private  void opcode0x7A()
              Opcode 0x7A.
    private  void opcode0x7B()
              Opcode 0x7B.
    private  void opcode0x7C()
              Opcode 0x7C.
    private  void opcode0x7F()
              Opcode 0x7F.
    private  void opcode0x80()
              Opcode 0x80.
    private  void opcode0x82()
              Opcode 0x82.
    private  void opcode0x83()
              Opcode 0x83.
    private  void opcode0x87()
              Opcode 0x87.
    private  void opcode0x89()
              Opcode 0x89.
    private  void opcode0x8B()
              Opcode 0x8B.
    private  void opcode0x8F()
              Opcode 0x8F.
    private  void opcode0x92()
              Opcode 0x92.
    private  void opcode0x93()
              Opcode 0x93.
    private  void opcode0x97()
              Opcode 0x97.
    private  void opcode0x9B()
              Opcode 0x9B.
    private  void opcode0x9C()
              Opcode 0x9C.
    private  void opcode0x9E()
              Opcode 0x9E.
    private  void opcode0x9F()
              Opcode 0x9F.
    private  void opcode0xA3()
              Opcode 0xA3.
    private  void opcode0xA7()
              Opcode 0xA7.
    private  void opcode0xAB()
              Opcode 0xAB.
    private  void opcode0xAF()
              Opcode 0xAF.
    private  void opcode0xB2()
              Opcode 0xB2.
    private  void opcode0xB3()
              Opcode 0xB3.
    private  void opcode0xB7()
              Opcode 0xB7.
    private  void opcode0xBB()
              Opcode 0xBB.
    private  void opcode0xBF()
              Opcode 0xBF.
    private  void opcode0xC2()
              Opcode 0xC2.
    private  void opcode0xC3()
              Opcode 0xC3.
    private  void opcode0xC7()
              Opcode 0xC7.
    private  void opcode0xCB()
              Opcode 0xCB.
    private  void opcode0xCF()
              Opcode 0xCF.
    private  void opcode0xD2()
              Opcode 0xD2.
    private  void opcode0xD3()
              Opcode 0xD3.
    private  void opcode0xD4()
              Opcode 0xD4.
    private  void opcode0xD7()
              Opcode 0xD7.
    private  void opcode0xDA()
              Opcode 0xDA.
    private  void opcode0xDB()
              Opcode 0xDB.
    private  void opcode0xDC()
              Opcode 0xDC.
    private  void opcode0xDF()
              Opcode 0xDF.
    private  void opcode0xE2()
              Opcode 0xE2.
    private  void opcode0xE3()
              Opcode 0xE3.
    private  void opcode0xE7()
              Opcode 0xE7.
    private  void opcode0xEB()
              Opcode 0xEB.
    private  void opcode0xEF()
              Opcode 0xEF.
    private  void opcode0xF2()
              Opcode 0xF2.
    private  void opcode0xF3()
              Opcode 0xF3.
    private  void opcode0xF4()
              Opcode 0xF4.
    private  void opcode0xF7()
              Opcode 0xF7.
    private  void opcode0xFA()
              Opcode 0xFA.
    private  void opcode0xFB()
              Opcode 0xFB.
    private  void opcode0xFC()
              Opcode 0xFC.
    private  void opcode0xFF()
              Opcode 0xFF.
    private  void ORA()
              Logical inclusive OR.
    private  void PHA()
              Push accumulator.
    private  void PHP()
              Push processor status (flags).
    private  void PLA()
              Pull accumulator.
    private  void PLP()
              Pull processor status (flags).
    private  int PULL()
              Pull a register from the stack.
    private  void PUSH(int register)
              Push a register onto the stack.
    protected  void RD_ABS()
              Read a value using EA_ABS and store it into tmp.
    protected  void RD_ABX()
              Read a value using EA_ABX and store it into tmp.
    protected  void RD_ABY()
              Read a value using EA_ABY and store it into tmp.
    private  void RD_ACC()
              Read accumulator value and store it into tmp.
    protected  void RD_IDX()
              Read a value using EA_IDX and store it into tmp.
    protected  void RD_IDY()
              Read a value using EA_IDY and store it into tmp.
    protected  void RD_IMM()
              Read directly a value and store it into tmp.
    protected  void RD_ZPG()
              Read a value using EA_ZPG and store it into tmp.
    protected  void RD_ZPX()
              Read a value using EA_ZPX and store it into tmp.
    protected  void RD_ZPY()
              Read a value using EA_ZPY and store it into tmp.
    protected abstract  int RDMEM(int address)
              Read from memory.
    private  int readOpcode()
              Read an opcode.
    private  int readOpcodeArgument()
              Read an opcode argument.
    protected  void reset()
              Reset the processor.
    private  void ROL()
              Rotate left.
    protected  void ROR()
              Rotate right.
    private  void RTI()
              Return from interrupt.
    private  void RTS()
              Return from subroutine.
    protected  void SBC()
              Subtract with carry.
    private  void SEC()
              Set carry flag.
    private  void SED()
              Set decimal flag.
    private  void SEI()
              Set interrupt flag.
    protected  void set_irq_line(int irqline, int state)
              Set IRQ line.
    protected  void set_nmi_line(int state)
              Set NMI line.
    protected  void setNZ(int condition)
              Set N and Z flags in the processor status register according to condition.
    private  void STA()
              Store accumulator.
    private  void STX()
              Store index X.
    private  void STY()
              Store index Y.
    private  void switchOpcode(int opcode)
              Switch for opcode interpretation.
    protected  void take_irq()
              Take IRQ.
    private  void TAX()
              Transfer accumulator to index X.
    private  void TAY()
              Transfer accumulator to index Y.
    private  void TSX()
              Transfer stack LSB to index X.
    private  void TXA()
              Transfer index X to accumulator.
    private  void TXS()
              Transfer index X to stack LSB.
    private  void TYA()
              Transfer index Y to accumulator.
    protected  void WB_ACC()
               
    protected  void WB_EA()
               
    protected  void WR_ABS()
              Write a value from tmp using EA_ABS.
    protected  void WR_ABX()
              Write a value from tmp using EA_ABX.
    protected  void WR_ABY()
              Write a value from tmp using EA_ABY.
    protected  void WR_IDX()
              Write a value from tmp using EA_IDX.
    protected  void WR_IDY()
              Write a value from tmp using EA_IDY.
    protected  void WR_ZPG()
              Write a value from tmp using EA_ZPG.
    protected  void WR_ZPX()
              Write a value from tmp using EA_ZPX.
    protected  void WR_ZPY()
              Write a value from tmp using EA_ZPY.
    protected abstract  void WRMEM(int address, int data)
              Write to memory.
     
    Methods inherited from class java.lang.Object
    , clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
     

    Field Detail

    previousProgramCounter

    private Pair previousProgramCounter
    Previous program counter.

    programCounter

    protected Pair programCounter
    Program counter.

    stackPointer

    protected Pair stackPointer
    Stack pointer.
    Always between 0x0100 and 0x01FF.

    zeroPageAddress

    private Pair zeroPageAddress
    Zero page address.

    effectiveAddress

    protected Pair effectiveAddress
    Effective address.

    accumulator

    protected UInt8 accumulator
    Accumulator register.

    xIndexRegister

    protected UInt8 xIndexRegister
    X index register.

    yIndexRegister

    protected UInt8 yIndexRegister
    Y index register.

    processorStatus

    protected UInt8 processorStatus
    Processor status register.
    Flags in the status register are as follows:
    N V T B D I Z C
    7 6 5 4 3 2 1 0

    N: Negative flag (also called S flag for sign flag).
    V: Overflow flag.
    T: Bit number 5 is unused. It is always set and it is initialized by reset() so you would better call it before running the processor.
    B: Break flag.
    D: Decimal mode status flag.
    I: Interrupt flag.
    Z: Zero flag.
    C: Carry flag.

    after_cli

    private int after_cli
    Pending IRQ and last instruction cleared I.

    nmi_state

    private int nmi_state
    NMI state.

    irq_state

    private int irq_state
    IRQ state.

    so_state

    private int so_state
    Set overflow state.

    pending_irq

    protected int pending_irq
    Nonzero if a NMI or IRQ is pending.
    If pendingInterrupt = 0, no interrupt pending.
    If pendingInterrupt = 1, an IRQ is pending.
    If pendingInterrupt = 2, a NMI is pending.

    irq_callback

    private int irq_callback
    IRQ callbak.

    iCount

    protected int iCount
    Number of cycles left.

    tmp

    protected int tmp
    Temporary variable used in adressing modes.

    M6502_INT_NONE

    private final int M6502_INT_NONE
    No interrupt value.
    Replace a #define M6502_INT_NONE 0.

    M6502_INT_IRQ

    private final int M6502_INT_IRQ
    IRQ interrupt value.
    Replace a #define M6502_INT_IRQ 1.

    M6502_INT_NMI

    private final int M6502_INT_NMI
    NMI interrupt value.
    Replace a #define M6502_INT_NMI 2.

    M6502_SET_OVERFLOW

    private final int M6502_SET_OVERFLOW
    SET_OVERFLOW value.
    Replace a #define M6502_SET_OVERFLOW 3. Use cpu_set_irq_line(cpu, M6502_SET_OVERFLOW, level) to change level of the so input line positiv edge sets overflow flag.

    M6502_NMI_VEC

    private final int M6502_NMI_VEC
    NMI vector value.
    Replace a #define M6502_NMI_VEC 0xFFFA.

    M6502_RST_VEC

    private final int M6502_RST_VEC
    Reset vector value.
    Replace a #define M6502_RST_VEC 0xFFFC.

    M6502_IRQ_VEC

    private final int M6502_IRQ_VEC
    IRQ vector value.
    Replace a #define M6502_IRQ_VEC 0xFFFE.

    F_C

    protected final int F_C
    C flag value.
    Replace a #define F_C 0x01.

    F_Z

    protected final int F_Z
    Z flag value.
    Replace a #define F_Z 0x02.

    F_I

    private final int F_I
    I flag value.
    Replace a #define F_I 0x04.

    F_D

    protected final int F_D
    D flag value.
    Replace a #define F_D 0x08.

    F_B

    private final int F_B
    B flag value.
    Replace a #define F_B 0x10.

    F_T

    private final int F_T
    T flag value.
    Replace a #define F_T 0x20.

    F_V

    protected final int F_V
    V flag value.
    Replace a #define F_V 0x40.

    F_N

    protected final int F_N
    N flag value.
    Replace a #define F_N 0x80.

    CLEAR_LINE

    private final int CLEAR_LINE
    Clear line value.
    Replace a #define CLEAR_LINE 0.
    Constructor Detail

    NMOS6502

    public NMOS6502()
    Constructor.
    Method Detail

    debugRegisters

    protected final void debugRegisters()
    Display the different registers.
    It produces the following output:

    Accumulator: xxx X register: xxx Y register: xxx
    Stack pointer: xxx Program counter: xxxx Status flags: NV5BDIZC

    Accumulator, X and Y registers are integer values between 0 and 255.
    Stack pointer is an integer value between 0 and 255 but you have to add 0x0100 to get the true value.
    Program counter is an integer value between 0 and 65535.
    Why not improve it and display hexadecimal values?
    Status register display use the following rules:
  • 5 is always displayed (since bit 5 is always set).
  • If a bit is set, the letter corresponding to the flag is displayed. Otherwise (i.e. bit is cleared), an underscore ("_") is displayed.

  • changePC16

    private final void changePC16(int value)
    This is provided as a dummy function.
    Some system will use it when program counter change (if you plan to use it you will have to modify this source by quitting the final and private attributes and make it protected and abstract for example).
    Parameters:
    value - is used for the new program counter.

    WRMEM

    protected abstract void WRMEM(int address,
                                  int data)
    Write to memory.
    You have to provide this function.
    Parameters:
    address - the memory address where you want to write.
    data - the value you want to write.

    RDMEM

    protected abstract int RDMEM(int address)
    Read from memory.
    You have to provide this function.
    Parameters:
    address - is the memory address you want to read from.
    Returns:
    the unsigned byte read in memory.

    setNZ

    protected final void setNZ(int condition)
    Set N and Z flags in the processor status register according to condition.
    Parameters:
    condition - The condition.
    If condition = 0, N is cleared and Z is set.
    Else N is set if it is set in condition and Z is cleared.

    readOpcode

    private final int readOpcode()
    Read an opcode.
    Returns:
    the opcode value.

    readOpcodeArgument

    private final int readOpcodeArgument()
    Read an opcode argument.
    Returns:
    the opcode value.

    BRA

    private final void BRA(boolean condition)
    Branch relative.
    An extra cycle is used if page boundary is crossed.
    Parameters:
    condition - that indicates if the branch relative occurs.

    EA_ZPG

    private final void EA_ZPG()
    Effective address = zero page address.

    EA_ZPX

    private final void EA_ZPX()
    Effective address = zero page address + X.

    EA_ZPY

    private final void EA_ZPY()
    Effective address = zero page address + Y.

    EA_ABS

    private final void EA_ABS()
    Effective address = absolute address.

    EA_ABX

    protected final void EA_ABX()
    Effective address = absolute address + X.

    EA_ABY

    protected final void EA_ABY()
    Effective address = absolute address + Y.

    EA_IDX

    private final void EA_IDX()
    Effective address = zero page + X indirect.
    This is called pre indexed mode.

    EA_IDY

    private final void EA_IDY()
    Effective address = zero page indirect + Y (post indexed).
    Subtract 1 cycle if page boundary is crossed.

    EA_IND

    private final void EA_IND()
    Effective address = indirect.
    This is only only used by JMP.

    RD_IMM

    protected final void RD_IMM()
    Read directly a value and store it into tmp.

    RD_ACC

    private final void RD_ACC()
    Read accumulator value and store it into tmp.

    RD_ZPG

    protected final void RD_ZPG()
    Read a value using EA_ZPG and store it into tmp.

    RD_ZPX

    protected final void RD_ZPX()
    Read a value using EA_ZPX and store it into tmp.

    RD_ZPY

    protected final void RD_ZPY()
    Read a value using EA_ZPY and store it into tmp.

    RD_ABS

    protected final void RD_ABS()
    Read a value using EA_ABS and store it into tmp.

    RD_ABX

    protected final void RD_ABX()
    Read a value using EA_ABX and store it into tmp.

    RD_ABY

    protected final void RD_ABY()
    Read a value using EA_ABY and store it into tmp.

    RD_IDX

    protected final void RD_IDX()
    Read a value using EA_IDX and store it into tmp.

    RD_IDY

    protected final void RD_IDY()
    Read a value using EA_IDY and store it into tmp.

    WR_ZPG

    protected final void WR_ZPG()
    Write a value from tmp using EA_ZPG.

    WR_ZPX

    protected final void WR_ZPX()
    Write a value from tmp using EA_ZPX.

    WR_ZPY

    protected final void WR_ZPY()
    Write a value from tmp using EA_ZPY.

    WR_ABS

    protected final void WR_ABS()
    Write a value from tmp using EA_ABS.

    WR_ABX

    protected final void WR_ABX()
    Write a value from tmp using EA_ABX.

    WR_ABY

    protected final void WR_ABY()
    Write a value from tmp using EA_ABY.

    WR_IDX

    protected final void WR_IDX()
    Write a value from tmp using EA_IDX.

    WR_IDY

    protected final void WR_IDY()
    Write a value from tmp using EA_IDY.

    WB_ACC

    protected final void WB_ACC()

    WB_EA

    protected final void WB_EA()

    PUSH

    private final void PUSH(int register)
    Push a register onto the stack.
    Parameters:
    register - the byte to push.

    PULL

    private final int PULL()
    Pull a register from the stack.
    Returns:
    the byte pulled.

    ADC

    protected void ADC()
    Add with carry.

    AND

    private final void AND()
    Logical AND.

    ASL

    private final void ASL()
    Arithmetic shift left.

    BCC

    private final void BCC()
    Branch if carry clear.

    BCS

    private final void BCS()
    Branch if carry set.

    BEQ

    private final void BEQ()
    Branch if equal.

    BIT

    private final void BIT()
    Bit test.

    BMI

    private final void BMI()
    Branch if minus.

    BNE

    private final void BNE()
    Branch if not equal.

    BPL

    private final void BPL()
    Branch if plus.

    BRK

    private final void BRK()
    Break.
    Increment PC, push PC high byte, PC low byte, flags (with B bit set), set I flag, reset D flag and jump via IRQ vector.

    BVC

    private final void BVC()
    Branch if overflow clear.

    BVS

    private final void BVS()
    Branch if overflow set.

    CLC

    private final void CLC()
    Clear carry flag.

    CLD

    private final void CLD()
    Clear decimal flag.

    CLI

    private final void CLI()
    Clear interrupt flag.

    CLV

    private final void CLV()
    Clear overflow flag.

    CMP

    private final void CMP()
    Compare accumulator.

    CPX

    private final void CPX()
    Compare index X.

    CPY

    private final void CPY()
    Compare index Y.

    DEC

    private final void DEC()
    Decrement memory.

    DEX

    private final void DEX()
    Decrement index X.

    DEY

    private final void DEY()
    Decrement index Y.

    EOR

    private final void EOR()
    Logical exclusive OR.

    ILL

    private final void ILL()
    Illegal opcode.

    INC

    private final void INC()
    Increment memory.

    INX

    private final void INX()
    Increment index X.

    INY

    private final void INY()
    Increment index Y.

    JMP

    private final void JMP()
    Jump to address.
    Set PC to the effective address.

    JSR

    private final void JSR()
    Jump to subroutine.
    Decrement PC (sic!), push PC high byte, push PC low byte and set PC to the effective address.

    LDA

    private final void LDA()
    Load accumulator.

    LDX

    private final void LDX()
    Load index X.

    LDY

    private final void LDY()
    Load index Y.

    LSR

    protected final void LSR()
    Logic shift right.

    0 -> [7][6][5][4][3][2][1][0] -> C

    NOP

    protected final void NOP()
    No operation.

    ORA

    private final void ORA()
    Logical inclusive OR.

    PHA

    private final void PHA()
    Push accumulator.

    PHP

    private final void PHP()
    Push processor status (flags).

    PLA

    private final void PLA()
    Pull accumulator.

    PLP

    private final void PLP()
    Pull processor status (flags).

    ROL

    private final void ROL()
    Rotate left.

    new C <- [7][6][5][4][3][2][1][0] <- C

    ROR

    protected final void ROR()
    Rotate right.

    C -> [7][6][5][4][3][2][1][0] -> new C

    RTI

    private final void RTI()
    Return from interrupt.
    Pull flags, pull PC low byte, pull PC high byte.

    RTS

    private final void RTS()
    Return from subroutine.

    Pull PC low byte, PC high byte and increment PC.

    SBC

    protected void SBC()
    Subtract with carry.

    SEC

    private final void SEC()
    Set carry flag.

    SED

    private final void SED()
    Set decimal flag.

    SEI

    private final void SEI()
    Set interrupt flag.

    STA

    private final void STA()
    Store accumulator.

    STX

    private final void STX()
    Store index X.

    STY

    private final void STY()
    Store index Y.

    TAX

    private final void TAX()
    Transfer accumulator to index X.

    TAY

    private final void TAY()
    Transfer accumulator to index Y.

    TSX

    private final void TSX()
    Transfer stack LSB to index X.

    TXA

    private final void TXA()
    Transfer index X to accumulator.

    TXS

    private final void TXS()
    Transfer index X to stack LSB.
    No flags changed (sic!).

    TYA

    private final void TYA()
    Transfer index Y to accumulator.

    opcode0x80

    private void opcode0x80()
    Opcode 0x80.
    2 ILL.

    opcode0x02

    private void opcode0x02()
    Opcode 0x02.
    2 ILL.

    opcode0x22

    private void opcode0x22()
    Opcode 0x22.
    2 ILL.

    opcode0x42

    private void opcode0x42()
    Opcode 0x42.
    2 ILL.

    opcode0x62

    private void opcode0x62()
    Opcode 0x62.
    2 ILL.

    opcode0x82

    private void opcode0x82()
    Opcode 0x82.
    2 ILL.

    opcode0xC2

    private void opcode0xC2()
    Opcode 0xC2.
    2 ILL.

    opcode0xE2

    private void opcode0xE2()
    Opcode 0xE2.
    2 ILL.

    opcode0x12

    private void opcode0x12()
    Opcode 0x12.
    2 ILL.

    opcode0x32

    private void opcode0x32()
    Opcode 0x32.
    2 ILL.

    opcode0x52

    private void opcode0x52()
    Opcode 0x52.
    2 ILL.

    opcode0x72

    private void opcode0x72()
    Opcode 0x72.
    2 ILL.

    opcode0x92

    private void opcode0x92()
    Opcode 0x92.
    2 ILL.

    opcode0xB2

    private void opcode0xB2()
    Opcode 0xB2.
    2 ILL.

    opcode0xD2

    private void opcode0xD2()
    Opcode 0xD2.
    2 ILL.

    opcode0xF2

    private void opcode0xF2()
    Opcode 0xF2.
    2 ILL.

    opcode0x03

    private void opcode0x03()
    Opcode 0x03.
    2 ILL.

    opcode0x23

    private void opcode0x23()
    Opcode 0x23.
    2 ILL.

    opcode0x43

    private void opcode0x43()
    Opcode 0x43.
    2 ILL.

    opcode0x63

    private void opcode0x63()
    Opcode 0x63.
    2 ILL.

    opcode0x83

    private void opcode0x83()
    Opcode 0x83.
    2 ILL.

    opcode0xA3

    private void opcode0xA3()
    Opcode 0xA3.
    2 ILL.

    opcode0xC3

    private void opcode0xC3()
    Opcode 0xC3.
    2 ILL.

    opcode0xE3

    private void opcode0xE3()
    Opcode 0xE3.
    2 ILL.

    opcode0x13

    private void opcode0x13()
    Opcode 0x13.
    2 ILL.

    opcode0x33

    private void opcode0x33()
    Opcode 0x33.
    2 ILL.

    opcode0x53

    private void opcode0x53()
    Opcode 0x53.
    2 ILL.

    opcode0x73

    private void opcode0x73()
    Opcode 0x73.
    2 ILL.

    opcode0x93

    private void opcode0x93()
    Opcode 0x93.
    2 ILL.

    opcode0xB3

    private void opcode0xB3()
    Opcode 0xB3.
    2 ILL.

    opcode0xD3

    private void opcode0xD3()
    Opcode 0xD3.
    2 ILL.

    opcode0xF3

    private void opcode0xF3()
    Opcode 0xF3.
    2 ILL.

    opcode0x04

    private void opcode0x04()
    Opcode 0x04.
    2 ILL.

    opcode0x44

    private void opcode0x44()
    Opcode 0x44.
    2 ILL.

    opcode0x64

    private void opcode0x64()
    Opcode 0x64.
    2 ILL.

    opcode0x14

    private void opcode0x14()
    Opcode 0x14.
    2 ILL.

    opcode0x34

    private void opcode0x34()
    Opcode 0x34.
    2 ILL.

    opcode0x54

    private void opcode0x54()
    Opcode 0x54.
    2 ILL.

    opcode0x74

    private void opcode0x74()
    Opcode 0x74.
    2 ILL.

    opcode0xD4

    private void opcode0xD4()
    Opcode 0xD4.
    2 ILL.

    opcode0xF4

    private void opcode0xF4()
    Opcode 0xF4.
    2 ILL.

    opcode0x07

    private void opcode0x07()
    Opcode 0x07.
    2 ILL.

    opcode0x27

    private void opcode0x27()
    Opcode 0x27.
    2 ILL.

    opcode0x47

    private void opcode0x47()
    Opcode 0x47.
    2 ILL.

    opcode0x67

    private void opcode0x67()
    Opcode 0x67.
    2 ILL.

    opcode0x87

    private void opcode0x87()
    Opcode 0x87.
    2 ILL.

    opcode0xA7

    private void opcode0xA7()
    Opcode 0xA7.
    2 ILL.

    opcode0xC7

    private void opcode0xC7()
    Opcode 0xC7.
    2 ILL.

    opcode0xE7

    private void opcode0xE7()
    Opcode 0xE7.
    2 ILL.

    opcode0x17

    private void opcode0x17()
    Opcode 0x17.
    2 ILL.

    opcode0x37

    private void opcode0x37()
    Opcode 0x37.
    2 ILL.

    opcode0x57

    private void opcode0x57()
    Opcode 0x57.
    2 ILL.

    opcode0x77

    private void opcode0x77()
    Opcode 0x77.
    2 ILL.

    opcode0x97

    private void opcode0x97()
    Opcode 0x97.
    2 ILL.

    opcode0xB7

    private void opcode0xB7()
    Opcode 0xB7.
    2 ILL.

    opcode0xD7

    private void opcode0xD7()
    Opcode 0xD7.
    2 ILL.

    opcode0xF7

    private void opcode0xF7()
    Opcode 0xF7.
    2 ILL.

    opcode0x89

    private void opcode0x89()
    Opcode 0x89.
    2 ILL.

    opcode0x1A

    private void opcode0x1A()
    Opcode 0x1A.
    2 ILL.

    opcode0x3A

    private void opcode0x3A()
    Opcode 0x3A.
    2 ILL.

    opcode0x5A

    private void opcode0x5A()
    Opcode 0x5A.
    2 ILL.

    opcode0x7A

    private void opcode0x7A()
    Opcode 0x7A.
    2 ILL.

    opcode0xDA

    private void opcode0xDA()
    Opcode 0xDA.
    2 ILL.

    opcode0xFA

    private void opcode0xFA()
    Opcode 0xFA.
    2 ILL.

    opcode0x0B

    private void opcode0x0B()
    Opcode 0x0B.
    2 ILL.

    opcode0x2B

    private void opcode0x2B()
    Opcode 0x2B.
    2 ILL.

    opcode0x4B

    private void opcode0x4B()
    Opcode 0x4B.
    2 ILL.

    opcode0x6B

    private void opcode0x6B()
    Opcode 0x6B.
    2 ILL.

    opcode0x8B

    private void opcode0x8B()
    Opcode 0x8B.
    2 ILL.

    opcode0xAB

    private void opcode0xAB()
    Opcode 0xAB.
    2 ILL.

    opcode0xCB

    private void opcode0xCB()
    Opcode 0xCB.
    2 ILL.

    opcode0xEB

    private void opcode0xEB()
    Opcode 0xEB.
    2 ILL.

    opcode0x1B

    private void opcode0x1B()
    Opcode 0x1B.
    2 ILL.

    opcode0x3B

    private void opcode0x3B()
    Opcode 0x3B.
    2 ILL.

    opcode0x5B

    private void opcode0x5B()
    Opcode 0x5B.
    2 ILL.

    opcode0x7B

    private void opcode0x7B()
    Opcode 0x7B.
    2 ILL.

    opcode0x9B

    private void opcode0x9B()
    Opcode 0x9B.
    2 ILL.

    opcode0xBB

    private void opcode0xBB()
    Opcode 0xBB.
    2 ILL.

    opcode0xDB

    private void opcode0xDB()
    Opcode 0xDB.
    2 ILL.

    opcode0xFB

    private void opcode0xFB()
    Opcode 0xFB.
    2 ILL.

    opcode0x0C

    private void opcode0x0C()
    Opcode 0x0C.
    2 ILL.

    opcode0x1C

    private void opcode0x1C()
    Opcode 0x1C.
    2 ILL.

    opcode0x3C

    private void opcode0x3C()
    Opcode 0x3C.
    2 ILL.

    opcode0x5C

    private void opcode0x5C()
    Opcode 0x5C.
    2 ILL.

    opcode0x7C

    private void opcode0x7C()
    Opcode 0x7C.
    2 ILL.

    opcode0x9C

    private void opcode0x9C()
    Opcode 0x9C.
    2 ILL.

    opcode0xDC

    private void opcode0xDC()
    Opcode 0xDC.
    2 ILL.

    opcode0x9E

    private void opcode0x9E()
    Opcode 0x9E.
    2 ILL.

    opcode0xFC

    private void opcode0xFC()
    Opcode 0xFC.
    2 ILL.

    opcode0x0F

    private void opcode0x0F()
    Opcode 0x0F.
    2 ILL.

    opcode0x2F

    private void opcode0x2F()
    Opcode 0x2F.
    2 ILL.

    opcode0x4F

    private void opcode0x4F()
    Opcode 0x4F.
    2 ILL.

    opcode0x6F

    private void opcode0x6F()
    Opcode 0x6F.
    2 ILL.

    opcode0x8F

    private void opcode0x8F()
    Opcode 0x8F.
    2 ILL.

    opcode0xAF

    private void opcode0xAF()
    Opcode 0xAF.
    2 ILL.

    opcode0xCF

    private void opcode0xCF()
    Opcode 0xCF.
    2 ILL.

    opcode0xEF

    private void opcode0xEF()
    Opcode 0xEF.
    2 ILL.

    opcode0x1F

    private void opcode0x1F()
    Opcode 0x1F.
    2 ILL.

    opcode0x3F

    private void opcode0x3F()
    Opcode 0x3F.
    2 ILL.

    opcode0x5F

    private void opcode0x5F()
    Opcode 0x5F.
    2 ILL.

    opcode0x7F

    private void opcode0x7F()
    Opcode 0x7F.
    2 ILL.

    opcode0x9F

    private void opcode0x9F()
    Opcode 0x9F.
    2 ILL.

    opcode0xBF

    private void opcode0xBF()
    Opcode 0xBF.
    2 ILL.

    opcode0xDF

    private void opcode0xDF()
    Opcode 0xDF.
    2 ILL.

    opcode0xFF

    private void opcode0xFF()
    Opcode 0xFF.
    2 ILL.

    switchOpcode

    private final void switchOpcode(int opcode)
    Switch for opcode interpretation.
    Parameters:
    opcode - the opcode to be interpreted.

    reset

    protected final void reset()
    Reset the processor.

    execute

    protected final int execute(int cycles)
    Main loop.
    Parameters:
    cycles - the number of cycles available to execute opcodes.
    Returns:
    the number of extra cycles (i.e. unavailable cycles) consumed by the last opcode .

    set_nmi_line

    protected final void set_nmi_line(int state)
    Set NMI line.
    Parameters:
    state - is the NMI line state.
    If state is 0, the line is inactive, else the line is active. May be revised to become a boolean?

    set_irq_line

    protected final void set_irq_line(int irqline,
                                      int state)
    Set IRQ line.
    Parameters:
    irqline - is the IRQ line.
    state - is the IRQ line state.
    If state is 0, the line is inactive, else the line is active. May be revised to become a boolean?

    m6502_set_irq_callback

    private final void m6502_set_irq_callback(int callback)
    Set IRQ callback.
    Parameters:
    callback - ???.
    Not implemented yet.

    take_irq

    protected final void take_irq()
    Take IRQ.