miSim

misim
Class MachineState

java.lang.Object
  |
  +--misim.MachineState
Direct Known Subclasses:
Processor

public abstract class MachineState
extends java.lang.Object

MachineState stores the information about the microcontroller being emulated - its stack, registers and EEPROM. It manages listeners for events generated by an instruction being emulated, such as PortListeners, and ClockListeners. The Processor class extends MachineState to provide functions to run an emulation - executing a sequence of instructions.


Field Summary
protected  Aliases aliases
          The Aliases object that defines any instruction aliases for this machine
static int carryBit
          The value of the carry flag bit in the status register
 int[] chipData
          The device EEPROM memory
protected  ClockListener clockListener
          The end of the chain of clock listeners, this handles interrupts for the device
protected  long clockRate
          The speed, in MHz that the processor should be run at.
 long clocks
          The current clock cycle count
static int CONFIG_CP
          Bit flag indicating that this device can be configured with Code protection Enabled(0) or Disabled(1)
static int CONFIG_DP
          Bit flag indicating that this device can be configured with Data protection Enabled(0) or Disabled(1)
static int CONFIG_OSC4
          Bit flag indicating that this device can be configured with a RC(11), HS(10), XT(01) or LP(00) Oscillator
static int CONFIG_PWRTE
          Bit flag indicating that this device can be configured with a Power-up Timer Enabled(1) or Disabled(0)
static int CONFIG_PWRTEI
          Bit flag indicating that this device can be configured with a Power-up Timer Enabled(0) or Disabled(1)
static int CONFIG_WDTE
          Bit flag indicating that this device can be configured with a Watchdog Timer Enabled(1) or Disabled(0)
 int configStart
          The start address of config/test memory - note that this is stored as the byte address
static int decimalBit
          The value of the decimal carry flag bit in the status register
protected  int deviceId
          The device ID (unique within the processor implementation of a family of devices) for this device
 int eepromStart
          The Start address of EEPROM memory - note that this is stored as the byte address
protected  InstructionSet instructionSet
          The instruction set for this machine
static int PACKAGE_DIP
          Indicates that this device is available in a DIP package - may be OR'd with other package types
static int PACKAGE_PLCC
          Indicates that this device is available in a PLCC package - may be OR'd with other package types
static int PACKAGE_QFP
          Indicates that this device is available in a QFP package - may be OR'd with other package types
static int PACKAGE_SOIC
          Indicates that this device is available in a SOIC package - may be OR'd with other package types
static int PARAM_BANK_SIZE
          Parameter ID for getParameter() - Returns the size of each memory bank (byte offset to next bank start)
static int PARAM_BANKS
          Parameter ID for getParameter() - Returns the number of memory banks
static int PARAM_BIT_CP0
          Parameter ID for getParameter() - Returns the bit mask for the Config code protection bit 0
static int PARAM_BIT_DP0
          Parameter ID for getParameter() - Returns the bit mask for the Data code protection bit 0
static int PARAM_BIT_FOSC0
          Parameter ID for getParameter() - Returns the bit mask for the Config oscillator selection bit 0
static int PARAM_BIT_FOSC1
          Parameter ID for getParameter() - Returns the bit mask for the Config oscillator selection bit 1
static int PARAM_BIT_PWRTE
          Parameter ID for getParameter() - Returns the bit mask for the Config power-up timer flag
static int PARAM_BIT_PWRTEI
          Parameter ID for getParameter() - Returns the bit mask for the Config power-up timer flag (inverted sense)
static int PARAM_BIT_WDTE
          Parameter ID for getParameter() - Returns the bit mask for the Config watchdog timer flag
static int PARAM_CONFIG_ADDR
          Parameter ID for getParameter() - Returns the address of the config data
static int PARAM_CONFIG_START
          Parameter ID for getParameter() - Returns the start address for the config/test program memory area
static int PARAM_CONFIG_WORD
          Parameter ID for getParameter() - Returns the bit flags indicating the CPU features that can be configured by the first config word
static int PARAM_DATA_SIZE
          Parameter ID for getParameter() - Returns the size of data memory (bytes)
