# Interface: com.pnfsoftware.jeb.core.units.code.asm.processor.IProcessor

Definition of a simple machine code processor or microcontroller. It is recommended that implementors extend [AbstractProcessor](AbstractProcessor) instead of implementing this interface from scratch. 

 The "processor mode" indicates the current operating size of the processor. \(In several cases, it matches the size in bits of a general\-purpose register, as well as the size of the program counter \- there are exceptions to this rule though.\) 

 Implementations may or may not support safe concurrent operation.

## Static Field: MODE_128
Type: `int`

Constant value: `128`
Description: Convenience constant. Processor mode constant for 128\-bit processors

## Static Field: MODE_16
Type: `int`

Constant value: `16`
Description: Convenience constant. Processor mode constant for 16\-bit processors

## Static Field: MODE_256
Type: `int`

Constant value: `256`
Description: Convenience constant. Processor mode constant for 256\-bit processors

## Static Field: MODE_32
Type: `int`

Constant value: `32`
Description: Convenience constant. Processor mode constant for 32\-bit processors

## Static Field: MODE_64
Type: `int`

Constant value: `64`
Description: Convenience constant. Processor mode constant for 64\-bit processors

## Static Field: MODE_8
Type: `int`

Constant value: `8`
Description: Convenience constant. Processor mode constant for 8\-bit processors

## Static Field: MODE_DEFAULT
Type: `int`

Constant value: `0`
Description: Default processor mode constant \(unknown or standard mode\)

## Static Field: MODE_INVALID
Type: `int`

Constant value: `-1`
Description: Invalid processor mode, do not use

## Method: createEntryPoint
- parameter: `address`, type: `long`
- return type: `com.pnfsoftware.jeb.core.units.code.CodePointer`

Description: Create an entry\-point from a provided native address.
parameter: address: address of the instruction
return: the entry point \(careful\! may contain an address different \-adjusted\- than the input         parameter\)

