diff --git a/Processors/Decoders/PowerPC/PowerPC.hpp b/Processors/Decoders/PowerPC/PowerPC.hpp index e5f086653..20b9184de 100644 --- a/Processors/Decoders/PowerPC/PowerPC.hpp +++ b/Processors/Decoders/PowerPC/PowerPC.hpp @@ -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. diff --git a/Processors/Decoders/x86/x86.cpp b/Processors/Decoders/x86/x86.cpp index 635523ed5..68f5a0267 100644 --- a/Processors/Decoders/x86/x86.cpp +++ b/Processors/Decoders/x86/x86.cpp @@ -541,8 +541,8 @@ std::pair Decoder::decode(const uint8_t *source, size_t length segment_override_, repetition_, Size(operation_size_), - 0, - 0) + displacement_, + operand_) ); reset_parsing(); phase_ = Phase::Instruction; diff --git a/Processors/Decoders/x86/x86.hpp b/Processors/Decoders/x86/x86.hpp index 5efba12fd..aaab81365 100644 --- a/Processors/Decoders/x86/x86.hpp +++ b/Processors/Decoders/x86/x86.hpp @@ -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 type displacement(); - template 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.