static int PARAM_DEVICES
          Parameter ID for getParameter() - Returns the number of devices supported by this processor implementation
static int PARAM_EEPROM_SIZE
          Parameter ID for getParameter() - Returns the size of EEPROM memory (bytes)
static int PARAM_EEPROM_START
          Parameter ID for getParameter() - Returns the start address for the eeprom data memory area
static int PARAM_ID_ADDR
          Parameter ID for getParameter() - Returns the start address of the ID data (words)
static int PARAM_ID_SIZE
          Parameter ID for getParameter() - Returns the number of ID data words
static int PARAM_ID_WIDTH
          Parameter ID for getParameter() - Returns the how many bits of each ID word are valid
static int PARAM_INSTR_WIDTH
          Parameter ID for getParameter() - Returns the instruction bit width
static int PARAM_PACKAGES
          Parameter ID for getParameter() - Returns the bit flags for the package types this device is supplied in
static int PARAM_PINS
          Parameter ID for getParameter() - Returns the number of pins for this device
static int PARAM_PROG_SIZE
          Parameter ID for getParameter() - Returns the size of program memory (words)
static int PARAM_STACK_SIZE
          Parameter ID for getParameter() - Returns the stack size
 int pc
          The Program Counter
 int regOffset
          The offset into the current register bank
 Register[] regs
          The register memory array
static int RESET_AS_PROGRAMMED
          Flag to indicate a reset to the full original programmed values
static int RESET_MCLR
          Flag to indicate a reset on MCLR
static int RESET_POWER_UP
          Flag to indicate a reset on power up
static int RESET_WATCHDOG
          Flag to indicate a reset on the watchdog timer
 boolean sleep
          The Sleep flag
 int[] stack
          The call stack
 int stackPtr
          The Stack Pointer
 int trisBankOffset
          The offset of the tris register bank, used by tris instructions
 int w
          The W register
 long wdTimer
          The watchdog timer value
static int zeroBit
          The value of teh zero flag bit in the status register
 
Constructor Summary
MachineState(java.lang.String deviceName, InstructionSet instructionSet, Aliases aliases)
          MachineState constructor.
 
Method Summary
 void addClockListener(ChainedClockListener newListener)
          Add a chained clock listener to this machine.
 java.util.Vector addPortListener(PortListener portListener, java.lang.String aPortName)
          Add a port listener..
 java.util.Vector addPortListener(PortListener portListener, java.util.Vector whichPorts)
          Add a port listener..
 void addResetListener(ResetListener resetListener)
          Add a reset listener to this device, to respond to reset events
 java.lang.String addressName(int addr, int length, boolean emptyOk)
          Return the name (label) for this address.
 java.lang.String disassemble(Instruction instr)
          Return a String representation of the given instruction
abstract  void enableGlobalInterrupts()
          This is called at the end of the RETFIE instruction, and should re-enable global interrupts.
 void eraseEeprom()
          Set the EEPROM contents to zero
 Aliases getAliases()
          Return the definition for any instruction aliases defined for this processor
 java.util.Hashtable getAvailablePorts()
          Return the hashtable that maps the names of the ports that this chip supports (a String) to the port implementations (a misim.register.Port)
 long getClockRate()
          Get the clock rate, in hz for emulation.
 long getClocks()
          Get the current clock cycle count.
 int getDeviceId()
          Return the deviceID for this device.
abstract  java.lang.String getDeviceName(int deviceId)
          Return the names of the devices supported by this processor.
 InstructionSet getInstructionSet()
          Get the InstructionSet object that defines the instructions for this processor
 Instruction getNewInstruction(int opcode)
          Return an initialised instruction for the given opcode
 int getNthRegAddress(int index)
          Return the address of the Nth named register.
 java.lang.String getNthRegName(int index)
          Return the name for the Nth named register.
 int getParameter(int paramId)
          Return a given statistic for this machineState implementation.
abstract  int getParameter(int paramId, int deviceId)
          Return a given statistic for the given device for this machineState implementation.
 int getPC()
          Get the current value for the Program Counter
