Commit graph

66 commits

Author SHA1 Message Date
H. Peter Anvin
39d6ac6f79 Fix display for fixed xmm0/ymm0, SSE redundant prefixes
All singleton registers need to be displayable from register flags
alone!

When using the new 0360..0363 codes, make sure we appropriate avoid
displaying the legacy use of the prefixes.
2008-05-21 10:33:19 -07:00
H. Peter Anvin
6b3b7bcd33 VEX prefixes apply to VEX instructions only... 2008-05-20 23:36:36 -07:00
H. Peter Anvin
52dc353868 Handle is4 bytes without meaningful information in the bottom bits
Support is4 bytes without meaningful information in the bottom bits.
This is equivalent to /is4=0 for the assembler, but makes the bottom
bits don't care for the disassembler.
2008-05-20 19:29:04 -07:00
H. Peter Anvin
0ab96a17d5 ndisasm: simple compare for conditional opcodes, no loop
We had a completely unnecessary loop to test for conditional opcodes.
Since we always put the conditional opcodes at the end, we might as
well just remember where that list starts and compare against it.
2008-05-20 17:07:57 -07:00
H. Peter Anvin
a4835d466c Avoid #including .c files; instead compile as separate units
Don't #include .c files, even if they are auto-generated; instead
compile them as separate compilation units and let the linker do its
job.
2008-05-20 14:21:29 -07:00
H. Peter Anvin
dfb918047b Add DY, YWORD, and the SY instruction flag
Add the DY instruction, YWORD keyword, and an SY marker for
instruction sizes.  Add a few more AVX sample instructions.
2008-05-20 11:43:53 -07:00
H. Peter Anvin
fff5a47e65 Same some space by introducing shorthand byte codes for SSE prefixes
Properly done, all SSE instructions which has the 66/F2/F3 opcode
multiplex need two prefixes: one to control the use of OSP and one to
control the use of REP.  However, it's a four-way select: np/66/F2/F3;
so introduce shorthand bytecodes for that purpose.
2008-05-20 09:46:24 -07:00
H. Peter Anvin
aaa088fbf3 Remove special hacks to avoid zero bytecodes
We can now have zero bytecodes with impunity, so remove any special
hacks we had to avoid zeroes in the bytecode.
2008-05-12 11:13:41 -07:00
H. Peter Anvin
d58656f797 Add support for register-number immediates with fixed 4-bit values
Add support for imm8 bytes which has a register value in the top four
bits and an arbitrary fixed value in the bottom four bits.
2008-05-06 20:11:14 -07:00
H. Peter Anvin
7334e3ac23 Initial NDISASM support for AVX instructions/VEX prefixes
Initial NDISASM support for AVX instructions and VEX prefixes.  It
doesn't mean it's correct, but it seems to match my current
understanding.  It can disassemble *some*, but not *all*, of the AVX
test cases (which are known to be at least partially incorrect...)
2008-05-05 18:47:27 -07:00
H. Peter Anvin
d85d250fa2 First cut at AVX machinery.
First cut at AVX machinery support.  The only instruction implemented
is VPERMIL2PS, and it's probably buggy.  I'm checking this in with the
hope that other people can start helping out with (a) testing this,
and (b) adding instructions.

NDISASM support is not there yet.
2008-05-04 17:53:31 -07:00
H. Peter Anvin
08367e2231 disasm: relative operands are signed, not unsigned
Relative operands are signed, not unsigned; record them as such and
then apply proper truncation after offset addition.
2008-01-02 12:20:38 -08:00
Beroset
095e6a2973 regularized spelling of license to match name of LICENSE file 2007-12-29 09:44:23 -05:00
H. Peter Anvin
9e9a24253a disasm: 32-bit index registers were displayed as 64 bits
Fix bug where 32-bit index registers got incorrectly displayed as 64
bits:

00000000  678B040B          mov eax,[ebx+rcx]
00000004  678B044B          mov eax,[ebx+rcx*2]
00000008  678B045B          mov eax,[ebx+rbx*2]
2007-12-26 19:10:20 -08:00
H. Peter Anvin
a30cc07224 BR 1834292: Fix multiple disassembler bugs
- Correct the building on the disassembler decision tree.
- Handle SSE instructions with F2 prefix (\332) correctly.
- Mark instructions which are now used as prefixes with ND.
  (In a future version when we have better CPU version handling,
  we should probably build the decision tree at runtime based on
  the selected CPU feature sets.)
- Sanitize the handling of \144-147 and \154-157 in both the assembler
  and disassembler.  They take an opcode byte as argument; don't
  pretend they don't.
