mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +00:00
Ensure ScaleIndexBase
can be used constexpr
; add note-to-self on indexing table.
This commit is contained in:
parent
63d8a88e2f
commit
546b4edbf1
@ -440,6 +440,17 @@ std::pair<int, InstructionSet::x86::Instruction> 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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user