Andreas Kling
036ce64cef
LibX86: Don't cache whether instruction have a sub-opcode
...
We can just check if the first opcode byte is 0x0f to know this.
2020-07-15 13:42:15 +02:00
Andreas Kling
6a926a8c61
LibX86+UserspaceEmulator: Don't store a32 in MemoryOrRegisterReference
...
The a32 bit tells us whether a memory address is 32-bit or not.
We already have this information in Instruction, so just plumb that
around instead of double-caching the bit.
2020-07-15 13:42:15 +02:00
Andreas Kling
bc66221ee3
LibX86: Don't store the prefix/imm1/imm2 byte counts individually
...
We can shrink and simplify Instruction a bit by combining these into
a single "extra bytes" count.
2020-07-15 13:42:15 +02:00
Andreas Kling
4f8e86ad67
LibX86: Remove Instruction::m_handler
...
We can fetch the handler via Instruction::m_descriptor.
2020-07-15 13:42:15 +02:00
Andreas Kling
ef84865c8c
LibX86+UserspaceEmulator: Devirtualize and inline more instruction code
...
Use some template hacks to force GCC to inline more of the instruction
decoding stuff into the UserspaceEmulator main execution loop.
This is my last optimization for today, and we've gone from ~60 seconds
when running "UserspaceEmulator UserspaceEmulator id" to ~8 seconds :^)
2020-07-13 21:00:51 +02:00
Andreas Kling
7ea36f5ed0
LibX86: Don't build_opcode_table_if_needed() every instruction decode
...
Instead, just do this once at startup. :^)
2020-07-13 20:42:37 +02:00
Andreas Kling
868db2313f
LibX86: Apply aggressive inlining to Instruction decoding functions
...
These functions really benefit from being inlined together instead
of being separated.
This yields roughly a ~2x speedup.
2020-07-13 20:34:54 +02:00
Andreas Kling
f1bbc39148
LibX86: ALWAYS_INLINE some Instruction members
2020-07-13 13:50:22 +02:00
Andreas Kling
97f4cebc8d
UserspaceEmulator+LibX86: Implement the LEA instruction
...
This piggybacks nicely on Instruction's ModR/M resolution code. :^)
2020-07-11 23:57:14 +02:00
Andreas Kling
0cf7fd5268
UserspaceEmulator+LibX86: Implement all the forms of XOR
...
And they're all generic, which will make it easy to support more ops.
2020-07-10 20:20:27 +02:00
Andreas Kling
45bfdd0063
LibX86: Add a templatized way to resolve ModR/M memory references
...
Hopefully this will be flexible enough for our SoftCPU. :^)
2020-07-10 20:20:27 +02:00
Andreas Kling
3a1cf9505d
LibX86: Store Instruction's segment prefix as Optional<SegmentRegister>
...
Instead of having a dedicated enum value for the empty state.
2020-07-10 20:20:27 +02:00
Andreas Kling
4d8683b632
UserspaceEmulator: Tidy up SoftCPU's general purpose registers
...
This patch adds a PartAddressableRegister type, which divides a 32-bit
value into separate parts needed for the EAX/AX/AL/AH register splits.
Clean up the code around register access to make it a little less
cumbersome to use.
2020-07-09 23:27:50 +02:00
Andreas Kling
6440e59ead
LibX86: Expose some more things on X86::Instruction
2020-07-07 22:44:58 +02:00
Andreas Kling
3cdf4cd204
LibX86: Use MakeUnsigned<T> from AK instead of making a custom one
2020-04-15 16:58:46 +02:00
Andreas Kling
e880e4c2d2
LibX86: Add a way for Instruction::to_string() to symbolicate addresses
...
This patch adds a pure virtual X86::SymbolProvider that can be passed
to Instruction::to_string(). If the instruction contains what appears
to be a program address, stringification will try to symbolicate that
address via the SymbolProvider.
This makes it possible (and very flexible) to add symbolication to
clients of the disassembler. :^)
2020-04-12 14:20:04 +02:00
Andreas Kling
1924112d7d
LibX86: Tolerate invalid segment register indices when disassembling
...
While #6 and #7 are not valid segment register, they can still be
encoded in otherwise-valid instructions, so let's tolerate it.
2020-04-11 14:00:20 +02:00
Andreas Kling
2ce38d4699
LibX86: Support decoding basic MMX instructions like MOVQ
2020-04-11 13:42:18 +02:00
Andreas Kling
e5cde0082a
LibX86: Run the instruction decoder in 32-bit mode by default
...
Let's assume a 32-bit execution environment unless otherwise specified.
2020-04-11 13:24:55 +02:00
Andreas Kling
32d83fdee4
LibX86: Add an X86 instruction decoder library + basic disassembler
...
This will be very useful for developer tools like ProfileView, and also
for future tools like debuggers and such. :^)
2020-04-11 13:16:17 +02:00