2007-11-18 21:55:26 -08:00
H. Peter Anvin
d1fb15c154 Address data is int64_t; simplify writing an address object
Address data is always int64_t even if the size itself is smaller;
this was broken on bigendian hosts (still need testing!)

Create simple "write sized object" macros.
2007-11-13 09:37:59 -08:00
H. Peter Anvin
a5fb90834a ndisasm: factor out the common operand-extraction code
Factor out the common operand-extraction code in the disassembler, as
previously done in the assembler.
2007-11-12 23:00:31 -08:00
H. Peter Anvin
bb72f7f111 Un-special-case "xchg rax,rax"; disassemble o64
Un-special-case "xchg rax,rax"; allow it to be encoded as 48 90 for
orthogonality's sake.  It's a no-op, to be sure, but so are many other
instructions.

"xchg eax,eax" is still special-cased in 64-bit mode since it is not a
no-op; unadorned opcode 90 is now simply "nop" and nothing else.

Make the disassembler detect unused REX.W and display them as an "o64"
prefix.
2007-11-12 22:56:07 -08:00
H. Peter Anvin
e8cdcdcc37 Better (but not *good!*) handling of 64-bit addressing in ndisasm
More correct -- but not fully correct -- handing of 64-bit addressing
in ndisasm.  In particular, we need to generate "a32" versus "dword"
where applicable.
2007-11-12 21:57:00 -08:00
H. Peter Anvin
2344010d26 Fix disassembly of XCHG
"REX.B 90" in 64-bit mode is "xchg eax,r8d" not "nop"; equivalent
situation for "REX.WB 90" (xchg rax,r8).
2007-11-12 21:02:33 -08:00
H. Peter Anvin
de4b89bb3e 64-bit addressing and prefix handling changes
Revamp the address- and prefix-handling code to make more sense in
64-bit mode.  We are now a lot closer to where we want to be, but
we're not quite there yet.

ndisasm may very well have problems, or give counterintuitive output.
However, checking it in so we can make forward progress.
2007-10-28 22:04:00 -07:00
Charles Crayne
f6816b25bf Fix bugs item #1817677 2007-10-23 19:28:39 -07:00
H. Peter Anvin
7065309739 Formatting: kill off "stealth whitespace"
"Stealth whitespace" makes it harder to read diffs, and just generally
cause unwanted weirdness.  Do a source-wide pass to get rid of it.
2007-10-19 14:42:29 -07:00
Charles Crayne
46b31b0f08 Suppress signedness warnings in disassembler 2007-10-18 21:17:20 -07:00
H. Peter Anvin
6867acc18e Use the compiler-provided booleans if available, otherwise emulate
Both C and C++ have "bool", "true" and "false" in lower case; C
requires <stdbool.h> for this, in C++ it is an inherent type built
into the compiler.  Use those instead of the old macros; emulate with
a simple typedef enum if unavailable.
2007-10-10 14:58:45 -07:00
H. Peter Anvin
fe501957c0 Portability fixes
Concentrate compiler dependencies to compiler.h; make sure compiler.h
is included first in every .c file (since some prototypes may depend
on the presence of feature request macros.)

Actually use the conditional inclusion of various functions (totally
broken in previous releases.)
2007-10-02 21:53:51 -07:00
H. Peter Anvin
c5b9ce0a84 Auto-generate 0x67 prefixes without the need for \30x codes
Auto-generate 0x67 prefixes without the need for \30x codes; the
prefix is automatically added when there is a memory operand with
address size differing from the current address size (and impossible
combinations checked for.)
2007-09-22 21:49:51 -07:00
H. Peter Anvin
19e2010536 Speed up the disassembler by allowing prefixed instruction tables
Modify the disassembler so that we can have separate instruction
tables for prefixed instructions.  As it was, all instructions which
started with 0F were linearly searched, and that is by now more than
half the instruction set.
2007-09-18 15:08:20 -07:00
H. Peter Anvin
7786c364b4 Disassembler support for SSE5 instructions
Support for the SSE5 instruction format in the disassembler.

Also adds some comments to insnsd.c for easier debugging.
2007-09-17 18:45:44 -07:00
H. Peter Anvin
7eb4a38793 Initial support for four arguments per instruction
For SSE5, we will need to support four arguments per instruction.
2007-09-17 15:49:30 -07:00
H. Peter Anvin
cb9b690ae6 Add (untested!) SSSE3, SSE4.1, SSE4.2 instructions
Add the SSSE3, SSE4.1 and SSE4.2 instruction sets.  Change \332 to be
a literal 0xF2 prefix, by analog with \333 for 0xF3 prefix (the
previous \332 flag changed to \335).  This is necessary to get the REX
prefix in the right place for instructions that use it.

