jmce - 1_02

jmce.sim.cpu
Class AbstractCPU

java.lang.Object
  extended by jmce.sim.AbstractHardware
      extended by jmce.sim.cpu.AbstractCPU
All Implemented Interfaces:
java.lang.Runnable, BreakPointListener, CPU, Hardware, InterruptManager
Direct Known Subclasses:
I8080, I8086, M6502, M68HC05, MCS51

public abstract class AbstractCPU
extends AbstractHardware
implements CPU, BreakPointListener

Abstract implementation of CPU.

Introduction

This class implements all method not hardware depending for the interface CPU , add some helper method for access to the data from subclass. Also implements all method usable from one external class to implement debug,reset set/get register and so on.

For performance reason log are conditioned to static flag and can be changed only recompiling this class.

At default the cpu will not start in real time mode but will use all the resource available from the Java Virtual Machine. This can be a little problem for play game, in this case use the method setRealTime(boolean) to enable the real time emulation.

Version:
1.01
Author:
Mario Viara
See Also:
setRealTime(boolean)

Field Summary
protected  FastArray<Interrupt> interrupts
          Array with all installed interrupt
protected  Memory io
          I/O memory
protected  Memory memory
          Main memory.
static long NS100MS
          Number of ns in 100 ms
static long NS1MS
          Number of ns in 1 ms
 
Fields inherited from interface jmce.sim.CPU
BIG_ENDIAN, IO_MEMORY, LITTLE_ENDIAN, MAIN_MEMORY
 
Constructor Summary
AbstractCPU(java.lang.String name)
           
 
Method Summary
 void abort(java.lang.String s)
          Abort the cpu execution.
 void addCycleListener(CycleListener l)
          Register listener so that it will receive cycle event.
 Decoder addDecoder(Decoder d)
          Add a new decoder.
 void addExceptionListener(ExceptionListener l)
          Add a new listener called when one new exception is detected
 BreakPoint addExecBreakPoint(int m, int a)
          Add a new exec break point.
 void addInterrupt(Interrupt irq)
          Add a new interrupt to this CPU
 void addIOReadListener(int a, MemoryReadListener l)
          Add a MemoryReadListener to the I/O memory.
 void addIOReadListener(MemoryReadListener l)
          Add a global MemoryReadListener to the I/O memory,
 void addIOWriteListener(int a, MemoryWriteListener l)
          Add a Memory write listener to the I/O memory.
 void addIOWriteListener(MemoryWriteListener l)
          Add a global MemoryWriteListener to the I/O memory,
 void addLoader(Loader loader)
           
 void addMemoryWriteListener(MemoryWriteListener l)
          Add a memory write listener to the system memory.
 int addOffset(int word, int offset)
          Add a 8 bit signed offset to a 16 bit word
 BreakPoint addReadBreakPoint(int m, int a)
          Add a new read break point.
 Register addRegister(Register r)
          Add a Register
 void addResetListener(ResetListener l)
          Add a new reset listener.
 void addTimerCycle(Timer t)
          Add a new timer as clock the machine cycle.
 void addTimerMs(Timer t)
          Add a new timer as clock sec/1000 but using the machine cycle.
 void addTraceListener(TraceListener t)
          Add a new trace listener.
 BreakPoint addWriteBreakPoint(int m, int a)
          Add a new write break point.
static boolean bit0(int value)
          Check the bit 0 of a value.
static boolean bit7(int value)
          Check the 7 bit of a value.
 void breakPointEvent(BreakPoint bp, java.lang.String msg)
          Break point event.
protected  CpuRuntime createRuntime()
          CPU implementing istruction with RuntimeOpcode must in this method create the appropriate runtime class.
 java.lang.String decodeAt(int pc)
          Decode the istruction at the specified address.
 void destroy()
          Destroy the device.
 void dumpStatistics(java.io.PrintStream ps)
          Dump cpu execution statistics in the specified stream.
 void dumpStatistics(java.lang.String file)
          Dump cpu execution statistics in the specified file.
protected  void dumpTitle(java.io.PrintStream ps, java.lang.String s1, java.lang.String s2)
          Dump the title of new section.
protected  void dumpValue(java.io.PrintStream ps, long n, java.lang.String s)
          Dump a vale on the specificed stream.