## Method: createEntryPoint
- parameter: `address`, type: `long`
- parameter: `defaultMode`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.CodePointer`

Description: Create an entry\-point from a provided native address.
parameter: address: address of the instruction
parameter: defaultMode: default processor mode if it cannot be determined by address
return: the entry point \(careful\! may contain an address different \-adjusted\- than the input         parameter\)

## Method: getDefaultMode
- return type: `int`

Description: Get the default processor mode. The mode indicates the current operating size of the processor. Typically, this represents the size in bits of general purpose \(GP\) registers, as well as the size of the program counter \(PC\).
return: the default processor mode, never [#MODE_DEFAULT](#MODE_DEFAULT) \(0\)

## Method: getEndianness
- return type: `com.pnfsoftware.jeb.util.io.Endianness`

Description: Get the endianness this processor operates in.
return: 

## Method: getGPRegisterBitsize
- return type: `int`

Description: Retrieve the size of a General Purpose register, in bits.
return: 

## Method: getInstructionAlignment
- return type: `int`

Description: Retrieve the instruction alignment, in bytes.
return: the instruction alignment, eg, 1, 2, 4, 8, etc.

## Method: getMode
- return type: `int`

Description: Get the processor mode. Typically, the processor mode is a size in bits that indicates how instructions are parsed and/or the size of general\-purpose registers used for arithmetic operations and/or how memory slots are addressed are accessed. Typical processor modes are 8\-, 16\-, 32\- or 64\- bits\). Note: A 'processor mode' could have a different semantic, but anything non\-standard is unlikely to be understood by client code. This function will never return 0 See `MODE_Xxx` for common constants.
return: the processor mode, never [#MODE_DEFAULT](#MODE_DEFAULT) \(0\)

## Method: getPCRegisterBitsize
- return type: `int`

Description: Retrieve the size of the Program Counter register, in bits.
return: 

## Method: getRegisterBank
- return type: `com.pnfsoftware.jeb.core.units.code.asm.processor.IRegisterBank`

Description: 
return: 

## Method: getRegisterName
- parameter: `registerCode`, type: `long`
- return type: `java.lang.String`

Description: Retrieve the string name of a register by its internal register code.
parameter: registerCode: register code used by this processor object as well as generated            instruction and operand objects. Not to be confused with standardized register            indices defined in [register bank objects](IRegisterBank)
return: a name or null \(on error or if the implementation is not provided\)

## Method: getResolver
- return type: `com.pnfsoftware.jeb.core.units.code.asm.simulator.ICodeResolver<InsnType>`

Description: Retrieve a code resolver. A resolver is optional; implementors may decide to not provide one, and return null.
return: a resolver

## Method: getSupportedModes
- return type: `java.util.Collection<java.lang.Integer>`

Description: Get the list of valid modes that this processor supports.
return: 

## Method: getSupportedVariants
- return type: `java.util.Collection<com.pnfsoftware.jeb.core.units.codeobject.ProcessorVariant>`

Description: Retrieve a list of supported processor variants.
return: 

## Method: getType
- return type: `com.pnfsoftware.jeb.core.units.codeobject.ProcessorType`

Description: Retrieve the processor type. The type depends on the current [execution mode](#getMode()). A processor class may implement several modes, mapping to various processor types.
return: 

## Method: getVariant
- return type: `com.pnfsoftware.jeb.core.units.codeobject.ProcessorVariant`

Description: Get the processor variant used by this object.
return: 

## Method: isRISC
- return type: `boolean`

Description: Provide a hint about the instruction set architecture.
return: 

## Method: parseAt
- parameter: `bytes`, type: `byte[]`
- parameter: `index`, type: `int`
- parameter: `end`, type: `int`
- return type: `InsnType`

Description: Parse a single instruction.
parameter: bytes: input code buffer
parameter: index: where to parse in the input buffer
parameter: end: exclusive end offset in the buffer: if parsing at the given index offset requires            bytes past the end offset, an exception is raised
return: the instruction, never null \- on parsing error, an exception is raised
throws: on parsing error
throws: on miscellaneous error

## Method: parseAt
- parameter: `vm`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `address`, type: `long`
- return type: `InsnType`

Description: Parse a single instruction at the specified address in memory.
parameter: vm: the input virtual memory
parameter: address: the address to read at, with permission of [read\+write](IVirtualMemory#ACCESS_RW)
return: the instruction, never null. On parsing error, an exception is raised
throws: on parsing error
throws: on miscellaneous error

## Method: parseWithContext
- parameter: `context`, type: `com.pnfsoftware.jeb.core.units.code.asm.IMachineContext`
- return type: `InsnType`

Description: Parse a single instruction given a machine context. The context provides access to at least: 
 
- memory data
-  
- a register bank, including the program counter
-  

 When using this method, other settings determined by this interface, such as the processor mode or endianness, can be disregarded: the context has higher priority. However, an implementor is allowed to raise a processor exception if mismatches are detected \(typically, the endianness\).
parameter: context: 
return: 
throws: 

## Method: setEndianness
- parameter: `endianness`, type: `com.pnfsoftware.jeb.util.io.Endianness`

Description: Set the endianness of this processor.
parameter: endianness: 

## Method: setInstructionAlignment
- parameter: `align`, type: `int`

Description: Set the instruction alignment, in bytes. The implementation may decide to enforce alignment, or ignore it. If alignment is enforced, attempting to parse an unaligned instruction should raise a [ProcessorException](ProcessorException).
parameter: align: the alignment, must be a strictly positive power of 2

## Method: setMode
- parameter: `newMode`, type: `int`
- return type: `int`

Description: Set the processor mode. Implementors may override this class, if they have other/better/proper ways to determine the processor operating mode. In that case, the mode provided by this method may be regarded as a hint \- or disregarded entirely.
parameter: newMode: the mode, the value [#MODE_DEFAULT](#MODE_DEFAULT) \(0\) can be provided to revert to the            default processor mode
return: the previous processor mode
throws: if the mode is not supported

## Method: setVariant
- parameter: `variant`, type: `com.pnfsoftware.jeb.core.units.codeobject.ProcessorVariant`

Description: Set the new variant used by this processor.
parameter: variant: 
throws: if the variant is not supported