abstract  java.lang.String getPinName(int pinNo, int deviceId, int packageType)
          Return the name of the given pin for this device
 Port getPort(java.lang.String aPortName)
          Return a Named port
abstract  int getPortPin(java.lang.String portName, int bitNo)
          Return the pin number that the given port bit is connected to
 int getReg(int regNumber)
          Return the value of the given register or -1 if the register is not implemented.
 long getTicks(long time)
          Return the number of clock ticks for the given time interval, assuming the current CPU clock rate..
 int getW()
          Read the W register.
 boolean isNamed(int address)
          Return true if this register has a name, false otherwise.
 int namedRegisters()
          Return the number of registers that have been named.
 char regChar(int regNumber)
          Return the contents of the given register as a character.
 java.lang.String regName(int address)
          Get the name of a processor register.
 java.lang.String regString(int regNumber)
          Return the value of the register as a String.
 void removeClockListener(ChainedClockListener aListener)
          Remove a chained clock listener from this machine..
 void removePortListener(PortListener portListener)
          Remove port listener - this asks all ports to remove the given port listener.
 void removeResetListener(ResetListener resetListener)
          Remove a ResetListener from this device
 void resetMachine(int resetType)
          Reset the machineState registers according to the given reset type
abstract  void resetRegs(Register[] regs, int resetType)
          Reset all registers to their power-on values
 void setAddresses(int[] addrArray, int count)
          Initialise the address label hashtable with default labels for the given set of 'important' addresses.
 void setAddressName(int addr, java.lang.String label)
           
 void setAliases(Aliases aliases)
          Set the Aliases object that defines any aliases for this processor
 void setClockListener(ClockListener clockListener)
          Set the clock listener for this machine.
 void setClockRate(long clockRate)
          Set the clock rate, in hz for emulation.
 void setClocks(long clocks)
          Set the current clock cycle count.
 void setInstructionSet(InstructionSet instructionSet)
          Set the InstructionSet object that defines the instructions for this processor
 void setPC(int pc)
          Set a new value for the Program Counter.
 void setReg(int regNumber, int value)
          Set the value of a given register.
abstract  void setRegisters(Register[] regs, java.lang.String[] regNames, java.util.Hashtable portHash)
          Create and assign the registers that the device implements.
 void setRegName(int address, java.lang.String name)
          Set the name for a given register.
 void setW(int w)
          Set a new value for the W register
 boolean validReg(int regNumber)
          Check to see if this register is implemented
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

regs

public Register[] regs
The register memory array

stack

public int[] stack
The call stack

chipData

public int[] chipData
The device EEPROM memory

eepromStart

public int eepromStart
The Start address of EEPROM memory - note that this is stored as the byte address

configStart

public int configStart
The start address of config/test memory - note that this is stored as the byte address

w

public int w
The W register

pc

public int pc
The Program Counter

stackPtr

public int stackPtr
The Stack Pointer

regOffset

public int regOffset
The offset into the current register bank

clocks

public long clocks
The current clock cycle count

wdTimer

public long wdTimer
The watchdog timer value

sleep

public boolean sleep
The Sleep flag

clockRate

protected long clockRate
The speed, in MHz that the processor should be run at.

clockListener

protected ClockListener clockListener
The end of the chain of clock listeners, this handles interrupts for the device

instructionSet

protected InstructionSet instructionSet
The instruction set for this machine

aliases

protected Aliases aliases
The Aliases object that defines any instruction aliases for this machine

zeroBit

public static final int zeroBit
The value of teh zero flag bit in the status register

carryBit

public static final int carryBit
The value of the carry flag bit in the status register

decimalBit

public static final int decimalBit
The value of the decimal carry flag bit in the status register

trisBankOffset

public int trisBankOffset
The offset of the tris register bank, used by tris instructions

deviceId

protected int deviceId
The device ID (unique within the processor implementation of a family of devices) for this device

RESET_POWER_UP

public static final int RESET_POWER_UP
Flag to indicate a reset on power up

RESET_MCLR

public static final int RESET_MCLR
Flag to indicate a reset on MCLR

RESET_WATCHDOG

public static final int RESET_WATCHDOG
Flag to indicate a reset on the watchdog timer