protected  void dumpValue(java.io.PrintStream ps, java.lang.String s1, java.lang.String s2)
          Dump a value on the speficied stream.
 int fetch(int a)
          Fecth a byte from the memory for exec istructions.
 int fireISR(Interrupt i)
          This function must be overridden from sub class that implements interrupt.
 int fireNMI(Interrupt i)
          This function must be overridden from sub class that implements NMI interrupt.
static java.lang.String formatFrequence(long hz)
           
 BreakPoint getBreakPointAt(int i)
          Return the specified break point.
 int getBreakPointCount()
          Return the number of installed break point.
 int getByte(int a)
          Return a byte of memory from the main memory.
 CallListener getCallListener(int a)
           
 long getClock()
          Return che CPU clock in Hz.
 int getClockPerCycle()
          Get the number of clock used for cycle
 long getCycle()
          Return the current clock cycle of the CPU.
 long getCycleMillis()
          Return the number of cycle per ms.
 Decoder getDecoderAt(int i)
          Get a decoder.
 int getDecoderCount()
          Get the number of installed decoder
 int getEndian()
          Get the cpu 'endianess'
 ExceptionListener getExceptionListenerAt(int i)
          Return the specified exception listener.
 int getExceptionListenerCount()
          Return the number of exception listener installed.
 jmce.sim.cpu.SortedVector<Opcode> getExecStatistics()
           
 int getInterruptCount()
           
 int getInterruptCounter(int n)
           
 java.lang.String getInterruptName(int n)
           
 int getIOByte(int a)
          Get a byte from the I/O memory.
 int getLenghtAt(int pc)
          Return the lenght of one instruction
 Memory getMemory()
          Return the main memory
 Memory getMemoryAt(int i)
          Return the memory at the specified position
 int getMemoryCount()
          Debug interface
 Memory getMemoryForName(java.lang.String name)
          Return the memory for name.
 AbstractOpcode getOpcodeAt(int pc)
           
 MultiOpcode getOpcodes()
          Return the CPU opocode table.
 boolean getRealTime()
          Return the real time emulation mode.
 Register getRegisterAt(int i)
          Return the specified Register
 int getRegisterCount()
          Get the number of register present in the CPU
 Register getRegisterForName(java.lang.String name)
          Search one register for name
 int getResetAddress()
          Return the value of PC at reset.
 double getUsage()
          Get CPU usage return the CPU usage of the simulator thread, high value (more than 90.00) means the current java machine is too slow to execute the simulator.
 java.lang.String getUsageDesc()
          Get CPU usage in string format.
 int getWordBig(int a)
           
 int getWordLittle(int a)
           
protected  void halt()
          Special istruction general pourpse HALT If interrupt are disable one exception is thrown otherwise call the idle() method till one interrupt will be fired.
 int idle()
          Idle cycle.
 void init(Hardware parent)
          Initialize the hardware.
 boolean isBigEndian()
          Return true if the byte order of the cpu is Big Endian
 boolean isLittleEndian()
          Return true if the byte order of the cpu is Little Endian
 boolean isRunning()
          Return true is the CPU is running.
 void load(Memory m, java.lang.String name, int base, LoadInfo info)
          Load a program in the specified memory.
 void load(java.lang.String name, int base, LoadInfo info)
          Load a program in the default memory.
 void notifyInterrupt(Interrupt irq)
          Notity the cpu the specified isr can have changed state.
 void removeBreakPoint(BreakPoint b)
          Remove the specified breakpoint
 void removeBreakPoint(int i)
          Remove the specified break point.
 void removeExceptionListener(ExceptionListener l)
          Remove one exception listener.
 void removeTraceListener(TraceListener t)
          Remove the specified trace listener
 void reset()
          Reset the CPU and call all installed ResetListener.
protected  void resetRegisters()
          Reset all register to default value.
 void run()
           
 void run0()
          Run the cpu till one exception occour.
 void setByte(int a, int value)
          Set a byte on the Main memory.
 void setCallListener(int a, CallListener l)
           
 void setClock(long clock)
          Set the CPU clock in Hz.
 void setClockPerCycle(int n)
          Set the number of clock used for cycle during instruction execution.
 void setEndian(int n)
          Set cpu 'endianess'
 void setIO(Memory io)
           
 void setIOByte(int a, int v)
          Set a byte in the I/O memory.
