mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Adds a presently-unreachable step for SIB consumption.
This commit is contained in:
parent
30b355fd6f
commit
4d2e8cd71d
@ -637,6 +637,14 @@ std::pair<int, InstructionSet::x86::Instruction> Decoder::decode(const uint8_t *
|
|||||||
phase_ = (displacement_size_ + operand_size_) ? Phase::DisplacementOrOperand : Phase::ReadyToPost;
|
phase_ = (displacement_size_ + operand_size_) ? Phase::DisplacementOrOperand : Phase::ReadyToPost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - ScaleIndexBase
|
||||||
|
|
||||||
|
if(phase_ == Phase::ScaleIndexBase && source != end) {
|
||||||
|
sib_ = *source;
|
||||||
|
++source;
|
||||||
|
++consumed_;
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Displacement and operand.
|
// MARK: - Displacement and operand.
|
||||||
|
|
||||||
if(phase_ == Phase::DisplacementOrOperand && source != end) {
|
if(phase_ == Phase::DisplacementOrOperand && source != end) {
|
||||||
|
@ -53,6 +53,8 @@ class Decoder {
|
|||||||
/// Receives a ModRegRM byte and either populates the source_ and dest_ fields appropriately
|
/// Receives a ModRegRM byte and either populates the source_ and dest_ fields appropriately
|
||||||
/// or completes decoding of the instruction, as per the instruction format.
|
/// or completes decoding of the instruction, as per the instruction format.
|
||||||
ModRegRM,
|
ModRegRM,
|
||||||
|
/// Awaits n 80386+-style scale-index-base byte ('SIB'), indicating the form of indirect addressing.
|
||||||
|
ScaleIndexBase,
|
||||||
/// Waits for sufficiently many bytes to pass for the required displacement and operand to be captured.
|
/// Waits for sufficiently many bytes to pass for the required displacement and operand to be captured.
|
||||||
/// Cf. displacement_size_ and operand_size_.
|
/// Cf. displacement_size_ and operand_size_.
|
||||||
DisplacementOrOperand,
|
DisplacementOrOperand,
|
||||||
@ -143,6 +145,9 @@ class Decoder {
|
|||||||
uint16_t operand_ = 0;
|
uint16_t operand_ = 0;
|
||||||
uint64_t inward_data_ = 0;
|
uint64_t inward_data_ = 0;
|
||||||
|
|
||||||
|
// Indirection style.
|
||||||
|
uint8_t sib_;
|
||||||
|
|
||||||
// Facts about the instruction.
|
// Facts about the instruction.
|
||||||
int displacement_size_ = 0; // i.e. size of in-stream displacement, if any.
|
int displacement_size_ = 0; // i.e. size of in-stream displacement, if any.
|
||||||
int operand_size_ = 0; // i.e. size of in-stream operand, if any.
|
int operand_size_ = 0; // i.e. size of in-stream operand, if any.
|
||||||
|
@ -319,7 +319,7 @@ enum class Size: uint8_t {
|
|||||||
|
|
||||||
enum class Source: uint8_t {
|
enum class Source: uint8_t {
|
||||||
// These are in SIB order; this matters for packing later on.
|
// These are in SIB order; this matters for packing later on.
|
||||||
// Whether each refers to e.g. EAX or AX depends on the
|
// Whether each refers to e.g. EAX, AX or AL depends on the
|
||||||
// instruction's data size.
|
// instruction's data size.
|
||||||
eAX, eCX, eDX, eBX, eSP, eBP, eSI, eDI,
|
eAX, eCX, eDX, eBX, eSP, eBP, eSI, eDI,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user