avrora.core
Class Register

java.lang.Object
  extended byavrora.core.Register

public class Register
extends java.lang.Object

The Register class represents a register available on the AVR instruction set. All registers in the instruction set architecture are represented as objects that have a name and a number. Those objects are singletons and are public static final fields of this class.

Additionally, the Register class contains sets of registers that are used in verifying the operand constraints of each individual instruction as defined in the AVR instruction set reference. An example of an operand constraint is that ldi (load immediate) takes as operands one of the general purpose registers {r17...r31} and an immediate. Other instructions take certain subsets of the instructions. Those register sets are allocated once here and are exposed as static fields in this class.

See Also:
Operand, Instr

Nested Class Summary
static class Register.Set
          The Set class represents a set of registers.
 
Field Summary
static Register.Set ADR_set
           
static Register.Set EGPR_set
           
static Register.Set GPR_set
           
static Register.Set HGPR_set
           
static Register.Set MGPR_set
           
static Register R0
           
static Register R1
           
static Register R10
           
static Register R11
           
static Register R12
           
static Register R13
           
static Register R14
           
static Register R15
           
static Register R16
           
static Register R17
           
static Register R18
           
static Register R19
           
static Register R2
           
static Register R20
           
static Register R21
           
static Register R22
           
static Register R23
           
static Register R24
           
static Register R25
           
static Register R26
           
static Register R27
           
static Register R28
           
static Register R29
           
static Register R3
           
static Register R30
           
static Register R31
           
static Register R4
           
static Register R5
           
static Register R6
           
static Register R7
           
static Register R8
           
static Register R9
           
static Register.Set RDL_set
           
static Register X
           
static Register Y
           
static Register.Set YZ_set
           
static Register Z
           
static Register.Set Z_set
           
 
Method Summary
 java.lang.String getName()
          The getName() method returns the name of the instruction as a string.
 int getNumber()
          The getNumber() method returns the "number" of this register, meaning the offset into the register file.
static Register getRegisterByName(java.lang.String name)
          The getRegisterByName() method retrieves a reference to the Register instance with the given string name.
static Register getRegisterByNumber(int num)
          The getRegisterByNumber() method retrieves a reference to the Register instance with the given offset in the register file.
 int getWidth()
          The getWidth() method returns the width of the register in bits.
 int hashCode()
          The hashCode() computes the hash code of this register so that registers can be inserted in hashmaps and hashsets.
 Register nextRegister()
          The nextRegister() method returns a reference to the register that immediately follows this register in the register file.
 java.lang.String toString()
          The toString() method coverts this register to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

R0

public static final Register R0

R1

public static final Register R1

R2

public static final Register R2

R3

public static final Register R3

R4

public static final Register R4

R5

public static final Register R5

R6

public static final Register R6

R7

public static final Register R7

R8

public static final Register R8

R9

public static final Register R9

R10

public static final Register R10

R11

public static final Register R11

R12

public static final Register R12

R13

public static final Register R13

R14

public static final Register R14

R15

public static final Register R15

R16

public static final Register R16

R17

public static final Register R17

R18

public static final Register R18

R19

public static final Register R19

R20

public static final Register R20

R21

public static final Register R21

R22

public static final Register R22

R23

public static final Register R23

R24

public static final Register R24

R25

public static final Register R25

R26

public static final Register R26

R27

public static final Register R27

R28

public static final Register R28

R29

public static final Register R29

R30

public static final Register R30

R31

public static final Register R31

X

public static final Register X

Y

public static final Register Y

Z

public static final Register Z

GPR_set

public static final Register.Set GPR_set

HGPR_set

public static final Register.Set HGPR_set

MGPR_set

public static final Register.Set MGPR_set

EGPR_set

public static final Register.Set EGPR_set

ADR_set

public static final Register.Set ADR_set

RDL_set

public static final Register.Set RDL_set

YZ_set

public static final Register.Set YZ_set

Z_set

public static final Register.Set Z_set
Method Detail

getRegisterByName

public static Register getRegisterByName(java.lang.String name)
The getRegisterByName() method retrieves a reference to the Register instance with the given string name. This method is not case sensitive.

Parameters:
name - the name of the register as a string
Returns:
a reference to the Register object representing the register if a register of that name exists; null otherwise

getRegisterByNumber

public static Register getRegisterByNumber(int num)
The getRegisterByNumber() method retrieves a reference to the Register instance with the given offset in the register file.

Parameters:
num - the integer number of the register to retrieve
Returns:
a reference to the Register object representing the chosen register

hashCode

public int hashCode()
The hashCode() computes the hash code of this register so that registers can be inserted in hashmaps and hashsets. This implementation of register simply uses the hash code of the name of the register as its hash code.

Returns:
an integer that represents the hash code of this register

toString

public java.lang.String toString()
The toString() method coverts this register to a string. This implementation simply returns the name of the register.

Returns:
a string representation of this register

getName

public java.lang.String getName()
The getName() method returns the name of the instruction as a string.

Returns:
the name of the instruction

getNumber

public int getNumber()
The getNumber() method returns the "number" of this register, meaning the offset into the register file.

Returns:
the number of this register

getWidth

public int getWidth()
The getWidth() method returns the width of the register in bits.

Returns:
the number of bits in this register

nextRegister

public Register nextRegister()
The nextRegister() method returns a reference to the register that immediately follows this register in the register file. This is needed when treating multiple registers as a single value, etc.

Returns:
the register immediately following this register in the register file