protected  void setMemory(Memory m)
           
 void setOpcode(AbstractOpcode o)
           
 void setRealTime(boolean mode)
          Set the real time emulation mode.
 void setResetAddress(int value)
          Set the value of the PC at reset.
 void setStatusLine(char c)
          Set a char on the status line The status line is the last line of the display and is reserved for JMCE message the first part of the line will display the type of cpu, the configured clock, the current clock and the VM usage.
 void setTill(int till)
          Set the break address.
 void start()
          Start the CPU
 int step()
          Exec one step and return the number of cycle used.
 int step0()
          Exec one instruction.
 int stepNoBreak()
           
 void stop()
          Stop the CPU
 
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.CPU
getWord, isInterruptEnabled, pc, pc, setWord
 
Methods inherited from interface jmce.sim.Hardware
addHardware, getHardware, getHardware, getHardware, getHardware, getHardwareCount, getHardwareInstances, getHardwareTree, getName, getParent, initSwing, removeHardware, removeHardware, setHardware, setHardware, setName
 

Field Detail

NS1MS

public static final long NS1MS
Number of ns in 1 ms

See Also:
Constant Field Values

NS100MS

public static final long NS100MS
Number of ns in 100 ms

See Also:
Constant Field Values

interrupts

protected FastArray<Interrupt> interrupts
Array with all installed interrupt


memory

protected Memory memory
Main memory.


io

protected Memory io
I/O memory

Constructor Detail

AbstractCPU

public AbstractCPU(java.lang.String name)
Method Detail

addOffset

public final int addOffset(int word,
                           int offset)
Add a 8 bit signed offset to a 16 bit word

Parameters:
word - - Source word
offset - - 8 bit signed offset
Returns:
The word plus/minus the offset

getCycle

public long getCycle()
Description copied from interface: CPU
Return the current clock cycle of the CPU. This value will be set to 0 after any reset.

Specified by:
getCycle in interface CPU

getClock

public long getClock()
Description copied from interface: CPU
Return che CPU clock in Hz.

Specified by:
getClock in interface CPU

setClock

public void setClock(long clock)
Description copied from interface: CPU
Set the CPU clock in Hz.

Specified by:
setClock in interface CPU

setClockPerCycle

public void setClockPerCycle(int n)
Description copied from interface: CPU
Set the number of clock used for cycle during instruction execution.

Specified by:
setClockPerCycle in interface CPU

getClockPerCycle

public int getClockPerCycle()
Description copied from interface: CPU
Get the number of clock used for cycle

Specified by:
getClockPerCycle in interface CPU

getDecoderCount

public int getDecoderCount()
Description copied from interface: CPU
Get the number of installed decoder

Specified by:
getDecoderCount in interface CPU
Returns:
the number of installed decoders.

addDecoder

public Decoder addDecoder(Decoder d)
Description copied from interface: CPU
Add a new decoder.

Specified by:
addDecoder in interface CPU
Parameters:
d - - Decoder
See Also:
Decoder

getDecoderAt

public Decoder getDecoderAt(int i)
Description copied from interface: CPU
Get a decoder.

Specified by:
getDecoderAt in interface CPU
Returns:
the specified decoder.

getRegisterCount

public int getRegisterCount()
Description copied from interface: CPU
Get the number of register present in the CPU

Specified by:
getRegisterCount in interface CPU

getRegisterForName

public Register getRegisterForName(java.lang.String name)
Description copied from interface: CPU
Search one register for name

Specified by:
getRegisterForName in interface CPU

addRegister

public Register addRegister(Register r)
Description copied from interface: CPU
Add a Register

Specified by:
addRegister in interface CPU

getRegisterAt

public Register getRegisterAt(int i)
Description copied from interface: CPU
Return the specified Register

Specified by:
getRegisterAt in interface CPU

setEndian

public void setEndian(int n)
Description copied from interface: CPU
Set cpu 'endianess'

Specified by:
setEndian in interface CPU
See Also:
CPU.LITTLE_ENDIAN, CPU.BIG_ENDIAN

