mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-27 15:29:34 +00:00
Marks intent for operand/displacement.
This commit is contained in:
parent
97a64db5e0
commit
68fe16a092
@ -254,7 +254,7 @@ std::pair<int, Instruction> Decoder::decode(const uint8_t *source, size_t length
|
|||||||
modregrm_format_ = ModRegRMFormat::MemRegROL_to_SAR;
|
modregrm_format_ = ModRegRMFormat::MemRegROL_to_SAR;
|
||||||
operation_size_ = 1 + (instr_ & 1);
|
operation_size_ = 1 + (instr_ & 1);
|
||||||
source_ = Source::Immediate;
|
source_ = Source::Immediate;
|
||||||
// TODO: set operand to 1.
|
operand_ = 1;
|
||||||
break;
|
break;
|
||||||
case 0xd2: case 0xd3:
|
case 0xd2: case 0xd3:
|
||||||
phase_ = Phase::ModRegRM;
|
phase_ = Phase::ModRegRM;
|
||||||
@ -512,14 +512,20 @@ std::pair<int, Instruction> Decoder::decode(const uint8_t *source, size_t length
|
|||||||
// MARK: - Displacement and operand.
|
// MARK: - Displacement and operand.
|
||||||
|
|
||||||
if(phase_ == Phase::AwaitingDisplacementOrOperand && source != end) {
|
if(phase_ == Phase::AwaitingDisplacementOrOperand && source != end) {
|
||||||
// TODO: calculate number of expected operands.
|
|
||||||
const int required_bytes = displacement_size_ + operand_size_;
|
const int required_bytes = displacement_size_ + operand_size_;
|
||||||
|
|
||||||
|
if(!required_bytes) {
|
||||||
|
phase_ = Phase::ReadyToPost;
|
||||||
|
} else {
|
||||||
const int outstanding_bytes = required_bytes - operand_bytes_;
|
const int outstanding_bytes = required_bytes - operand_bytes_;
|
||||||
const int bytes_to_consume = std::min(int(end - source), outstanding_bytes);
|
const int bytes_to_consume = std::min(int(end - source), outstanding_bytes);
|
||||||
|
|
||||||
|
// TODO: fill displacement_ and operand_ here... efficiently?
|
||||||
|
|
||||||
source += bytes_to_consume;
|
source += bytes_to_consume;
|
||||||
consumed_ += bytes_to_consume;
|
consumed_ += bytes_to_consume;
|
||||||
operand_bytes_ += bytes_to_consume;
|
operand_bytes_ += bytes_to_consume;
|
||||||
|
|
||||||
if(bytes_to_consume == outstanding_bytes) {
|
if(bytes_to_consume == outstanding_bytes) {
|
||||||
phase_ = Phase::ReadyToPost;
|
phase_ = Phase::ReadyToPost;
|
||||||
} else {
|
} else {
|
||||||
@ -527,6 +533,7 @@ std::pair<int, Instruction> Decoder::decode(const uint8_t *source, size_t length
|
|||||||
return std::make_pair(-(outstanding_bytes - bytes_to_consume), Instruction());
|
return std::make_pair(-(outstanding_bytes - bytes_to_consume), Instruction());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Check for completion.
|
// MARK: - Check for completion.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user