jmce - 1_02

jmce.mos
Class M6502

java.lang.Object
  extended by jmce.sim.AbstractHardware
      extended by jmce.sim.cpu.AbstractCPU
          extended by jmce.mos.M6502
All Implemented Interfaces:
java.lang.Runnable, M65XXConstants, BreakPointListener, CPU, Hardware, InterruptManager
Direct Known Subclasses:
VIC20

public class M6502
extends AbstractCPU
implements M65XXConstants

MOS 6502

Emulated register : A,X,Y,P,S,PC

The 6502 have one one memory used as program data and i/o space.

Lmitations

Since:
1.01
Version:
1.00
Author:
Mario Viara

Field Summary
 
Fields inherited from class jmce.sim.cpu.AbstractCPU
interrupts, io, memory, NS100MS, NS1MS
 
Fields inherited from interface jmce.mos.M65XXConstants
BRK_VECTOR, IRQ_VECTOR, NMI_VECTTOR, P_B, P_C, P_D, P_E, P_I, P_S, P_V, P_Z, RESET_VECTOR, S_PAGE, Z_PAGE
 
Fields inherited from interface jmce.sim.CPU
BIG_ENDIAN, IO_MEMORY, LITTLE_ENDIAN, MAIN_MEMORY
 
Constructor Summary
M6502()
           
 
Method Summary
 void dumpStatistics(java.io.PrintStream ps)
          Dump cpu execution statistics in the specified stream.
 int fireISR(Interrupt irq)
          This function must be overridden from sub class that implements interrupt.
 int getWord(int a)
          Read one word (16 bit) from the main memory.
 void init(Hardware parent)
          Initialize the hardware.
protected  void initMemories()
           
protected  void initPeripherals()
          No peripherals are build in on 6502 this function is present only for compatibility
protected  void initRegisters()
           
 boolean isInterruptEnabled()
          Return the status of the interrupt enable
 int pc()
          Return the register used as program counter
 void pc(int pc)
          Set the program counter.
protected  int pop()
          Pop a 8 bit value from the stack.
protected  int pop16()
          Pop a word (16 bit) from the stack
protected  void push(int value)
          Push a 8 bit value on the stack.
protected  void push16(int value)
          Push a word (16 bit) on the stack
 void reset()
          Reset the CPU and call all installed ResetListener.
 void setWord(int a, int v)
          Set one word (16 bit) in the main memory
 int vectorToAddress(int irq)
          Convert one irq number to the memory address.
 
Methods inherited from class jmce.sim.cpu.AbstractCPU
abort, addCycleListener, addDecoder, addExceptionListener, addExecBreakPoint, addInterrupt, addIOReadListener, addIOReadListener, addIOWriteListener, addIOWriteListener, addLoader, addMemoryWriteListener, addOffset, addReadBreakPoint, addRegister, addResetListener, addTimerCycle, addTimerMs, addTraceListener, addWriteBreakPoint, bit0, bit7, breakPointEvent, createRuntime, decodeAt, destroy, dumpStatistics, dumpTitle, dumpValue, dumpValue, fetch, fireNMI, formatFrequence, getBreakPointAt, getBreakPointCount, getByte, getCallListener, getClock, getClockPerCycle, getCycle, getCycleMillis, getDecoderAt, getDecoderCount, getEndian, getExceptionListenerAt, getExceptionListenerCount, getExecStatistics, getInterruptCount, getInterruptCounter, getInterruptName, getIOByte, getLenghtAt, getMemory, getMemoryAt, getMemoryCount, getMemoryForName, getOpcodeAt, getOpcodes, getRealTime, getRegisterAt, getRegisterCount, getRegisterForName, getResetAddress, getUsage, getUsageDesc, getWordBig, getWordLittle, halt, idle, isBigEndian, isLittleEndian, isRunning, load, load, notifyInterrupt, removeBreakPoint, removeBreakPoint, removeExceptionListener, removeTraceListener, resetRegisters, run, run0, setByte, setCallListener, setClock, setClockPerCycle, setEndian, setIO, setIOByte, setMemory, setOpcode, setRealTime, setResetAddress, setStatusLine, setTill, start, step, step0, stepNoBreak, stop
 