getEndian

public final int getEndian()
Description copied from interface: CPU
Get the cpu 'endianess'

Specified by:
getEndian in interface CPU
See Also:
CPU.LITTLE_ENDIAN, CPU.BIG_ENDIAN

isLittleEndian

public final boolean isLittleEndian()
Description copied from interface: CPU
Return true if the byte order of the cpu is Little Endian

Specified by:
isLittleEndian in interface CPU

isBigEndian

public final boolean isBigEndian()
Description copied from interface: CPU
Return true if the byte order of the cpu is Big Endian

Specified by:
isBigEndian in interface CPU

addMemoryWriteListener

public void addMemoryWriteListener(MemoryWriteListener l)
Description copied from interface: CPU
Add a memory write listener to the system memory.

Specified by:
addMemoryWriteListener in interface CPU

getMemory

public final Memory getMemory()
Description copied from interface: CPU
Return the main memory

Specified by:
getMemory in interface CPU

setMemory

protected final void setMemory(Memory m)

addCycleListener

public void addCycleListener(CycleListener l)
Description copied from interface: CPU
Register listener so that it will receive cycle event.

This event is fired after the execution of every instructions. Please use only when necessary because can have large impact on simulator performance.

Specified by:
addCycleListener in interface CPU
Parameters:
l - - The listener to register.

setOpcode

public void setOpcode(AbstractOpcode o)

getOpcodeAt

public final AbstractOpcode getOpcodeAt(int pc)
                                 throws SIMException
Throws:
SIMException

getLenghtAt

public final int getLenghtAt(int pc)
                      throws SIMException
Return the lenght of one instruction

Specified by:
getLenghtAt in interface CPU
Throws:
SIMException

decodeAt

public java.lang.String decodeAt(int pc)
                          throws SIMException
Description copied from interface: CPU
Decode the istruction at the specified address.

Specified by:
decodeAt in interface CPU
Returns:
The decoded istruction of null if undefined.
Throws:
SIMException

setByte

public final void setByte(int a,
                          int value)
                   throws SIMException
Description copied from interface: CPU
Set a byte on the Main memory. Set one byte on the main memory.

Specified by:
setByte in interface CPU
Parameters:
a - - Address
value - - Value.
Throws:
SIMException

fetch

public final int fetch(int a)
                throws SIMException
Description copied from interface: CPU
Fecth a byte from the memory for exec istructions. For not segmented CPU do the same of getByte.

Specified by:
fetch in interface CPU
Throws:
SIMException

getByte

public final int getByte(int a)
                  throws SIMException
Description copied from interface: CPU
Return a byte of memory from the main memory.

Specified by:
getByte in interface CPU
Parameters:
a - - Address
Returns:
byte read from the memory.
Throws:
SIMException

getWordLittle

public final int getWordLittle(int a)
                        throws SIMException
Throws:
SIMException

getWordBig

public final int getWordBig(int a)
                     throws SIMException
Throws:
SIMException

resetRegisters

protected void resetRegisters()
                       throws SIMException
Reset all register to default value. Sub class can override this method to reset additional non conventional register. This method is called during reset().

Throws:
SIMException

reset

public void reset()
           throws SIMException
Reset the CPU and call all installed ResetListener.

Reset is performed in this order :

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

setTill

public void setTill(int till)
Description copied from interface: CPU
Set the break address.

Specified by:
setTill in interface CPU

getCycleMillis

public long getCycleMillis()
Description copied from interface: CPU
Return the number of cycle per ms.

Specified by:
getCycleMillis in interface CPU

addTimerMs

public void addTimerMs(Timer t)
Description copied from interface: CPU
Add a new timer as clock sec/1000 but using the machine cycle.

After every sec/1000 calculated using the clock machine the timer is decremeted and when reach 0 the timer is fired.

Specified by:
addTimerMs in interface CPU
Parameters:
t - - the timer.
See Also:
Timer

addTimerCycle

public void addTimerCycle(Timer t)
Description copied from interface: CPU
Add a new timer as clock the machine cycle.

After every clock machine the timer is decremented and when reach 0 the timer is fired.

Specified by:
addTimerCycle in interface CPU
Parameters:
t - - the timer.
See Also:
Timer

