diff --git a/InstructionSets/x86/Decoder.cpp b/InstructionSets/x86/Decoder.cpp index a08e6fc82..458facbea 100644 --- a/InstructionSets/x86/Decoder.cpp +++ b/InstructionSets/x86/Decoder.cpp @@ -440,6 +440,17 @@ std::pair Decoder::decode(const uint8_t * } break; default: { + // TODO: switch to this table. +// constexpr ScaleIndexBase rm_table[8] = { +// ScaleIndexBase(0, Source::eBX, Source::eSI), +// ScaleIndexBase(0, Source::eBX, Source::eDI), +// ScaleIndexBase(0, Source::eBP, Source::eSI), +// ScaleIndexBase(0, Source::eBP, Source::eDI), +// ScaleIndexBase(0, Source::None, Source::eSI), +// ScaleIndexBase(0, Source::None, Source::eDI), +// ScaleIndexBase(0, Source::None, Source::eBP), +// ScaleIndexBase(0, Source::None, Source::eBX), +// }; constexpr Source rm_table[8] = { Source::IndBXPlusSI, Source::IndBXPlusDI, Source::IndBPPlusSI, Source::IndBPPlusDI, diff --git a/InstructionSets/x86/Instruction.hpp b/InstructionSets/x86/Instruction.hpp index 31e6725be..23259c27d 100644 --- a/InstructionSets/x86/Instruction.hpp +++ b/InstructionSets/x86/Instruction.hpp @@ -364,17 +364,17 @@ enum class Repetition: uint8_t { /// even though it is a superset of that supported prior to the 80386. class ScaleIndexBase { public: - ScaleIndexBase() {} - ScaleIndexBase(uint8_t sib) : sib_(sib) {} - ScaleIndexBase(int scale, Source index, Source base) : sib_(uint8_t(scale << 6 | (int(index != Source::None ? index : Source::eSI) << 3) | int(base))) {} + constexpr ScaleIndexBase() noexcept {} + constexpr ScaleIndexBase(uint8_t sib) noexcept : sib_(sib) {} + constexpr ScaleIndexBase(int scale, Source index, Source base) noexcept : sib_(uint8_t(scale << 6 | (int(index != Source::None ? index : Source::eSI) << 3) | int(base))) {} /// @returns the power of two by which to multiply @c index() before adding it to @c base(). - int scale() const { + constexpr int scale() const { return sib_ >> 6; } /// @returns the @c index for this address; this is guaranteed to be one of eAX, eBX, eCX, eDX, None, eBP, eSI or eDI. - Source index() const { + constexpr Source index() const { constexpr Source sources[] = { Source::eAX, Source::eCX, Source::eDX, Source::eBX, Source::None, Source::eBP, Source::eSI, Source::eDI, }; @@ -383,7 +383,7 @@ class ScaleIndexBase { } /// @returns the @c base for this address; this is guaranteed to be one of eAX, eBX, eCX, eDX, eSP, eBP, eSI or eDI. - Source base() const { + constexpr Source base() const { return Source(sib_ & 0x7); }