mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-09 05:25:01 +00:00
Ensure ScaleIndexBase
can be used constexpr
; add note-to-self on indexing table.
This commit is contained in:
@@ -440,6 +440,17 @@ std::pair<int, InstructionSet::x86::Instruction> Decoder::decode(const uint8_t *
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
default: {
|
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] = {
|
constexpr Source rm_table[8] = {
|
||||||
Source::IndBXPlusSI, Source::IndBXPlusDI,
|
Source::IndBXPlusSI, Source::IndBXPlusDI,
|
||||||
Source::IndBPPlusSI, Source::IndBPPlusDI,
|
Source::IndBPPlusSI, Source::IndBPPlusDI,
|
||||||
|
@@ -364,17 +364,17 @@ enum class Repetition: uint8_t {
|
|||||||
/// even though it is a superset of that supported prior to the 80386.
|
/// even though it is a superset of that supported prior to the 80386.
|
||||||
class ScaleIndexBase {
|
class ScaleIndexBase {
|
||||||
public:
|
public:
|
||||||
ScaleIndexBase() {}
|
constexpr ScaleIndexBase() noexcept {}
|
||||||
ScaleIndexBase(uint8_t sib) : sib_(sib) {}
|
constexpr ScaleIndexBase(uint8_t sib) noexcept : 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(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().
|
/// @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;
|
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.
|
/// @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[] = {
|
constexpr Source sources[] = {
|
||||||
Source::eAX, Source::eCX, Source::eDX, Source::eBX, Source::None, Source::eBP, Source::eSI, Source::eDI,
|
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.
|
/// @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);
|
return Source(sib_ & 0x7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user