1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:57:35 +00:00

LibX86: Expose some more things on X86::Instruction

This commit is contained in:
Andreas Kling 2020-07-07 21:12:40 +02:00
parent 7ab2a4dde7
commit 6440e59ead
2 changed files with 15 additions and 2 deletions

View file

@ -1906,4 +1906,10 @@ void MemoryOrRegisterReference::decode32(InstructionStream& stream)
}
}
InstructionHandler Instruction::handler() const
{
ASSERT(m_descriptor->handler);
return m_descriptor->handler;
}
}

View file

@ -198,6 +198,8 @@ public:
String to_string_mm() const;
bool is_register() const { return m_register_index != 0xffffffff; }
unsigned register_index() const { return m_register_index; }
SegmentRegister segment() const
{
ASSERT(!is_register());
@ -237,17 +239,22 @@ private:
bool m_has_sib { false };
};
class Interpreter;
typedef void (Interpreter::*InstructionHandler)(const Instruction&);
class Instruction {
public:
static Instruction from_stream(InstructionStream&, bool o32, bool a32);
~Instruction() {}
MemoryOrRegisterReference& modrm()
MemoryOrRegisterReference& modrm() const
{
ASSERT(has_rm());
return m_modrm;
}
InstructionHandler handler() const;
bool has_segment_prefix() const { return m_segment_prefix != SegmentRegister::None; }
bool has_address_size_override_prefix() const { return m_has_address_size_override_prefix; }
bool has_operand_size_override_prefix() const { return m_has_operand_size_override_prefix; }
@ -350,7 +357,7 @@ private:
bool m_has_address_size_override_prefix { false };
u8 m_rep_prefix { 0 };
MemoryOrRegisterReference m_modrm;
mutable MemoryOrRegisterReference m_modrm;
InstructionDescriptor* m_descriptor { nullptr };
};