com.pnfsoftware.jeb.core.units.code.asm.processor.IProcessor<InsnType extends com.pnfsoftware.jeb.core.units.code.IInstruction> |
![]()
AbstractProcessor<InsnType extends IInstruction>
|
Definition of a simple machine code processor or microcontroller. It is recommended that
implementors extend 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.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | MODE_128 | Convenience constant. | |||||||||
int | MODE_16 | Convenience constant. | |||||||||
int | MODE_256 | Convenience constant. | |||||||||
int | MODE_32 | Convenience constant. | |||||||||
int | MODE_64 | Convenience constant. | |||||||||
int | MODE_8 | Convenience constant. | |||||||||
int | MODE_DEFAULT | Default processor mode constant (unknown or standard mode) | |||||||||
int | MODE_INVALID | Invalid processor mode, do not use |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract EntryPointDescription |
createEntryPoint(long address)
Create an entry-point from a provided native address.
| ||||||||||
abstract EntryPointDescription |
createEntryPoint(long address, int defaultMode)
Create an entry-point from a provided native address.
| ||||||||||
abstract int |
getDefaultMode()
Get the default processor mode.
| ||||||||||
abstract Endianness |
getEndianness()
Get the endianness this processor operates in.
| ||||||||||
abstract int |
getGPRegisterBitsize()
Retrieve the size of a General Purpose register, in bits.
| ||||||||||
abstract int |
getInstructionAlignment()
Retrieve the instruction alignment, in bytes.
| ||||||||||
abstract int |
getMode()
Get the processor mode.
| ||||||||||
abstract int |
getPCRegisterBitsize()
Retrieve the size of the Program Counter register, in bits.
| ||||||||||
abstract IRegisterBank | getRegisterBank() | ||||||||||
abstract String |
getRegisterName(long registerCode)
Retrieve the string name of a register by its internal register code.
| ||||||||||
abstract ICodeResolver<InsnType> |
getResolver()
Retrieve a code resolver.
| ||||||||||
abstract Collection<Integer> |
getSupportedModes()
Get the list of valid modes that this processor supports.
| ||||||||||
abstract Collection<ProcessorVariant> |
getSupportedVariants()
Retrieve a list of supported processor variants.
| ||||||||||
abstract ProcessorType |
getType()
Retrieve the processor type.
| ||||||||||
abstract ProcessorVariant |
getVariant()
Get the processor variant used by this object.
| ||||||||||
abstract boolean |
isRISC()
Provide a hint about the instruction set architecture.
| ||||||||||
abstract InsnType |
parseAt(byte[] bytes, int index, int end)
Parse a single instruction.
| ||||||||||
abstract InsnType |
parseAt(IVirtualMemory vm, long address)
Parse a single instruction at the specified address in memory.
| ||||||||||
abstract InsnType |
parseWithContext(IMachineContext context)
Parse a single instruction given a machine context.
| ||||||||||
abstract void |
setEndianness(Endianness endianness)
Set the endianness of this processor.
| ||||||||||
abstract void |
setInstructionAlignment(int align)
Set the instruction alignment, in bytes.
| ||||||||||
abstract int |
setMode(int newMode)
Set the processor mode.
| ||||||||||
abstract void |
setVariant(ProcessorVariant variant)
Set the new variant used by this processor.
|
Convenience constant. Processor mode constant for 128-bit processors
Convenience constant. Processor mode constant for 16-bit processors
Convenience constant. Processor mode constant for 256-bit processors
Convenience constant. Processor mode constant for 32-bit processors
Convenience constant. Processor mode constant for 64-bit processors
Convenience constant. Processor mode constant for 8-bit processors
Default processor mode constant (unknown or standard mode)
Invalid processor mode, do not use
Create an entry-point from a provided native address.
address | address of the instruction |
---|
Create an entry-point from a provided native address.
address | address of the instruction |
---|---|
defaultMode | default processor mode if it cannot be determined by address |
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).
MODE_DEFAULT
(0)
Retrieve the size of a General Purpose register, in bits.
Retrieve the instruction alignment, in bytes.
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.
MODE_DEFAULT
(0)
Retrieve the size of the Program Counter register, in bits.
Retrieve the string name of a register by its internal register code.
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 |
---|
Retrieve a code resolver. A resolver is optional; implementors may decide to not provide one, and return null.
Get the list of valid modes that this processor supports.
Retrieve a list of supported processor variants.
Retrieve the processor type. The type depends on the current execution
mode
. A processor class may implement several modes, mapping to various processor types.
Provide a hint about the instruction set architecture.
Parse a single instruction.
bytes | input code buffer |
---|---|
index | where to parse in the input buffer |
end | exclusive end offset in the buffer: if parsing at the given index offset requires bytes past the end offset, an exception is raised |
ProcessorException | on parsing error |
---|---|
RuntimeException | on miscellaneous error |
Parse a single instruction at the specified address in memory.
vm | the input virtual memory |
---|---|
address | the address to read at, with permission of read+write |
ProcessorException | on parsing error |
---|---|
RuntimeException | on miscellaneous error |
Parse a single instruction given a machine context. The context provides access to at least:
ProcessorException |
---|
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
.
align | the alignment, must be a strictly positive power of 2 |
---|
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.
newMode | the mode, the value MODE_DEFAULT (0) can be provided to revert to the
default processor mode |
---|
ProcessorException | if the mode is not supported |
---|
Set the new variant used by this processor.
ProcessorException | if the variant is not supported |
---|