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

Edges closer towards full x86 recording.

This commit is contained in:
Thomas Harte 2021-01-08 22:38:56 -05:00
parent 86577b772b
commit 97a64db5e0
3 changed files with 17 additions and 11 deletions

View File

@ -82,9 +82,9 @@ struct Instruction {
bool is_supervisor = false;
uint32_t opcode = 0;
Instruction() {}
Instruction(uint32_t opcode) : opcode(opcode) {}
Instruction(Operation operation, uint32_t opcode, bool is_supervisor = false) : operation(operation), is_supervisor(is_supervisor), opcode(opcode) {}
Instruction() noexcept {}
Instruction(uint32_t opcode) noexcept : 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
// Motorola's documentation and IBM's.
@ -192,6 +192,8 @@ struct Instruction {
uint32_t oe() const { return opcode & 0x800; }
};
static_assert(sizeof(Instruction) <= 8);
/*!
Implements PowerPC instruction decoding.

View File

@ -541,8 +541,8 @@ std::pair<int, Instruction> Decoder::decode(const uint8_t *source, size_t length
segment_override_,
repetition_,
Size(operation_size_),
0,
0)
displacement_,
operand_)
);
reset_parsing();
phase_ = Phase::Instruction;

View File

@ -134,7 +134,7 @@ class Instruction {
uint16_t sources_ = 0;
// Unpackable fields.
uint16_t displacement_ = 0;
int16_t displacement_ = 0;
uint16_t operand_ = 0; // ... or used to store a segment for far operations.
public:
@ -148,10 +148,10 @@ class Instruction {
uint16_t segment() const { return uint16_t(operand_); }
template <typename type> type displacement();
template <typename type> type immediate();
int16_t displacement() const { return displacement_; }
uint16_t operand() const { return operand_; }
Instruction() {}
Instruction() noexcept {}
Instruction(
Operation operation,
Source source,
@ -160,8 +160,8 @@ class Instruction {
Source segment_override,
Repetition repetition,
Size operation_size,
uint16_t displacement,
uint16_t operand) :
int16_t displacement,
uint16_t operand) noexcept :
operation(operation),
repetition_size_(uint8_t((int(operation_size) << 2) | int(repetition))),
sources_(uint16_t(
@ -264,6 +264,10 @@ struct Decoder {
Source source_ = Source::None;
Source destination_ = Source::None;
// Immediate fields.
int16_t displacement_ = 0;
uint16_t operand_ = 0;
// 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.