# Class: com.pnfsoftware.jeb.core.units.code.asm.processor.arch.RegisterUtil

Utility methods for [IRegisterBank](IRegisterBank) and [IRegisterData](IRegisterData), including methods to create standard register ids. 

 **Implementation note:** at this time, a standard register id is composed as such \(this may change\):           

```

           I=index (20 bits), G=group (12 bits), S=bitsize (12 bits), B=bitstart (12 bits), x=unused
           storage format: [xx BB BS SS GG GI II II]
           
```

## Static Method: byteArrayToHex
- parameter: `endianness`, type: `com.pnfsoftware.jeb.util.io.Endianness`
- parameter: `data`, type: `byte[]`
- return type: `java.lang.String`

Description: Format a byte array according to an endianness.
parameter: endianness: byte order
parameter: data: bytes to format
return: hexadecimal string

## Static Method: byteArrayToHex
- parameter: `endianness`, type: `com.pnfsoftware.jeb.util.io.Endianness`
- parameter: `data`, type: `byte[]`
- parameter: `pos`, type: `int`
- parameter: `end`, type: `int`
- return type: `java.lang.String`

Description: Format a byte\-array range according to an endianness.
parameter: endianness: byte order
parameter: data: bytes to format
parameter: pos: start offset
parameter: end: exclusive end offset
return: hexadecimal string

## Static Method: createPureRegisterId
- parameter: `index`, type: `int`
- parameter: `grp`, type: `int`
- return type: `long`

Description: Create a pure register id, i.e. an id always representing a full register, without indicators such as bit size or bit start.
parameter: index: register index
parameter: grp: register group
return: pure register id

## Static Method: createRegisterId
- parameter: `index`, type: `int`
- parameter: `grp`, type: `int`
- parameter: `bitsize`, type: `int`
- return type: `long`

Description: Create a standard register id \(full or slice\).
parameter: index: register index
parameter: grp: register group
parameter: bitsize: register size in bits
return: register id

## Static Method: createRegisterId
- parameter: `index`, type: `int`
- parameter: `grp`, type: `int`
- parameter: `bitsize`, type: `int`
- parameter: `bitstart`, type: `int`
- return type: `long`

Description: Create a standard register id \(full or slice\).
parameter: index: register index
parameter: grp: register group
parameter: bitsize: register size in bits
parameter: bitstart: start bit for register slices
return: register id

## Static Method: createRegisterIdFromPureId
- parameter: `pure`, type: `long`
- parameter: `bitsize`, type: `int`
- parameter: `bitstart`, type: `int`
- return type: `long`

Description: Create a full register id from a pure id and slice metadata.
parameter: pure: pure register id
parameter: bitsize: register size in bits
parameter: bitstart: start bit
return: register id

## Static Method: getBank
- parameter: `proctype`, type: `com.pnfsoftware.jeb.core.units.codeobject.ProcessorType`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.processor.IRegisterBank`

Description: Convenience method to retrieve a register bank used by a well\-known processor type. 

 It is recommended to use [RegisterBankService](RegisterBankService) directly.
parameter: proctype: a processor type
return: null if not found

## Static Method: getEntryByName
- parameter: `bank`, type: `com.pnfsoftware.jeb.core.units.code.asm.processor.IRegisterBank`
- parameter: `name`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.processor.RegisterDescriptionEntry`

Description: Retrieve a register entry by name.
parameter: bank: register bank
parameter: name: register name
return: register entry, or null

## Static Method: getEntryByName
- parameter: `bank`, type: `com.pnfsoftware.jeb.core.units.code.asm.processor.IRegisterData`
- parameter: `name`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.processor.RegisterDescriptionEntry`

Description: Retrieve a register entry by name.
parameter: bank: register data
parameter: name: register name
return: register entry, or null

## Static Method: getEntryByType
- parameter: `bank`, type: `com.pnfsoftware.jeb.core.units.code.asm.processor.IRegisterBank`
- parameter: `type`, type: `com.pnfsoftware.jeb.core.units.code.asm.processor.RegisterType`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.processor.RegisterDescriptionEntry`

Description: Retrieve a register entry by type.
parameter: bank: register bank
parameter: type: register type
return: register entry, or null

## Static Method: getEntryByType
- parameter: `bank`, type: `com.pnfsoftware.jeb.core.units.code.asm.processor.IRegisterData`
- parameter: `type`, type: `com.pnfsoftware.jeb.core.units.code.asm.processor.RegisterType`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.processor.RegisterDescriptionEntry`

Description: Retrieve a register entry by type.
parameter: bank: register data
parameter: type: register type
return: register entry, or null

## Static Method: getPureId
- parameter: `id`, type: `long`
- return type: `long`

Description: Extract the pure id from a register id.
parameter: id: register id
return: pure register id

## Static Method: getRegisterBitsize
- parameter: `id`, type: `long`
- return type: `int`

Description: Extract the register size from a register id.
parameter: id: register id
return: register size in bits

## Static Method: getRegisterBitstart
- parameter: `id`, type: `long`
- return type: `int`

Description: Extract the register slice start bit from a register id.
parameter: id: register id
return: start bit

## Static Method: getRegisterGroup
- parameter: `id`, type: `long`
- return type: `int`

Description: Extract the register group from a register id.
parameter: id: register id
return: register group

## Static Method: getRegisterIndex
- parameter: `id`, type: `long`
- return type: `int`

Description: Extract the register index from a register id.
parameter: id: register id
return: register index

## Static Method: getValueByName
- parameter: `bank`, type: `com.pnfsoftware.jeb.core.units.code.asm.processor.IRegisterData`
- parameter: `name`, type: `java.lang.String`
- return type: `byte[]`

Description: Retrieve a register value by name.
parameter: bank: register data
parameter: name: register name
return: register value bytes, or null

## Static Method: getValueByNameAsLong
- parameter: `bank`, type: `com.pnfsoftware.jeb.core.units.code.asm.processor.IRegisterData`
- parameter: `name`, type: `java.lang.String`
- return type: `java.lang.Long`

Description: Retrieve a register value by name as a long.
parameter: bank: register data
parameter: name: register name
return: register value, or null

## Static Method: isPureId
- parameter: `id`, type: `long`
- return type: `boolean`

Description: Determine whether a register id is pure.
parameter: id: register id
return: true if the id does not encode size or bit\-start metadata

## Static Method: setValueByName
- parameter: `bank`, type: `com.pnfsoftware.jeb.core.units.code.asm.processor.IRegisterData`
- parameter: `name`, type: `java.lang.String`
- parameter: `bytes`, type: `byte[]`
- return type: `boolean`

Description: Set a register value by name.
parameter: bank: register data
parameter: name: register name
parameter: bytes: register value bytes
return: true if the value was set

## Static Method: setValueByNameAsLong
- parameter: `bank`, type: `com.pnfsoftware.jeb.core.units.code.asm.processor.IRegisterData`
- parameter: `name`, type: `java.lang.String`
- parameter: `value`, type: `long`
- return type: `boolean`

Description: Set a register value by name as a long.
parameter: bank: register data
parameter: name: register name
parameter: value: register value
return: true if the value was set