RESET_AS_PROGRAMMED

public static final int RESET_AS_PROGRAMMED
Flag to indicate a reset to the full original programmed values

PACKAGE_DIP

public static final int PACKAGE_DIP
Indicates that this device is available in a DIP package - may be OR'd with other package types

PACKAGE_SOIC

public static final int PACKAGE_SOIC
Indicates that this device is available in a SOIC package - may be OR'd with other package types

PACKAGE_PLCC

public static final int PACKAGE_PLCC
Indicates that this device is available in a PLCC package - may be OR'd with other package types

PACKAGE_QFP

public static final int PACKAGE_QFP
Indicates that this device is available in a QFP package - may be OR'd with other package types

CONFIG_WDTE

public static final int CONFIG_WDTE
Bit flag indicating that this device can be configured with a Watchdog Timer Enabled(1) or Disabled(0)

CONFIG_PWRTE

public static final int CONFIG_PWRTE
Bit flag indicating that this device can be configured with a Power-up Timer Enabled(1) or Disabled(0)

CONFIG_PWRTEI

public static final int CONFIG_PWRTEI
Bit flag indicating that this device can be configured with a Power-up Timer Enabled(0) or Disabled(1)

CONFIG_CP

public static final int CONFIG_CP
Bit flag indicating that this device can be configured with Code protection Enabled(0) or Disabled(1)

CONFIG_OSC4

public static final int CONFIG_OSC4
Bit flag indicating that this device can be configured with a RC(11), HS(10), XT(01) or LP(00) Oscillator

CONFIG_DP

public static final int CONFIG_DP
Bit flag indicating that this device can be configured with Data protection Enabled(0) or Disabled(1)

PARAM_DEVICES

public static final int PARAM_DEVICES
Parameter ID for getParameter() - Returns the number of devices supported by this processor implementation

PARAM_BANKS

public static final int PARAM_BANKS
Parameter ID for getParameter() - Returns the number of memory banks

PARAM_BANK_SIZE

public static final int PARAM_BANK_SIZE
Parameter ID for getParameter() - Returns the size of each memory bank (byte offset to next bank start)

PARAM_STACK_SIZE

public static final int PARAM_STACK_SIZE
Parameter ID for getParameter() - Returns the stack size

PARAM_INSTR_WIDTH

public static final int PARAM_INSTR_WIDTH
Parameter ID for getParameter() - Returns the instruction bit width

PARAM_EEPROM_SIZE

public static final int PARAM_EEPROM_SIZE
Parameter ID for getParameter() - Returns the size of EEPROM memory (bytes)

PARAM_PROG_SIZE

public static final int PARAM_PROG_SIZE
Parameter ID for getParameter() - Returns the size of program memory (words)

PARAM_DATA_SIZE

public static final int PARAM_DATA_SIZE
Parameter ID for getParameter() - Returns the size of data memory (bytes)

PARAM_CONFIG_ADDR

public static final int PARAM_CONFIG_ADDR
Parameter ID for getParameter() - Returns the address of the config data

PARAM_CONFIG_WORD

public static final int PARAM_CONFIG_WORD
Parameter ID for getParameter() - Returns the bit flags indicating the CPU features that can be configured by the first config word

PARAM_ID_ADDR

public static final int PARAM_ID_ADDR
Parameter ID for getParameter() - Returns the start address of the ID data (words)

PARAM_ID_SIZE

public static final int PARAM_ID_SIZE
Parameter ID for getParameter() - Returns the number of ID data words

PARAM_ID_WIDTH

public static final int PARAM_ID_WIDTH
Parameter ID for getParameter() - Returns the how many bits of each ID word are valid

PARAM_CONFIG_START

public static final int PARAM_CONFIG_START
Parameter ID for getParameter() - Returns the start address for the config/test program memory area

PARAM_EEPROM_START

public static final int PARAM_EEPROM_START
Parameter ID for getParameter() - Returns the start address for the eeprom data memory area

PARAM_PINS

public static final int PARAM_PINS
Parameter ID for getParameter() - Returns the number of pins for this device

