miSim

misim
Class Instruction

java.lang.Object
  |
  +--misim.Instruction
All Implemented Interfaces:
java.lang.Cloneable

public abstract class Instruction
extends java.lang.Object
implements java.lang.Cloneable

The Instruction class is the basis for all emulated instructions. Each emulated instruction must extend this class, and implement the doIt() method to perform the task for that instruction. The extending class must also set the bitmask, bitvalue, mnemonic, type and asmType member variables in its constructor.


Field Summary
 int address
           
 int asmType
           
 java.lang.String assembly
           
 int bitmask
           
 int bitMask
           
 int bits
           
 int bitvalue
           
static int carryBit
           
static int decimalBit
           
 boolean destW
           
 int literal
           
protected  MachineState machineState
           
static int MAX_PARAMS
           
 java.lang.String mnemonic
           
 int opcode
           
static int OPERAND_TYPE_ADDRESS
           
static int OPERAND_TYPE_BITS
           
static int OPERAND_TYPE_ERROR
           
static int OPERAND_TYPE_FLAG
           
static int OPERAND_TYPE_LITERAL
           
static int OPERAND_TYPE_NONE
           
static int OPERAND_TYPE_SOURCE_DEST
           
static int OPERAND_TYPE_TRIS
           
 boolean optLoop
           
static int pageBit
           
static int readBit
           
 int reg
           
 boolean regDest
           
 boolean stepOver
           
 int type
           
static int zeroBit
           
 
Constructor Summary
Instruction()
           
 
Method Summary
 java.lang.Object clone()
           
 void complete()
          This is called after each instruction completes, and handles any special behaviour of registers that may have been altered by the instruction
abstract  void doIt()
          This method must be implemented to perform the function of the instruction being emulated.
 java.lang.String getMnemonic()
          Return this instruction's mnemonic.
 int getOpcode()
          Return this instruction's opcode
 boolean isOneOf(java.lang.String instructionList)
          Test to see if this instruction is one of a list of instructions The list is of the standard Pic Mnemonics, and does not change if the mnemonic style changes.
 int optionalParams()
          Return the number of optional parameters for this instruction
 int requiredParams()
          Return the number of required parameters to this instruction
 void setMachineState(MachineState machineState)
           
 void setValue(int value)
          This method sets the data value of this instruction - that is, it decodes the binary form of the instruction into its possible components
 java.lang.String toString()
          The returns the disassembled version of the instruction
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

machineState

protected MachineState machineState

pageBit

public static final int pageBit

zeroBit

public static final int zeroBit

carryBit

public static final int carryBit

decimalBit

public static final int decimalBit

readBit

public static final int readBit

OPERAND_TYPE_ERROR

public static final int OPERAND_TYPE_ERROR

OPERAND_TYPE_NONE

public static final int OPERAND_TYPE_NONE

OPERAND_TYPE_FLAG

public static final int OPERAND_TYPE_FLAG

OPERAND_TYPE_SOURCE_DEST

public static final int OPERAND_TYPE_SOURCE_DEST

OPERAND_TYPE_BITS

public static final int OPERAND_TYPE_BITS

OPERAND_TYPE_ADDRESS

public static final int OPERAND_TYPE_ADDRESS

OPERAND_TYPE_LITERAL

public static final int OPERAND_TYPE_LITERAL

OPERAND_TYPE_TRIS

public static final int OPERAND_TYPE_TRIS

MAX_PARAMS

public static final int MAX_PARAMS

type

public int type

asmType

public int asmType

mnemonic

public java.lang.String mnemonic

assembly

public java.lang.String assembly

bitmask

public int bitmask

bitvalue

public int bitvalue

reg

public int reg

literal

public int literal

bits

public int bits

bitMask

public int bitMask

address

public int address

opcode

public int opcode

destW

public boolean destW

regDest

public boolean regDest

optLoop

public boolean optLoop

stepOver

public boolean stepOver
Constructor Detail

Instruction

public Instruction()
Method Detail

setMachineState

public void setMachineState(MachineState machineState)

doIt

public abstract void doIt()
This method must be implemented to perform the function of the instruction being emulated.

setValue

public void setValue(int value)
This method sets the data value of this instruction - that is, it decodes the binary form of the instruction into its possible components
Parameters:
value - The binary value of the instruction

toString

public java.lang.String toString()
The returns the disassembled version of the instruction
Overrides:
toString in class java.lang.Object
Returns:
A String representation of this instruction

complete

public final void complete()
This is called after each instruction completes, and handles any special behaviour of registers that may have been altered by the instruction

isOneOf

public boolean isOneOf(java.lang.String instructionList)
Test to see if this instruction is one of a list of instructions The list is of the standard Pic Mnemonics, and does not change if the mnemonic style changes. Each element in the list must be separated by a space ' ', to avoid partial matches. The list is not case sensitive. (e.g. myInstruction.isOneOf( "GOTO RETURN RETLW" );
Parameters:
instructionList - String list of instructions to test against
Returns:
true if this instruction is in the list

getMnemonic

public java.lang.String getMnemonic()
Return this instruction's mnemonic. Note that the returned value may not be the same as the 'standard' Mnemonic used internally and defined by Arizona Microchip, as we may be supporting an alternative Assembly style
Returns:
The mnemonic for this instruction

getOpcode

public int getOpcode()
Return this instruction's opcode
Returns:
The opcode

requiredParams

public int requiredParams()
Return the number of required parameters to this instruction
Returns:
The number of non-optional parameters

optionalParams

public int optionalParams()
Return the number of optional parameters for this instruction
Returns:
the number of optional parameters

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object

miSim