mirror of
https://github.com/TomHarte/CLK.git
synced 2024-10-11 08:23:43 +00:00
Edges closer towards full x86 recording.
This commit is contained in:
parent
86577b772b
commit
97a64db5e0
@ -82,9 +82,9 @@ struct Instruction {
|
|||||||
bool is_supervisor = false;
|
bool is_supervisor = false;
|
||||||
uint32_t opcode = 0;
|
uint32_t opcode = 0;
|
||||||
|
|
||||||
Instruction() {}
|
Instruction() noexcept {}
|
||||||
Instruction(uint32_t opcode) : opcode(opcode) {}
|
Instruction(uint32_t opcode) noexcept : opcode(opcode) {}
|
||||||
Instruction(Operation operation, uint32_t opcode, bool is_supervisor = false) : operation(operation), is_supervisor(is_supervisor), opcode(opcode) {}
|
Instruction(Operation operation, uint32_t opcode, bool is_supervisor = false) noexcept : operation(operation), is_supervisor(is_supervisor), opcode(opcode) {}
|
||||||
|
|
||||||
// Instruction fields are decoded below; naming is a compromise between
|
// Instruction fields are decoded below; naming is a compromise between
|
||||||
// Motorola's documentation and IBM's.
|
// Motorola's documentation and IBM's.
|
||||||
@ -192,6 +192,8 @@ struct Instruction {
|
|||||||
uint32_t oe() const { return opcode & 0x800; }
|
uint32_t oe() const { return opcode & 0x800; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static_assert(sizeof(Instruction) <= 8);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Implements PowerPC instruction decoding.
|
Implements PowerPC instruction decoding.
|
||||||
|
|
||||||
|
@ -541,8 +541,8 @@ std::pair<int, Instruction> Decoder::decode(const uint8_t *source, size_t length
|
|||||||
segment_override_,
|
segment_override_,
|
||||||
repetition_,
|
repetition_,
|
||||||
Size(operation_size_),
|
Size(operation_size_),
|
||||||
0,
|
displacement_,
|
||||||
0)
|
operand_)
|
||||||
);
|
);
|
||||||
reset_parsing();
|
reset_parsing();
|
||||||
phase_ = Phase::Instruction;
|
phase_ = Phase::Instruction;
|
||||||
|
@ -134,7 +134,7 @@ class Instruction {
|
|||||||
uint16_t sources_ = 0;
|
uint16_t sources_ = 0;
|
||||||
|
|
||||||
// Unpackable fields.
|
// Unpackable fields.
|
||||||
uint16_t displacement_ = 0;
|
int16_t displacement_ = 0;
|
||||||
uint16_t operand_ = 0; // ... or used to store a segment for far operations.
|
uint16_t operand_ = 0; // ... or used to store a segment for far operations.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -148,10 +148,10 @@ class Instruction {
|
|||||||
|
|
||||||
uint16_t segment() const { return uint16_t(operand_); }
|
uint16_t segment() const { return uint16_t(operand_); }
|
||||||
|
|
||||||
template <typename type> type displacement();
|
int16_t displacement() const { return displacement_; }
|
||||||
template <typename type> type immediate();
|
uint16_t operand() const { return operand_; }
|
||||||
|
|
||||||
Instruction() {}
|
Instruction() noexcept {}
|
||||||
Instruction(
|
Instruction(
|
||||||
Operation operation,
|
Operation operation,
|
||||||
Source source,
|
Source source,
|
||||||
@ -160,8 +160,8 @@ class Instruction {
|
|||||||
Source segment_override,
|
Source segment_override,
|
||||||
Repetition repetition,
|
Repetition repetition,
|
||||||
Size operation_size,
|
Size operation_size,
|
||||||
uint16_t displacement,
|
int16_t displacement,
|
||||||
uint16_t operand) :
|
uint16_t operand) noexcept :
|
||||||
operation(operation),
|
operation(operation),
|
||||||
repetition_size_(uint8_t((int(operation_size) << 2) | int(repetition))),
|
repetition_size_(uint8_t((int(operation_size) << 2) | int(repetition))),
|
||||||
sources_(uint16_t(
|
sources_(uint16_t(
|
||||||
@ -264,6 +264,10 @@ struct Decoder {
|
|||||||
Source source_ = Source::None;
|
Source source_ = Source::None;
|
||||||
Source destination_ = Source::None;
|
Source destination_ = Source::None;
|
||||||
|
|
||||||
|
// Immediate fields.
|
||||||
|
int16_t displacement_ = 0;
|
||||||
|
uint16_t operand_ = 0;
|
||||||
|
|
||||||
// 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.
|
||||||
|
Loading…
Reference in New Issue
Block a user