PARAM_PACKAGES

public static final int PARAM_PACKAGES
Parameter ID for getParameter() - Returns the bit flags for the package types this device is supplied in

PARAM_BIT_FOSC0

public static final int PARAM_BIT_FOSC0
Parameter ID for getParameter() - Returns the bit mask for the Config oscillator selection bit 0

PARAM_BIT_FOSC1

public static final int PARAM_BIT_FOSC1
Parameter ID for getParameter() - Returns the bit mask for the Config oscillator selection bit 1

PARAM_BIT_WDTE

public static final int PARAM_BIT_WDTE
Parameter ID for getParameter() - Returns the bit mask for the Config watchdog timer flag

PARAM_BIT_PWRTE

public static final int PARAM_BIT_PWRTE
Parameter ID for getParameter() - Returns the bit mask for the Config power-up timer flag

PARAM_BIT_PWRTEI

public static final int PARAM_BIT_PWRTEI
Parameter ID for getParameter() - Returns the bit mask for the Config power-up timer flag (inverted sense)

PARAM_BIT_CP0

public static final int PARAM_BIT_CP0
Parameter ID for getParameter() - Returns the bit mask for the Config code protection bit 0

PARAM_BIT_DP0

public static final int PARAM_BIT_DP0
Parameter ID for getParameter() - Returns the bit mask for the Data code protection bit 0
Constructor Detail

MachineState

public MachineState(java.lang.String deviceName,
                    InstructionSet instructionSet,
                    Aliases aliases)
             throws MiSimException
MachineState constructor. Initialises all arrays and invokes setRegisters so that the imlpementing class can create and assign device specific registers.
Method Detail

getDeviceId

public int getDeviceId()
Return the deviceID for this device. The device ID is unique within a given implementation of machineState and identifies the particular device being simulated, from the family of devices that the implementation supports.
Returns:
The device ID

getParameter

public int getParameter(int paramId)
Return a given statistic for this machineState implementation. The ID is given by one of the PARAM_ constants defined in this class. If the parameter has no defined value, this method returns -1
Parameters:
paramId - The identifier for the required statistic
Returns:
The requested value

setInstructionSet

public void setInstructionSet(InstructionSet instructionSet)
Set the InstructionSet object that defines the instructions for this processor
Parameters:
instructionSet - The InstructionSet object for this processor

getInstructionSet

public InstructionSet getInstructionSet()
Get the InstructionSet object that defines the instructions for this processor
Returns:
The InstructionSet for this processor

setAliases

public void setAliases(Aliases aliases)
Set the Aliases object that defines any aliases for this processor
Parameters:
aliases - The Aliases object for this processor

getAliases

public Aliases getAliases()
Return the definition for any instruction aliases defined for this processor
Returns:
This processor's instruction aliases

disassemble

public java.lang.String disassemble(Instruction instr)
Return a String representation of the given instruction
Returns:
The String representation of the given instruction

getNewInstruction

public Instruction getNewInstruction(int opcode)
                              throws MiSimException
Return an initialised instruction for the given opcode
Parameters:
opcode - The opcode to encode
Returns:
Instruction An initialised instance of the required instruction
Throws:
MiSimException - If any errors occur during decode

getParameter

public abstract int getParameter(int paramId,
                                 int deviceId)
Return a given statistic for the given device for this machineState implementation. The ID is given by one of the PARAM_ constants defined in this class. If the parameter has no defined value, this method returns -1
Parameters:
paramId - The identifier for the required statistic
deviceId - The ID for the device being examined
Returns:
The requested value

setRegisters

public abstract void setRegisters(Register[] regs,
                                  java.lang.String[] regNames,
                                  java.util.Hashtable portHash)
Create and assign the registers that the device implements. This includes any port registers. The arrays and hashtable passed to this method should be populated by the appropriate data.
Parameters:
regs - The memory space to populate with registers
regNames - An array of the names of each register
portHash - A hashtable mapping the (String) port name to the (Port) object itself

resetRegs

public abstract void resetRegs(Register[] regs,
                               int resetType)
Reset all registers to their power-on values
Parameters:
regs - The register array to reset
resetType - The type of reset

