fi.hu.cs.titokone
Class Registers

java.lang.Object
  extended byfi.hu.cs.titokone.Registers

public class Registers
extends java.lang.Object

This data class contains all the register information. The registers are accessed via index numbers which are defined in the TTK91CPU interface.


Field Summary
private  int[] registerValues
          This field contains the register values.
 
Constructor Summary
Registers()
           
 
Method Summary
private  int getIndex(int TTK91Cpu_index)
          Converts TTK91Cpu register to the corresponding index to registerValues array.
private  int getIndex(java.lang.String registerName)
          Converts given String to the corresponding index to registerValues array.
 int getRegister(int registerId)
          Returns the value of a register.
 int getRegister(java.lang.String registerName)
          Returns the value of a register.
 void setRegister(int registerId, int value)
          Sets a new value to a register.
 void setRegister(java.lang.String registerName, int value)
          Sets a new value to a register.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

registerValues

private int[] registerValues
This field contains the register values. 0..7 are general-purpose registers, 8..12 are CU registers.

Constructor Detail

Registers

public Registers()
Method Detail

getRegister

public int getRegister(int registerId)
Returns the value of a register. The index numbers are available from the TTK91CPU interface.

Parameters:
registerId - Identifying number of the register.
Returns:
Value stored in the register.

getRegister

public int getRegister(java.lang.String registerName)
Returns the value of a register.

Parameters:
registerName - The name of the register.
Returns:
Value stored in the register.

setRegister

public void setRegister(int registerId,
                        int value)
Sets a new value to a register.

Parameters:
registerId - The identifying number of the register.
value - New value to set.

setRegister

public void setRegister(java.lang.String registerName,
                        int value)
Sets a new value to a register.

Parameters:
registerName - The name of the register.
value - New value to set.

getIndex

private int getIndex(int TTK91Cpu_index)
Converts TTK91Cpu register to the corresponding index to registerValues array.

Parameters:
TTK91Cpu_index - Register index in TTK91Cpu notation
Returns:
Index to registerValues array. Returns -1 if register does not exists in TTK91Cpu.

getIndex

private int getIndex(java.lang.String registerName)
Converts given String to the corresponding index to registerValues array.

Parameters:
registerName - The name of the register.
Returns:
Index to registerValues array. Returns -1 if register does not exists.