Methods inherited from class jmce.sim.AbstractHardware
addHardware, createFrame, getHardware, getHardware, getHardware, getHardware, getHardware, getHardwareCount, getHardwareForName, getHardwareInstances, getHardwareTree, getName, getParent, initSwing, removeHardware, removeHardware, setHardware, setHardware, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jmce.sim.Hardware
addHardware, getHardware, getHardware, getHardware, getHardware, getHardwareCount, getHardwareInstances, getHardwareTree, getName, getParent, initSwing, removeHardware, removeHardware, setHardware, setHardware, setName
 

Constructor Detail

M6502

public M6502()
Method Detail

vectorToAddress

public int vectorToAddress(int irq)
                    throws SIMException
Convert one irq number to the memory address.

Parameters:
irq - Interrupt request number.
Returns:
The address of the IRQ.
Throws:
SIMException

reset

public void reset()
           throws SIMException
Description copied from class: AbstractCPU
Reset the CPU and call all installed ResetListener.

Reset is performed in this order :

Specified by:
reset in interface Hardware
Overrides:
reset in class AbstractCPU
Throws:
SIMException

setWord

public final void setWord(int a,
                          int v)
                   throws SIMException
Description copied from interface: CPU
Set one word (16 bit) in the main memory

Specified by:
setWord in interface CPU
Parameters:
a - - Address
v - - value
Throws:
SIMException

getWord

public final int getWord(int a)
                  throws SIMException
Description copied from interface: CPU
Read one word (16 bit) from the main memory.

Specified by:
getWord in interface CPU
Parameters:
a - - Address
Returns:
The word at the specified address.
Throws:
SIMException

initRegisters

protected void initRegisters()

init

public void init(Hardware parent)
          throws SIMException
Description copied from interface: Hardware
Initialize the hardware. This method must be called before any use of the interface. Only set ... / get ... method are allowed to be called before the intialization.

Specified by:
init in interface Hardware
Overrides:
init in class AbstractCPU
Parameters:
parent - Parent of this hardware.
Throws:
SIMException

initPeripherals

protected void initPeripherals()
                        throws SIMException
No peripherals are build in on 6502 this function is present only for compatibility

Throws:
SIMException

initMemories

protected void initMemories()
                     throws SIMException
Throws:
SIMException

push16

protected void push16(int value)
               throws SIMException
Push a word (16 bit) on the stack

Throws:
SIMException

pop16

protected int pop16()
             throws SIMException
Pop a word (16 bit) from the stack

Throws:
SIMException

push

protected void push(int value)
             throws SIMException
Push a 8 bit value on the stack.

Throws:
SIMException

pop

protected int pop()
           throws SIMException
Pop a 8 bit value from the stack.

Throws:
SIMException

pc

public void pc(int pc)
        throws SIMException
Description copied from interface: CPU
Set the program counter.

Specified by:
pc in interface CPU
Parameters:
pc - - New value for the program counter.
Throws:
SIMException

pc

public int pc()
       throws SIMException
Description copied from interface: CPU
Return the register used as program counter

Specified by:
pc in interface CPU
Returns:
- Program counter.
Throws:
SIMException

fireISR

public int fireISR(Interrupt irq)
            throws SIMException
Description copied from class: AbstractCPU
This function must be overridden from sub class that implements interrupt.

Specified by:
fireISR in interface CPU
Overrides:
fireISR in class AbstractCPU
Throws:
SIMException

isInterruptEnabled

public boolean isInterruptEnabled()
Description copied from interface: CPU
Return the status of the interrupt enable

Specified by:
isInterruptEnabled in interface CPU

dumpStatistics

public void dumpStatistics(java.io.PrintStream ps)
Description copied from class: AbstractCPU
Dump cpu execution statistics in the specified stream.

Overrides:
dumpStatistics in class AbstractCPU
Parameters:
ps - - The print stream.

jmce - 1_02