step

public int step()
         throws SIMException
Description copied from interface: CPU
Exec one step and return the number of cycle used.

Specified by:
step in interface CPU
Throws:
SIMException

stepNoBreak

public final int stepNoBreak()
                      throws SIMException
Throws:
SIMException

step0

public final int step0()
                throws SIMException
Exec one instruction.

Throws:
SIMException

run0

public final void run0()
                throws SIMException
Run the cpu till one exception occour.

Throws:
SIMException

run

public final void run()
Specified by:
run in interface java.lang.Runnable

isRunning

public boolean isRunning()
Description copied from interface: CPU
Return true is the CPU is running.

Specified by:
isRunning in interface CPU
Returns:
true if the CPU is running

start

public void start()
Description copied from interface: CPU
Start the CPU

Specified by:
start in interface CPU
See Also:
CPU.isRunning()

stop

public void stop()
Description copied from interface: CPU
Stop the CPU

Specified by:
stop in interface CPU
See Also:
CPU.isRunning()

dumpValue

protected void dumpValue(java.io.PrintStream ps,
                         java.lang.String s1,
                         java.lang.String s2)
Dump a value on the speficied stream.


dumpTitle

protected void dumpTitle(java.io.PrintStream ps,
                         java.lang.String s1,
                         java.lang.String s2)
Dump the title of new section.


dumpValue

protected void dumpValue(java.io.PrintStream ps,
                         long n,
                         java.lang.String s)
Dump a vale on the specificed stream.


dumpStatistics

public void dumpStatistics(java.lang.String file)
                    throws SIMException
Dump cpu execution statistics in the specified file.

Specified by:
dumpStatistics in interface CPU
Parameters:
file - - File name where dump cpu statistics.
Throws:
SIMException

dumpStatistics

public void dumpStatistics(java.io.PrintStream ps)
Dump cpu execution statistics in the specified stream.

Parameters:
ps - - The print stream.
Since:
1.01

destroy

public void destroy()
             throws SIMException
Description copied from interface: Hardware
Destroy the device. This method can be called only one time

Specified by:
destroy in interface Hardware
Overrides:
destroy in class AbstractHardware
Throws:
SIMException

getExceptionListenerAt

public ExceptionListener getExceptionListenerAt(int i)
Description copied from interface: CPU
Return the specified exception listener.

Specified by:
getExceptionListenerAt in interface CPU

addExceptionListener

public void addExceptionListener(ExceptionListener l)
Description copied from interface: CPU
Add a new listener called when one new exception is detected

Specified by:
addExceptionListener in interface CPU

getExceptionListenerCount

public int getExceptionListenerCount()
Description copied from interface: CPU
Return the number of exception listener installed.

Specified by:
getExceptionListenerCount in interface CPU

removeExceptionListener

public void removeExceptionListener(ExceptionListener l)
Description copied from interface: CPU
Remove one exception listener.

Specified by:
removeExceptionListener in interface CPU

idle

public final int idle()
               throws SIMException
Idle cycle.

When called from the cpu emulation thread advance counter and check for new interrupt available if a new interrupt is available throw SIMInterrupted

Specified by:
idle in interface CPU
Returns:
The number of ms elapsed.
Throws:
SIMInterrupted - When a new interrupt is available.
SIMException

getMemoryForName

public Memory getMemoryForName(java.lang.String name)
Description copied from interface: CPU
Return the memory for name.

If no memory with the specified name is present return null.

Specified by:
getMemoryForName in interface CPU
Parameters:
name - - Name of the memory to be searched.
Returns:
The memory or null

addLoader

public void addLoader(Loader loader)

load

public void load(java.lang.String name,
                 int base,
                 LoadInfo info)
          throws SIMException
Description copied from interface: CPU
Load a program in the default memory.

Specified by:
load in interface CPU
Parameters:
name - - Name of the file.
base - - Base address.
info - - Information filled when return.
Throws:
SIMException

load

public void load(Memory m,
                 java.lang.String name,
                 int base,
                 LoadInfo info)
          throws SIMException
Description copied from interface: CPU
Load a program in the specified memory.