We are going to have to go in and change existing instruction patterns
which use these, as well.
2007-09-12 21:58:51 -07:00
H. Peter Anvin
0da6b580eb Support r/m operands for non-integer types
Support r/m operands for non-integer operands types, i.e. mmx or xmm
operands.  This allows mmx and xmm operands to be written more
compactly, speeding up the assembler.
2007-09-12 21:04:39 -07:00
H. Peter Anvin
62cb606f68 Handle instructions which can have both REX.W and OSP 2007-09-11 22:44:03 +00:00
H. Peter Anvin
2ba7ed7122 ndisasm: handle \366 codes, prefer unprefixed instructions
- Implement \366 codes in ndisasm
- Prefer instruction patterns without loose prefixes if possible
- Fix improper initialization of operands in ndisasm
2007-09-11 22:13:17 +00:00
H. Peter Anvin
bfb888c015 Quiet gcc warning about uninitialized variables 2007-09-11 04:26:44 +00:00
H. Peter Anvin
3360d79369 Make the big instruction arrays "const"
Make the big instruction arrays "const", so they end up in readonly
storage.  While we're at it, move their prototypes into insns.h.
2007-09-11 04:16:57 +00:00
H. Peter Anvin
99c4ecd18f Implement REL/ABS modifiers
Implement "REL" and "ABS" modifiers for offsets in 64-bit mode.  This
replaces "rip+XXX" type addressing.  The infrastructure to set the default
mode is there, but there is nothing to throw the switch just yet.
2007-08-28 23:06:00 +00:00
H. Peter Anvin
ce2b397f1e Fix the handling of the \313 code.
\313 indicates a fixed 64-bit address size.  It was incorrectly
documented and incorrectly implemented in the assembler, and was
unimplemented in the disassembler.
2007-05-30 22:21:11 +00:00
H. Peter Anvin
3df97a7270 Get rid of magic open-coded "register numbers"
Get rid of magic open-coded register numbers.  We now keep track of
a total of three different kinds of register numbers: the register
enumeration (regs.h), the x86 register value, and the register flags.
That has all the information we need.

Additionally, do massive revamping of the EA generation code and the
REX generation logic.
2007-05-30 03:25:21 +00:00
H. Peter Anvin
dbf130e681 Rename REGNORM to REG_EA
Rename REGNORM to REG_EA to make the distinction between REG_GPR and
REG_EA clearer.
2007-05-30 00:18:26 +00:00
H. Peter Anvin
5a640e1161 Clean up the existing operand flag definitions, and document 2007-05-29 23:57:12 +00:00
H. Peter Anvin
0db11e236b Handle "LOCK as REX.R" for MOV CRx; fix warning for invalid 64-bit regs
- MOV gpr,CRx or MOV CRx,gpr can access high control registers with a LOCK
  prefix; handle that in both the assembler and disassembler.
- Get a saner error message when trying to access high resources in
  non-64-bit mode.
2007-04-17 20:23:11 +00:00
H. Peter Anvin
7cf03aff4f More 64-bit ndisasm fixes.
In particular, now we should handle A0-A3 instructions.
2007-04-16 02:39:56 +00:00
H. Peter Anvin
b061d595fb Fixes for 64-bit ndisasm.
This fixes some of the most glaring bugs in ndisasm 64-bit mode.  We're
still getting redundant prefixes for unknown reason, however.
2007-04-16 02:02:06 +00:00
H. Peter Anvin
0ee014231f Initial 64-bit support for ndisasm. Still a work in progress.
64-bit support for ndisasm.  This is very much an initial attempt, and
there are guaranteed to be bugs in the code.  However, some *very*
preliminary testing seems to indicate it's not completely off-base.
2007-04-16 01:18:30 +00:00
Keith Kanios
93f2e9a5a1 c99 printf/fprintf compliance. 2007-04-14 00:10:59 +00:00
Keith Kanios
a6dfa78b78 Fixed distinction between char and int8_t data types. 2007-04-13 16:47:53 +00:00
Keith Kanios
b7a89544d0 General push for x86-64 support, dubbed 0.99.00. 2007-04-12 02:40:54 +00:00
H. Peter Anvin
e2c80181b6 Apply Nindent to all .c and .h files 2005-01-15 22:15:51 +00:00
Ed Beroset
64ab51965a Added todo item to point out the somewhat tricky fact about snprintf's
return value.
2004-12-15 23:32:57 +00:00