1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-04 18:29:40 +00:00

Adds a presently-unreachable step for SIB consumption.

This commit is contained in:
Thomas Harte 2022-02-19 18:00:27 -05:00
parent 30b355fd6f
commit 4d2e8cd71d
3 changed files with 14 additions and 1 deletions

View File

@ -637,6 +637,14 @@ std::pair<int, InstructionSet::x86::Instruction> Decoder::decode(const uint8_t *
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.
if(phase_ == Phase::DisplacementOrOperand && source != end) {

View File

@ -53,6 +53,8 @@ class Decoder {
/// Receives a ModRegRM byte and either populates the source_ and dest_ fields appropriately
/// or completes decoding of the instruction, as per the instruction format.
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.
/// Cf. displacement_size_ and operand_size_.
DisplacementOrOperand,
@ -143,6 +145,9 @@ class Decoder {
uint16_t operand_ = 0;
uint64_t inward_data_ = 0;
// Indirection style.
uint8_t sib_;
// Facts about the instruction.
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.

View File

@ -319,7 +319,7 @@ enum class Size: uint8_t {
enum class Source: uint8_t {
// 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.
eAX, eCX, eDX, eBX, eSP, eBP, eSI, eDI,