jmce - 1_02

jmce.sim.cpu
Class AbstractOpcode

java.lang.Object
  extended by jmce.sim.cpu.AbstractOpcode
All Implemented Interfaces:
Opcode
Direct Known Subclasses:
InvalidOpcode, MultiOpcode, PrefixOpcode, RuntimeOpcode

public abstract class AbstractOpcode
extends java.lang.Object
implements Opcode

Abstract implementation of Opcode interface.

For performance reason this class contain boolean flag to identify subclass it is not very much elegant but use or instanceof is to slow for simulator performance. For example the subclass MultiOpcode in the costructor set the multiOpcode flag and at runtime to identify the class it is enough check the flag and do not require use of instanceof.

Version:
1.02
Author:
Mario Viara

Field Summary
protected  java.lang.String desc
           
protected  int length
           
protected  boolean multiOpcode
          Flag to identify subclass MultiOpcode
protected  int opcode
           
protected  AbstractOpcode[] opcodes
          Used for MultiOpcode implementation
protected  boolean prefixOpcode
          Flag to identify subclass PrefixOpcode
protected  boolean runtimeOpcode
          Flag to identify subclass RuntimeOpcode
protected  int times
           
 
Constructor Summary
AbstractOpcode(int opcode, int length, int times, java.lang.String desc)
           
 
Method Summary
 void clearCounter()
          Clear execution counter
 long getCounter()
          return execution counter
 java.lang.String getDescription()
           
 int getLength()
           
 int getMaxLength()
          Return the maximum lenght instructions.
 int getOpcode()
           
 AbstractOpcode getOpcode(int code)
          Return the opcode with the specified code
 int getOpcodeCount()
          Get the opcode count
 int getTimes()
           
 void incCounter()
          increment exec counter
 boolean isMultiOpcode()
           
 void setDescription(java.lang.String s)
           
 void setOpcode(AbstractOpcode o)
          Set a new opcode
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jmce.sim.Opcode
exec
 

Field Detail

opcode

protected int opcode

length

protected int length

times

protected int times

desc

protected java.lang.String desc

opcodes

protected AbstractOpcode[] opcodes
Used for MultiOpcode implementation


multiOpcode

protected boolean multiOpcode
Flag to identify subclass MultiOpcode


runtimeOpcode

protected boolean runtimeOpcode
Flag to identify subclass RuntimeOpcode


prefixOpcode

protected boolean prefixOpcode
Flag to identify subclass PrefixOpcode

Constructor Detail

AbstractOpcode

public AbstractOpcode(int opcode,
                      int length,
                      int times,
                      java.lang.String desc)
Method Detail

getOpcode

public final int getOpcode()
Specified by:
getOpcode in interface Opcode

getLength

public final int getLength()
Specified by:
getLength in interface Opcode

getTimes

public final int getTimes()
Specified by:
getTimes in interface Opcode

setDescription

public void setDescription(java.lang.String s)
Specified by:
setDescription in interface Opcode

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in interface Opcode

clearCounter

public void clearCounter()
Description copied from interface: Opcode
Clear execution counter

Specified by:
clearCounter in interface Opcode

getCounter

public long getCounter()
Description copied from interface: Opcode
return execution counter

Specified by:
getCounter in interface Opcode

incCounter

public final void incCounter()
Description copied from interface: Opcode
increment exec counter

Specified by:
incCounter in interface Opcode

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isMultiOpcode

public final boolean isMultiOpcode()

getOpcode

public final AbstractOpcode getOpcode(int code)
Return the opcode with the specified code

See Also:
MultiOpcode

setOpcode

public void setOpcode(AbstractOpcode o)
Set a new opcode

See Also:
MultiOpcode

getMaxLength

public int getMaxLength()
Return the maximum lenght instructions.

See Also:
MultiOpcode

getOpcodeCount

public int getOpcodeCount()
Get the opcode count

See Also:
MultiOpcode

jmce - 1_02