getDeviceName

public abstract java.lang.String getDeviceName(int deviceId)
Return the names of the devices supported by this processor. The number of devices supported can be discovered by calling getParameter( PARAM_DEVICES ). This method can then be called with the index of the device requested, and the name will be returned. If the id is out of range (the processor doesn't support that many devices) this method returns null.
Parameters:
deviceId - The Index of the device name required
Returns:
The requested device name, or null

getPinName

public abstract java.lang.String getPinName(int pinNo,
                                            int deviceId,
                                            int packageType)
Return the name of the given pin for this device
Parameters:
pinNo - The pin number being requested
deviceId - Which specific device is being considered
packageType - The package type, eg. PACKAGE_DIP
Returns:
The name of that pin for the device

getPortPin

public abstract int getPortPin(java.lang.String portName,
                               int bitNo)
Return the pin number that the given port bit is connected to
Parameters:
portName - The name of the required port
bitNo - The bt number for the port
Returns:
The pin number, or -1 if that port/bit is not connected to a pin

enableGlobalInterrupts

public abstract void enableGlobalInterrupts()
This is called at the end of the RETFIE instruction, and should re-enable global interrupts.

eraseEeprom

public void eraseEeprom()
Set the EEPROM contents to zero

setClockListener

public void setClockListener(ClockListener clockListener)
Set the clock listener for this machine.
Parameters:
clockListener - The clock listener for this machine

addClockListener

public void addClockListener(ChainedClockListener newListener)
Add a chained clock listener to this machine. If the new listener has already been added, this will do nothing. If the listener is added, its prepare() method is called to inform it of the current clock count.
Parameters:
newListener - The clock listener to add to the chain..

removeClockListener

public void removeClockListener(ChainedClockListener aListener)
Remove a chained clock listener from this machine..
Parameters:
aListener - The event handler to remove to the chain..

resetMachine

public void resetMachine(int resetType)
Reset the machineState registers according to the given reset type
Parameters:
resetType - The type of the rest that has occurred

addResetListener

public void addResetListener(ResetListener resetListener)
Add a reset listener to this device, to respond to reset events
Parameters:
resetListener - The resetListener to add

removeResetListener

public void removeResetListener(ResetListener resetListener)
Remove a ResetListener from this device
Parameters:
resetListener - The resetListener to remove

getW

public int getW()
Read the W register.
Returns:
The current value of W

setW

public void setW(int w)
Set a new value for the W register
Parameters:
w - The new value for W

getPC

public int getPC()
Get the current value for the Program Counter
Returns:
the current program counter

setPC

public void setPC(int pc)
           throws MiSimException
Set a new value for the Program Counter. This may be overridden in processor to throw an exception if the value requested is not valid.
Parameters:
pc - The new value for the program counter
Throws:
MiSimException - never.

getClocks

public long getClocks()
Get the current clock cycle count.
Returns:
The current clock cycle count

getClockRate

public long getClockRate()
Get the clock rate, in hz for emulation.
Returns:
The clock rate in hz.

setClockRate

public void setClockRate(long clockRate)
Set the clock rate, in hz for emulation. Note this calls prepare for all clock listeners.
Parameters:
clockRate - The new clock rate, in hz

setClocks

public void setClocks(long clocks)
Set the current clock cycle count.
Parameters:
clocks - The new value for the clock cycle count

getTicks

public long getTicks(long time)
Return the number of clock ticks for the given time interval, assuming the current CPU clock rate..
Parameters:
time - Time to convert, in uS (microseconds)
Returns:
The number of ticks in the given interval

getAvailablePorts

public java.util.Hashtable getAvailablePorts()
Return the hashtable that maps the names of the ports that this chip supports (a String) to the port implementations (a misim.register.Port)
Returns:
a Hashtable of available ports.

getPort

public Port getPort(java.lang.String aPortName)
Return a Named port
Parameters:
aPortName - The name of the port to return
Returns:
The specified port, or null if it doesn't exist

addPortListener

public java.util.Vector addPortListener(PortListener portListener,
                                        java.lang.String aPortName)
Add a port listener.. this adds the listener to the given port.
Parameters:
portListener - The port listener to add.
aPortName - The name of the port we wish to listen to
Returns:
A Vector of the ports that have been added..

addPortListener

public java.util.Vector addPortListener(PortListener portListener,
                                        java.util.Vector whichPorts)
Add a port listener.. this adds the listener to a Vector of port names.
Parameters:
portListener - The port listener to add.
whichPorts - A Vector of the port names to add this listener to
Returns:
A Vector of the ports that have been added..

removePortListener

public void removePortListener(PortListener portListener)
Remove port listener - this asks all ports to remove the given port listener. Note that it does not check to see if this port listener has registered with each port.
Parameters:
portListener - The port listener to remove

getReg

public int getReg(int regNumber)
Return the value of the given register or -1 if the register is not implemented.
Parameters:
regNumber - The number of the register to read
Returns:
The integer value of the register.

validReg

public boolean validReg(int regNumber)
Check to see if this register is implemented
Parameters:
regNumber - The number of the register to read
Returns:
True if a register exists at the given address

regString

public java.lang.String regString(int regNumber)
Return the value of the register as a String. The excact format of the register string is determined by the register's toString method. If the register is not implemented in this device, the string "xx" is returned.
Parameters:
regNumber - The number of the register to read
Returns:
A string representation of the value of this register

regChar

public char regChar(int regNumber)
Return the contents of the given register as a character. If the register does not exist a '-' is returned. If the register value cannot be displayed as a character in the range 32-127, a '.' is returned.
Parameters:
regNumber - The number of the register to read
Returns:
A character representing the value of that register.

setReg

public void setReg(int regNumber,
                   int value)
Set the value of a given register. If the register does not exist, this does nothing.
Parameters:
regNumber - The number of the register to set
value - The new value for the register.

regName

public java.lang.String regName(int address)
Get the name of a processor register. Named registers are usually special function registers for the processor, for example 'STATUS' or 'PORTA' in the case of the PIC16F84. If the register has been given a name (by the specific processor implementation) that name is returned. All other registers return the hex address of the register, in the format '0xNN'. If the register address is not valid for this processor, the string 'ERR' is returned.
Parameters:
address - The address of the register
Returns:
The name of the register, if defined, or the hex address

setRegName

public void setRegName(int address,
                       java.lang.String name)
Set the name for a given register.
Parameters:
address - The address of the register
name - The new name for the register, or null to unset.

isNamed

public boolean isNamed(int address)
Return true if this register has a name, false otherwise. Named registers are usually special function registers for the processor.
Parameters:
address - The address of the register to examine.
Returns:
True if this is a named register.

namedRegisters

public int namedRegisters()
Return the number of registers that have been named. Named registers are usually special function registers for the processor.
Returns:
The number of named registers

getNthRegName

public java.lang.String getNthRegName(int index)
Return the name for the Nth named register. The given index should be greater or equal to zero and less than the value returned by namedRegisterS().
Parameters:
index - The index for the required named register
Returns:
The name of the register or 'ERR' if the index is invalid
See Also:
namedRegisters()

getNthRegAddress

public int getNthRegAddress(int index)
Return the address of the Nth named register. The given index should be greater or equal to zero and less than the value returned by namedRegisterS().
Parameters:
index - The index for the required named register
Returns:
The address of the register, or -1 if the index is invalid
See Also:
namedRegisters()

setAddresses

public void setAddresses(int[] addrArray,
                         int count)
Initialise the address label hashtable with default labels for the given set of 'important' addresses.
Parameters:
addrArray - An array of important addresses
count - The number of addresses in the array that are valid

addressName

public java.lang.String addressName(int addr,
                                    int length,
                                    boolean emptyOk)
Return the name (label) for this address. If the address has a label, return that label, otherwise return the hex address. If the calling routine only wants labels, it must call this with the empty flag set to true.
Parameters:
addr - The address that we want the name for
length - The length to pad the text to
emptyOk - If True, return an empty (padded) string for unset addresses.

setAddressName

public void setAddressName(int addr,
                           java.lang.String label)

miSim