Specified by:
load in interface CPU
Parameters:
m - - Memory where to load.
name - - Name of the file.
base - - Base address.
info - - Information filled when return.
Throws:
SIMException

fireISR

public int fireISR(Interrupt i)
            throws SIMException
This function must be overridden from sub class that implements interrupt.

Specified by:
fireISR in interface CPU
Throws:
SIMException

fireNMI

public int fireNMI(Interrupt i)
            throws SIMException
This function must be overridden from sub class that implements NMI interrupt.

Specified by:
fireNMI in interface CPU
Throws:
SIMException

formatFrequence

public static final java.lang.String formatFrequence(long hz)

getUsageDesc

public java.lang.String getUsageDesc()
Description copied from interface: CPU
Get CPU usage in string format.

This method is like getUsage() but return one string with nome information.

Specified by:
getUsageDesc in interface CPU
Returns:
One string with current cpu usage.

getUsage

public double getUsage()
Description copied from interface: CPU
Get CPU usage return the CPU usage of the simulator thread, high value (more than 90.00) means the current java machine is too slow to execute the simulator.

Specified by:
getUsage in interface CPU
Returns:
cpu usage %

getOpcodes

public final MultiOpcode getOpcodes()
Return the CPU opocode table.

Since:
1.02

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 AbstractHardware
Parameters:
parent - Parent of this hardware.
Throws:
SIMException

addResetListener

public void addResetListener(ResetListener l)
Description copied from interface: CPU
Add a new reset listener. This type of listener will be called after inizialization and when the lister is called the machine is ready to run.

Specified by:
addResetListener in interface CPU
Parameters:
l - - Listener

getMemoryCount

public int getMemoryCount()
Debug interface

Specified by:
getMemoryCount in interface CPU

getMemoryAt

public Memory getMemoryAt(int i)
Description copied from interface: CPU
Return the memory at the specified position

Specified by:
getMemoryAt in interface CPU

getBreakPointCount

public int getBreakPointCount()
Description copied from interface: CPU
Return the number of installed break point.

Specified by:
getBreakPointCount in interface CPU

getBreakPointAt

public BreakPoint getBreakPointAt(int i)
Description copied from interface: CPU
Return the specified break point.

Specified by:
getBreakPointAt in interface CPU

removeBreakPoint

public void removeBreakPoint(BreakPoint b)
Description copied from interface: CPU
Remove the specified breakpoint

Specified by:
removeBreakPoint in interface CPU

removeBreakPoint

public void removeBreakPoint(int i)
Description copied from interface: CPU
Remove the specified break point.

Specified by:
removeBreakPoint in interface CPU

addExecBreakPoint

public BreakPoint addExecBreakPoint(int m,
                                    int a)
Description copied from interface: CPU
Add a new exec break point.

Triggered when the specified location is executed from the cpu.

Specified by:
addExecBreakPoint in interface CPU

addReadBreakPoint

public BreakPoint addReadBreakPoint(int m,
                                    int a)
Description copied from interface: CPU
Add a new read break point.

Trigger when the specified location is readed from the cpu.

Specified by:
addReadBreakPoint in interface CPU

addWriteBreakPoint

public BreakPoint addWriteBreakPoint(int m,
                                     int a)
Description copied from interface: CPU
Add a new write break point.

Triggered when the specified location si written from the cpu.

Specified by:
addWriteBreakPoint in interface CPU

breakPointEvent

public void breakPointEvent(BreakPoint bp,
                            java.lang.String msg)
Description copied from interface: BreakPointListener
Break point event. This listener will be called from the BreakPoint class when a new break point is detect.

Specified by:
breakPointEvent in interface BreakPointListener
Parameters:
bp - - Source BreakPoint
msg - - Short description of the breakpoint.

addTraceListener

public void addTraceListener(TraceListener t)
Description copied from interface: CPU
Add a new trace listener.

When a trace listener is installed it will be called with one or more string with the cpu trace in human reeadable form.

Specified by:
addTraceListener in interface CPU

removeTraceListener

public void removeTraceListener(TraceListener t)
Description copied from interface: CPU
Remove the specified trace listener

Specified by:
removeTraceListener in interface CPU

setIO

public void setIO(Memory io)

addIOReadListener

