1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:47:44 +00:00

LibX86: Only pass ProcessorMode to Instruction constructor

We previously passed both OperandSize and AddressSize to the
constructor.

Both values were only ever 32-bit at construction.
We used AddressSize::Size64 to signify Long mode which was needlessly
complicated.
This commit is contained in:
Itamar 2022-12-10 20:00:09 +02:00 committed by Andreas Kling
parent 9a136e354d
commit 108a8e4c88
3 changed files with 14 additions and 19 deletions

View file

@ -234,7 +234,7 @@ int Emulator::exec()
while (!m_shutdown) {
if (m_steps_til_pause) [[likely]] {
m_cpu->save_base_eip();
auto insn = X86::Instruction::from_stream(*m_cpu, X86::OperandSize::Size32, X86::AddressSize::Size32);
auto insn = X86::Instruction::from_stream(*m_cpu, X86::ProcessorMode::Protected);
// Exec cycle
if constexpr (trace) {
outln("{:p} \033[33;1m{}\033[0m", m_cpu->base_eip(), insn.to_deprecated_string(m_cpu->base_eip(), symbol_provider));
@ -301,7 +301,7 @@ void Emulator::handle_repl()
// FIXME: Function names (base, call, jump)
auto saved_eip = m_cpu->eip();
m_cpu->save_base_eip();
auto insn = X86::Instruction::from_stream(*m_cpu, X86::OperandSize::Size32, X86::AddressSize::Size32);
auto insn = X86::Instruction::from_stream(*m_cpu, X86::ProcessorMode::Protected);
// FIXME: This does not respect inlining
// another way of getting the current function is at need
if (auto symbol = symbol_at(m_cpu->base_eip()); symbol.has_value()) {
@ -311,7 +311,7 @@ void Emulator::handle_repl()
outln("==> {}", create_instruction_line(m_cpu->base_eip(), insn));
for (int i = 0; i < 7; ++i) {
m_cpu->save_base_eip();
insn = X86::Instruction::from_stream(*m_cpu, X86::OperandSize::Size32, X86::AddressSize::Size32);
insn = X86::Instruction::from_stream(*m_cpu, X86::ProcessorMode::Protected);
outln(" {}", create_instruction_line(m_cpu->base_eip(), insn));
}
// We don't want to increase EIP here, we just want the instructions