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

An abstract implementation of a [processor](IProcessor). It is recommended to inherit from this class. The implementor simply needs to implement a [parseAt\(\)](IProcessor#parseAtInternal(byte[], int, int)) method. Instruction alignment is enforced. 

 Implementations of [#parseAtInternal(byte[], int, int)](#parseAtInternal(byte[], int, int)) cannot be guaranteed to be thread\-safe. Because of that, parsing is synchronized to allow concurrent threads to parse safely. Use [#lock](#lock) instead of \`synchronized\(this\)\` for locking. \(This will allow us to offer implementors a way to disable locking/synchronizing when the implementation is truly concurrent.\)

## Constructor: AbstractProcessor
- parameter: `parseCacheLength`, type: `int`
- parameter: `defaultMode`, type: `int`
- parameter: `endianness`, type: `com.pnfsoftware.jeb.util.io.Endianness`
- parameter: `instructionAlign`, type: `int`

Description: Create a processor.
parameter: parseCacheLength: 
parameter: defaultMode: 
parameter: endianness: 
parameter: instructionAlign: 

## Constructor: AbstractProcessor
- parameter: `parseCacheLength`, type: `int`
- parameter: `defaultMode`, type: `int`
- parameter: `parent`, type: `com.pnfsoftware.jeb.core.IUnitCreator`
- parameter: `instructionAlign`, type: `int`


## Constructor: AbstractProcessor
- parameter: `parseCacheLength`, type: `int`
- parameter: `defaultMode`, type: `int`
- parameter: `parent`, type: `com.pnfsoftware.jeb.core.IUnitCreator`
- parameter: `instructionAlign`, type: `int`
- parameter: `parseBufferBefore`, type: `int`

Description: Create a processor, retrieving Endianness from parent [IUnitCreator](IUnitCreator). If the endianness cannot be retrieved, default little\-endian will be used.
parameter: parseCacheLength: Total byte length to retrieve when            [#parseAt(IVirtualMemory, long)](#parseAt(IVirtualMemory, long)) method is called.
parameter: defaultMode: Default Processor Mode
parameter: parent: Creator of the processor
parameter: instructionAlign: Minimum instruction alignment allowed.
parameter: parseBufferBefore: number of bytes to parse before current address when            [#parseAt(IVirtualMemory, long)](#parseAt(IVirtualMemory, long)) method is called. Note than the byte range            will be \[address\-parseBufferBefore, address\+parseCacheLength\]

## Protected Field: defaultMode
Type: `int`

## Protected Field: mode
Type: `int`

## Protected Field: supportedModes
Type: `java.util.Collection<java.lang.Integer>`

## Protected Field: supportedVariants
Type: `java.util.Collection<com.pnfsoftware.jeb.core.units.codeobject.ProcessorVariant>`

## Protected Field: variant
Type: `com.pnfsoftware.jeb.core.units.codeobject.ProcessorVariant`

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

Description: Clear the instruction cache, if this processed uses one. 

 The default implementation does nothing.
return: true if a cache was in place, was used, and was cleared; false otherwise

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

Description: The default implementation creates an entry\-point using the exact provided address, with a default processor mode.

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


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


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


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


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


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


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


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


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

Description: The default implementation attempts to find an appropriate hard\-coded bank \(from [#getType()](#getType())\) using [RegisterUtil](RegisterUtil).

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

Description: The default implementation attempts to find a name using [#getRegisterBank()](#getRegisterBank()).

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

Description: The default implementation returns null. Careful, access to this object is subject to locking.

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


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


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

Description: The default implementation returns [ProcessorType#UNKNOWN](ProcessorType#UNKNOWN). Most implementation will want to override this default and return a proper processor type.

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


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

Description: The default implementation returns false \(i.e. assume the processor is not RISC unless explicitly specified\).

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


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


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

Description: Decode bytes as instructions. The one and only method all processors must implement. This method is not synchronized; implementations should keep its protection level to \`protected\`, unless they want client code to be able to do fast\(er\), albeit unsafe, parsing. Most implementations should keep this method protected, and client code should call [#parseAt(byte[], int, int)](#parseAt(byte[], int, int)) or other similar, safe methods.
parameter: bytes: 
parameter: index: 
parameter: end: 
return: 
throws: 

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


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

Description: The default implementation throws [UnsupportedOperationException](UnsupportedOperationException).
parameter: context: 
return: 
throws: 

## Protected Method: setDefaultMode
- parameter: `defaultMode`, type: `int`

Description: Set the default mode. Only for implementors. This method is and should be called just once \(at construction time\).
parameter: defaultMode: the default processor mode, cannot be 0

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


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


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


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


