Class Register

java.lang.Object
ghidra.program.model.lang.Register
All Implemented Interfaces:
Serializable, Comparable<Register>
Direct Known Subclasses:
UnknownRegister

public class Register extends Object implements Serializable, Comparable<Register>
Class to represent a processor register. To sort of handle bit registers, a special addressing convention is used. First the upper bit is set. Second, the next 3 bits are used to specify what bit position within a byte that this register bit exists at. Finally, the rest of the address is the address of the byte where the register bit lives.
See Also:
  • Field Details

  • Constructor Details

    • Register

      public Register(String name, String description, Address address, int numBytes, boolean bigEndian, int typeFlags)
      Constructs a new Register object.
      Parameters:
      name - the name of this Register.
      description - the description of this Register
      address - the address in register space of this register
      numBytes - the size (in bytes) of this register
      bigEndian - true if the most significant bytes are associated with the lowest register addresses, and false if the least significant bytes are associated with the lowest register addresses.
      typeFlags - the type(s) of this Register (TYPE_NONE, TYPE_FP, TYPE_SP, TYPE_PC, TYPE_CONTEXT, TYPE_ZERO);)
    • Register

      public Register(Register register)
    • Register

      public Register(String name, String description, Address address, int numBytes, int leastSignificantBit, int bitLength, boolean bigEndian, int typeFlags)
  • Method Details

    • getAliases

      public Iterable<String> getAliases()
      Return register aliases. NOTE: This is generally only supported for context register fields.
      Returns:
      register aliases or null
    • getName

      public String getName()
      Gets the name of this Register.
      Returns:
      the name of this Register.
    • getDescription

      public String getDescription()
      Get the description of the Register.
      Returns:
      the description of the register
    • isBigEndian

      public boolean isBigEndian()
    • getBitLength

      public int getBitLength()
      Gets the total number of bits for this Register.
      Returns:
      the total number of bits for this Register.
    • getMinimumByteSize

      public int getMinimumByteSize()
      Returns the minimum number of bytes required to store a value for this Register.
    • getNumBytes

      public int getNumBytes()
      Returns the number of bytes spanned by this Register.

      Compare to getMinimumByteSize(): Suppose a 5-bit register spans 2 bytes: 1 bit in the first byte, and the remaining 4 in the following byte. Its value can still be stored in 1 byte, which is what getMinimumByteSize() returns; however, its storage still spans 2 bytes of the base register, which is what this method returns.

    • getOffset

      public int getOffset()
      Returns the offset into the register space for this register
    • getLeastSignificantBit

      public int getLeastSignificantBit()
      Returns the bit offset from the register address for this register.
      Returns:
      the bit offset from the register address for this register.
    • isDefaultFramePointer

      public boolean isDefaultFramePointer()
      Returns true if this is the default frame pointer register
    • followsFlow

      public boolean followsFlow()
      Returns true for a register whose context value should follow the disassembly flow.
    • isHidden

      public boolean isHidden()
      Returns true if this is a hidden register.
    • isProgramCounter

      public boolean isProgramCounter()
      Returns true if this is the program counter register
    • isProcessorContext

      public boolean isProcessorContext()
      Returns true if this is a processor state register
    • isZero

      public boolean isZero()
      Returns true for a register that is always zero
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • getAddressSpace

      public AddressSpace getAddressSpace()
      Returns the register address space
    • compareTo

      public int compareTo(Register other)
      Specified by:
      compareTo in interface Comparable<Register>
      See Also:
    • getAddress

      public Address getAddress()
      Returns the address of the register.
    • getParentRegister

      public Register getParentRegister()
    • getChildRegisters

      public List<Register> getChildRegisters()
      Returns list of children registers sorted by lest-significant bit-offset within this register.
    • getBaseRegister

      public Register getBaseRegister()
    • getLeastSignificantBitInBaseRegister

      public int getLeastSignificantBitInBaseRegister()
    • getTypeFlags

      public int getTypeFlags()
    • getBaseMask

      public byte[] getBaseMask()
      Returns the mask that indicates which bits in the base register apply to this register.
      Returns:
      the mask that indicates which bits in the base register apply to this register
    • hasChildren

      public boolean hasChildren()
    • getGroup

      public String getGroup()
    • isBaseRegister

      public boolean isBaseRegister()
    • contains

      public boolean contains(Register reg)
      Determines if reg is contained within this register. Method does not work for bit registers (e.g., context-bits)
      Parameters:
      reg - another register
      Returns:
      true if reg equals this register or is contained within it.
    • isVectorRegister

      public boolean isVectorRegister()
      Returns true if this is a vector register
      Returns:
      true precisely when this is a full vector register (i.e., a register that can be used as input or output for a SIMD operation).
    • isValidLaneSize

      public boolean isValidLaneSize(int laneSizeInBytes)
      Determines whether laneSizeInBytes is a valid lane size for this register.
      Parameters:
      laneSizeInBytes - lane size to check, measured in bytes
      Returns:
      true precisely when this is a vector register and laneSizeInBytes is a valid lane size.
    • getLaneSizes

      public int[] getLaneSizes()
      Returns the sorted array of lane sizes for this register, measured in bytes.
      Returns:
      array of lane sizes, or null if this is not a vector register or no lane sizes have been set.