public void addIOReadListener(MemoryReadListener l)
Description copied from interface: CPU
Add a global MemoryReadListener to the I/O memory,

Specified by:
addIOReadListener in interface CPU

addIOReadListener

public void addIOReadListener(int a,
                              MemoryReadListener l)
Description copied from interface: CPU
Add a MemoryReadListener to the I/O memory.

Specified by:
addIOReadListener in interface CPU

addIOWriteListener

public void addIOWriteListener(int a,
                               MemoryWriteListener l)
Description copied from interface: CPU
Add a Memory write listener to the I/O memory.

Specified by:
addIOWriteListener in interface CPU

addIOWriteListener

public void addIOWriteListener(MemoryWriteListener l)
Description copied from interface: CPU
Add a global MemoryWriteListener to the I/O memory,

Specified by:
addIOWriteListener in interface CPU

setIOByte

public final void setIOByte(int a,
                            int v)
                     throws SIMException
Description copied from interface: CPU
Set a byte in the I/O memory.

Specified by:
setIOByte in interface CPU
Throws:
SIMException

getIOByte

public final int getIOByte(int a)
                    throws SIMException
Description copied from interface: CPU
Get a byte from the I/O memory.

Specified by:
getIOByte in interface CPU
Throws:
SIMException

setResetAddress

public void setResetAddress(int value)
Description copied from interface: CPU
Set the value of the PC at reset.

Specified by:
setResetAddress in interface CPU

getResetAddress

public int getResetAddress()
Description copied from interface: CPU
Return the value of PC at reset.

Specified by:
getResetAddress in interface CPU

getInterruptCount

public int getInterruptCount()

getInterruptName

public java.lang.String getInterruptName(int n)

getInterruptCounter

public int getInterruptCounter(int n)

setRealTime

public void setRealTime(boolean mode)
Description copied from interface: CPU
Set the real time emulation mode.

If the realtime mode is selected the cpu will run at the current clock. original speed.

Specified by:
setRealTime in interface CPU
Parameters:
mode - - Real time emulation mode.
See Also:
CPU.setClock(long)

getRealTime

public boolean getRealTime()
Description copied from interface: CPU
Return the real time emulation mode.

Specified by:
getRealTime in interface CPU
See Also:
CPU.setRealTime(boolean)

abort

public void abort(java.lang.String s)
Description copied from interface: CPU
Abort the cpu execution.

This method can be called from any thread.

Specified by:
abort in interface CPU

getExecStatistics

public jmce.sim.cpu.SortedVector<Opcode> getExecStatistics()

halt

protected void halt()
             throws SIMException
Special istruction general pourpse HALT

If interrupt are disable one exception is thrown otherwise call the idle() method till one interrupt will be fired.

This instructions is the only istruction multi cpu !!

Throws:
SIMException

createRuntime

protected CpuRuntime createRuntime()
                            throws SIMException
CPU implementing istruction with RuntimeOpcode must in this method create the appropriate runtime class.

Throws:
SIMException

setCallListener

public void setCallListener(int a,
                            CallListener l)

getCallListener

public CallListener getCallListener(int a)

setStatusLine

public void setStatusLine(char c)
Description copied from interface: CPU
Set a char on the status line

The status line is the last line of the display and is reserved for JMCE message the first part of the line will display the type of cpu, the configured clock, the current clock and the VM usage. The last char of the line display a character with the last I/O operation :

The status line will display the last status till do not change.

Specified by:
setStatusLine in interface CPU

addInterrupt

public final void addInterrupt(Interrupt irq)
Description copied from interface: CPU
Add a new interrupt to this CPU

Specified by:
addInterrupt in interface CPU
Specified by:
addInterrupt in interface InterruptManager

notifyInterrupt

public final void notifyInterrupt(Interrupt irq)
Description copied from interface: CPU
Notity the cpu the specified isr can have changed state.

Specified by:
notifyInterrupt in interface CPU
Specified by:
notifyInterrupt in interface InterruptManager

bit7

public static final boolean bit7(int value)
Check the 7 bit of a value.

Returns:
true if the bit is set.
Since:
1.02

bit0

public static final boolean bit0(int value)
Check the bit 0 of a value.

Returns:
true if the bit is set.
Since:
1.02

jmce - 1_02