Commit Graph

84 Commits

Author SHA1 Message Date
Charles Crayne
8c7eca4936 Pass 64-bit instruction lengths to back-ends. 2007-11-06 21:48:12 -08:00
Charles Crayne
1f8bc4c9a9 Prepare for 64-bit instruction lengths 2007-11-06 18:27:23 -08:00
Charles Crayne
1b851dcd04 Disambiguate error messages 2007-11-05 21:49:49 -08:00
Charles Crayne
dd462c8f44 Make warning limit valid for both i386 and x86_64 2007-11-04 15:28:30 -08:00
Charles Crayne
7e97555f1c Warn on out of bounds EA displacements 2007-11-03 22:06:13 -07:00
H. Peter Anvin
e3917fc538 Move declarations before statements
C99 permits declarations and statements to be intermixed, so gcc don't
warn about them, but MSVC and OpenWatcom get unhappy about them.
2007-11-01 14:53:32 -07:00
H. Peter Anvin
839eca23e4 Clean up the handing of operands in assemble.c
assemble.c was full of code containing ins->oprs[c - 0xxx] where 0xxx
was the base of the particular code block.  Verbose and error prone
when code is moved around.  Now we precompute opx = &ins->oprs[c & 3]
before dispatching, resulting in less code.
2007-10-29 23:12:47 -07:00
H. Peter Anvin
10e2727133 Don't warn for segmented references
Don't warn for overflow in segmented references; those are linker
references and it is up to the backend or the linker to warn if they
overflow their permitted size.
2007-10-29 22:56:08 -07:00
H. Peter Anvin
b0c5462694 Fix bogus flagging of effective addresses as invalid
Ah, what a difference a single ~ makes... such as flagging invalid EAs
as valid and vice versa.
2007-10-28 23:21:46 -07: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
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
192d5b5e9c Suppress a few signedness warnings 2007-10-18 19:02:42 -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
c189b44032 Emit REX prefix before literal zero (\170) 2007-10-05 17:04:32 -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
d0b0d28f42 Unbreak relative references to immediate addresses
Remove bogus "treat labels different from immediates" code, which
would result in generating of a relative mod/rm but without adjusting
the address accordingly.

Update addressing mode test.
2007-09-28 17:17:20 -07:00
H. Peter Anvin
457afd4dad assemble.c: clean up whitespace
Remove stray whitespace
2007-09-25 15:41:19 -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
cfbe7c3cc2 Fix handling of DO; support unary + for floating-point numbers
Floating-point users generally expect to be able to use a unary plus.
Fix support for the DO instruction in several places.
2007-09-18 17:49:09 -07:00
H. Peter Anvin
41c9f6fde0 Implement "oword" (128 bits) as a first-class size
Implement oword, reso, do, as well as the SO flag to instructions.  No
instructions are actually flagged with SO yet, but this allows us to
specify 128-bit sizes in instruction patterns.
2007-09-18 13:01:32 -07:00
H. Peter Anvin
cf5180a955 Actually generate SSE5 instructions
This checkin completes what is required to actually generate SSE5
instructions.  No support in the disassembler yet.

This checkin covers:

- Support for actually generating DREX prefixes.
- Support for matching operand "operand X must match Y"
2007-09-17 17:25:27 -07:00
H. Peter Anvin
401c07e20d Initial support for generating DREX suffixes
Initial support for generating DREX suffixes.  Not used yet.  No
disassembler support yet, and no support for "operand X must match
operand Y."
2007-09-17 16:55:04 -07:00
H. Peter Anvin
8f94f988f0 Fix a few instances of missing renumbers
parser.c: change hard-coded argument count 3 to MAX_ARGUMENTS
assemble.c: change a few missed code renumbers
2007-09-17 16:31:33 -07:00
H. Peter Anvin
19315e012f Enable IF_AR3
Enable IF_AR3, which was incorrectly disabled in a previous checkin.
2007-09-17 16:20:45 -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
16b0a33cea Use enumerations where practical to ease debugging
We have a lot of enumerations; by declaring fields as such, we make it
easier when debugging, since the debugger can display the enumerations
in cleartext.  However, make sure exceptional values (like -1) are
included in the enumeration, since the compiler otherwise may not
include it in the valid range of the enumeration.
2007-09-12 20:27:41 -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
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
f5843c614a assemble.c: correct special handing of ESP/RSP
Correct the special handling of ESP/RSP (must be in the base register
slot, but requires SIB.)
2007-09-10 18:59:26 +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
Keith Kanios
d94764bec0 Fixed RIP address processing ambiguity found by Charles Crayne. 2007-08-19 18:49:26 +00:00
Keith Kanios
48af17738c Fixed issues with REX prefix effective address generation. Fixed XMM instruction output. 2007-08-17 07:37:52 +00:00
H. Peter Anvin
5b0e3eca28 More int/int32_t confusion 2007-07-07 02:01:08 +00:00
H. Peter Anvin
0ec60e69d9 regflag() should return int32_t. 2007-07-07 01:59:52 +00:00
Chuck Crayne
42fe6ce765 Support 32-bit direct addressing in 64-bit mode without base or index regs 2007-06-03 02:42:41 +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
c6be66fa20 Correct the generation of 67 prefixes.
The recent switch from register numbers (with -1 meaning "none") to
register flags (with 0 meaning "none") broke the generation of 67
prefixes, especially in 64-bit mode.
2007-05-30 20:30:15 +00:00
H. Peter Anvin
34539fb1ed Remove bogus redundant tests
Remove tests that are bogus (they trigger for legitimate instructions.)
The failure cases are okay anyway since they will be trapped by the
REX generation logic.
2007-05-30 04:27:58 +00:00
H. Peter Anvin
a57e8d411a Remove bogus check for 64-bitness
Remove a bogus check for 64-bit operands.  If appropriate, we will
detect this during REX generation and will bail then.  However, there
are other instructions (floating point, MMX, ...) which are legitimately
64 bits in non-64-bit mode.
2007-05-30 03:44:02 +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
5a640e1161 Clean up the existing operand flag definitions, and document 2007-05-29 23:57:12 +00:00
H. Peter Anvin
8d7316a3ff Fix the handling of \324 for computing the length
\324 means REX.W is mandatory, but that doesn't mean add a byte to the
output!  Instead, force REX.W set, and let the REX logic deal with the
length.
2007-04-18 02:27:18 +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
Keith Kanios
fd5d91383a Fixed 64-bit Mode Segment Selection. 2007-04-16 15:46:46 +00:00
Keith Kanios
e83b318017 Fixed distinction between [LOCAL]SYMBOL/IMMEDIATE for RIP-relative addressing. 2007-04-16 14:31:54 +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
Keith Kanios
3faf938f79 Fixed distinction between RIP relative symbols and immediate values. 2007-04-15 22:08:30 +00:00
Keith Kanios
61ff53c80d Added DQ constants for all BITS modes. 2007-04-14 18:54:52 +00:00
Keith Kanios
b2a0380eb8 Fixed support for DQ constants in long mode. 2007-04-14 03:52:05 +00:00