mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:47:44 +00:00
LibX86: Store Instruction's segment prefix as Optional<SegmentRegister>
Instead of having a dedicated enum value for the empty state.
This commit is contained in:
parent
f1801cfb28
commit
3a1cf9505d
2 changed files with 11 additions and 9 deletions
|
@ -867,7 +867,7 @@ unsigned Instruction::length() const
|
|||
return len;
|
||||
}
|
||||
|
||||
static SegmentRegister to_segment_prefix(u8 op)
|
||||
static Optional<SegmentRegister> to_segment_prefix(u8 op)
|
||||
{
|
||||
switch (op) {
|
||||
case 0x26:
|
||||
|
@ -883,7 +883,7 @@ static SegmentRegister to_segment_prefix(u8 op)
|
|||
case 0x65:
|
||||
return SegmentRegister::GS;
|
||||
default:
|
||||
return SegmentRegister::None;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -912,7 +912,7 @@ Instruction::Instruction(InstructionStream& stream, bool o32, bool a32)
|
|||
continue;
|
||||
}
|
||||
auto segment_prefix = to_segment_prefix(opbyte);
|
||||
if (segment_prefix != SegmentRegister::None) {
|
||||
if (segment_prefix.has_value()) {
|
||||
m_segment_prefix = segment_prefix;
|
||||
continue;
|
||||
}
|
||||
|
@ -1269,8 +1269,8 @@ String Instruction::to_string(u32 origin, const SymbolProvider* symbol_provider,
|
|||
String osize_prefix;
|
||||
String rep_prefix;
|
||||
String lock_prefix;
|
||||
if (has_segment_prefix()) {
|
||||
segment_prefix = String::format("%s: ", register_name(m_segment_prefix));
|
||||
if (m_segment_prefix.has_value()) {
|
||||
segment_prefix = String::format("%s: ", register_name(m_segment_prefix.value()));
|
||||
}
|
||||
if (has_address_size_override_prefix()) {
|
||||
asize_prefix = m_a32 ? "a32 " : "a16 ";
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
|
@ -75,7 +76,6 @@ enum class SegmentRegister {
|
|||
GS,
|
||||
SegR6,
|
||||
SegR7,
|
||||
None = 0xFF,
|
||||
};
|
||||
|
||||
enum RegisterIndex8 {
|
||||
|
@ -223,7 +223,7 @@ private:
|
|||
void decode32(InstructionStream&);
|
||||
|
||||
unsigned m_register_index { 0xffffffff };
|
||||
SegmentRegister m_segment { SegmentRegister::None };
|
||||
SegmentRegister m_segment;
|
||||
union {
|
||||
u32 m_offset32 { 0 };
|
||||
u16 m_offset16;
|
||||
|
@ -259,7 +259,9 @@ public:
|
|||
|
||||
InstructionHandler handler() const;
|
||||
|
||||
bool has_segment_prefix() const { return m_segment_prefix != SegmentRegister::None; }
|
||||
bool has_segment_prefix() const { return m_segment_prefix.has_value(); }
|
||||
Optional<SegmentRegister> segment_prefix() const { return m_segment_prefix; }
|
||||
|
||||
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; }
|
||||
bool has_lock_prefix() const { return m_has_lock_prefix; }
|
||||
|
@ -360,7 +362,7 @@ private:
|
|||
unsigned m_imm2_bytes { 0 };
|
||||
unsigned m_prefix_bytes { 0 };
|
||||
|
||||
SegmentRegister m_segment_prefix { SegmentRegister::None };
|
||||
Optional<SegmentRegister> m_segment_prefix;
|
||||
bool m_has_operand_size_override_prefix { false };
|
||||
bool m_has_address_size_override_prefix { false };
|
||||
u8 m_rep_prefix { 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue