Commit Graph

79 Commits

Author SHA1 Message Date
H. Peter Anvin
98df21629a insns.pl: remove stray whitespace
Clean up whitespace in insns.pl.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 23:18:06 -07:00
H. Peter Anvin
51c7de27e8 insns.pl: add "nohi" code for REX_NH
Add a "nohi" code flag for the \325 byte code, which sets the REX_NH
flag.  That is, REX_P not required to support high registers, high
registers are not supported and spl/bpl/sil/dil enabled even in
non-64-bit mode.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 23:17:52 -07:00
H. Peter Anvin
f5051691c9 insns.pl: fix indentation
Canonicalize indentation of some blocks.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-25 23:17:52 -07:00
H. Peter Anvin
37b3c59fc8 insns.pl: allow relaxed forms to be created without duplication
Allow a * to be put on an operand, indicating that it is optional and
should be replaced with the immediately preceding operand if it is
omitted.  This allows official and relaxed forms of nondestructive
instructions to be written on one line.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-06-24 18:06:26 -07:00
Cyrill Gorcunov
52fb2575f3 insns.pl - add handling of pp VEX/XOP fields
We already have such kind of aliases for L field
(via l0 and l1). Via p0,p1,p2 it's become easier
to follow AMD docs while encoding VEX/XOP commands.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-05-15 07:20:02 -07:00
H. Peter Anvin
0bff6a48fd Use lower case for VEX and XOP in instructions table
Use lower case for VEX and XOP ("vex", "xop") to avoid visual
confusion (and in the future potential real confusion) with upper-case
hexadecimal numbers.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-05-03 22:14:03 -07:00
H. Peter Anvin
a04019c7f4 Infrastructure support for AMD's new XOP prefix
Handle AMD's XOP prefixes; they use basically the same encoding as VEX
prefixes, so treat them simply as a variant of VEX.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2009-05-03 21:42:34 -07:00
H. Peter Anvin
58af1fbbe9 insns.pl: handle the new VEX.DDS flag per AVX spec version 5
The AVX spec version 5 introduces the new VEX.DDS flag; support it.
2009-02-18 14:04:02 -08:00
H. Peter Anvin
dcffe4b9f6 Add extension bytecodes to support operands 4+
The bytecode format assumes max 4 operands pretty strictly, but we
already have one instruction with 5 operands, and it's likely to get
more.  Support them via extension prefixes (similar to REX prefixes).
For bytecodes which use argument bytes we encode the number directly,
however.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-23 23:03:59 -07:00
H. Peter Anvin
ff6e12da50 Reshuffle and move the bytecodes for segment register push/pop
Reshuffle the bytecodes for segment register push/pop to make more
sense, and move them from \4 to \344, thus freeing up the single-digit
bytecodes \4..\7 for future use.  It doesn't really make sense to use
single-digit bytecodes for this very oddball use.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-08 21:17:32 -07:00
H. Peter Anvin
a5c31197f5 Collect statistics on bytecode use in insnsb.c
We are starting to have to worry about running short on available
bytecodes, especially where we encode the operand number in the byte
code.  Thus, compile a table of bytecode usage and include as a
comment in insnsb.c.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-08 16:56:35 -07:00
H. Peter Anvin
588df78b0d New opcode for 32->64 bit sign-extended immediate with warning
Add a new opcode for 32->64 bit sign-extended immediate, with warning
on the number not matching.

This unfortunately calls for an audit of all the \4[0123] opcodes, if
they should be replaced by \25[4567].  This only replaces one
instruction (MOV reg64,imm32); other instructions need to be
considered.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-07 10:05:10 -07:00
H. Peter Anvin
c1377e9a98 New opcodes to deal with 8-bit immediate sign extended to opsize
New opcodes to deal with 8-bit immediates which are then sign-extended
to the operand size.  These allow us to warn appropriately.
Not sure I'm using these in all the proper places; need audit of all
uses of the \14..\17 opcodes.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-06 23:40:31 -07:00
H. Peter Anvin
a0b91037e2 Mark Perl scripts executable
Be consistent about marking Perl scripts executable, even if we always
invoke them with $(PERL) in the Makefiles.
2008-06-15 16:55:39 -07:00
H. Peter Anvin
cb6aaa33ce insnsd.c: don't generate an inaccessible table
Some pseudo-instructions (RESB and EQU) seem to make it into the
instruction table.  This also generates an instruction table for
zero-length instructions, which of course can never actually be
accessed.  Quiet a compiler warning by simply not emitting this
useless table.  Ideally we shouldn't emit the pseudo-instructions
either, but that is a bigger change, and it's hardly a lot of memory
involved.
2008-06-05 12:28:00 -07:00
H. Peter Anvin
69d648800e insns.pl: better error messages, handle no-operand instructions better
Better error messages, and allow "void" instructions to omit the
operand colon.
2008-05-23 17:25:54 -07:00
H. Peter Anvin
bd420c7095 Add tokens vex.ww and vex.wx; vex.wx is the default
Add vex.ww (for VEX.W follows REX.W) and vex.wx (for VEX.W is a don't
care); vex.wx is the default since that seems to match existing usage
better.
2008-05-22 11:24:35 -07:00
H. Peter Anvin
2637aca805 insns.pl: error if we have a 'v' operand and no vex.nds/ndd
Although redundant, the presence of a 'v' operand should match the
existence of a nds or ndd flag on vex; this should help catch typos.
2008-05-21 18:09:17 -07:00
H. Peter Anvin
a69ce1d19d insnsn.c: cleaner to *not* separate out conditional instructions
The disassembler code gets cleaner if we do *not* separate out the
conditional instructions; instead, rely on the fact that the
conditionals are always at the end and use FIRST_COND_OPCODE as a
barrier.
2008-05-21 15:09:31 -07:00
H. Peter Anvin
f89b305c32 insns.pl: match AMD documentation for DREX syntax
Adjust the compiler to give a syntax for DREX instructions that
matches the AMD documentation.
2008-05-21 14:44:42 -07:00
H. Peter Anvin
9d5d239a9d Use "o64nw" instead of "o64i" for o64 without REX.W
Use the somewhat more mnemonic "o64nw" for 64-bit operand size sans
REX.W.
2008-05-21 14:16:49 -07:00
H. Peter Anvin
36b47fdfdc insns.pl: readabilty improvements for isnsnd.c
Make insnsd.c a bit more consistent in style.
2008-05-21 11:18:12 -07:00
H. Peter Anvin
2fb033af18 Disassembler: select table based on VEX prefixes
We can use the new VEX prefixes to select into a large table of new
opcode spaces.  Since the table is (currently) sparse, add logic so we
don't end up producing tons of empty tables for no good reason.

This is also necessary since VEX is likely to reuse opcode bytes that
would appear as prefixes at some point, which would cause conflicts
with the regular tables.
2008-05-21 11:05:39 -07:00
H. Peter Anvin
eb9e093840 Fix skipping 0270 code when searching for disasm prefixes
The 0270 code was incorrectly entered as 270 (decimal), which meant
that instructions with vex but no .nds got misfiled in the improper
opcode tables.
2008-05-21 10:34:33 -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
2d31ec106a Officially specify - as the symbol for an implicit operand
Use - to denote that an operand is implicit (not encoded).  This
*better* be a fixed operand!
2008-05-20 18:21:11 -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
670219a2c0 Make the syntax for immediates match the docs better
Use a more manual-like syntax for immediates (we still may have to use
extended syntax, but not always.)
2008-05-20 16:47:42 -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
b726b04813 insns.pl: don't require whitespace before / or \
Use Perl's context-sensitive regular expressions to tell split that a
slash or backslash begins a new operator.
2008-05-20 13:03:39 -07:00
H. Peter Anvin
70a13f5a37 insns.pl: support operands that serve double duty
Sometimes assembly syntax wants to permit a single operand to serve
multiple functions; allow this.

The disassembler could really use to be smarter about those.
2008-05-20 11:23:18 -07:00
H. Peter Anvin
0fc86cca1f insns.pl: fix regex subgroup of /is4= codes
The argument is now $1, not $2...
2008-05-20 10:48:22 -07:00
H. Peter Anvin
8491986e69 insns.pl: fix splitting of bracketted operations 2008-05-20 10:39:15 -07:00
H. Peter Anvin
0686131bbe Opcode listing notation is /is4, consistently 2008-05-20 10:29:11 -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
24860b0f0e Allow explicit immediate syntax for imz2 as well as is4
imz2 is just an alias for is4 as far as we are concerned...
2008-05-20 09:36:41 -07:00
H. Peter Anvin
e6fb38b9f2 insns.pl: escape literal special character in regex
In Perl code, it is good practice to escape special characters
intended to be literal.
2008-05-19 21:10:14 -07:00
H. Peter Anvin
7a4928f484 Bytecode compiler: add support for is4/imz2 operands 2008-05-19 21:07:48 -07:00
H. Peter Anvin
dfa2a842bd More work on bytecode compiler (not finished yet...)
More work on the bytecode compiler.  Not all useful bytecodes are
implemented yet, however.
2008-05-19 19:08:03 -07:00
H. Peter Anvin
4f0a3e64ee insns.pl: first steps toward a "smart" bytecode compiler
First steps toward a smart(er) bytecode compiler, using a syntax that
can be more directly taken from the manuals.
2008-05-19 18:19:42 -07:00
H. Peter Anvin
2c94c44f35 Make insnsb.c an actual compilation unit
"make alldeps" doesn't really like it when included files end in *.c.
Instead of renaming insnsb.c to insnsb.h, make it an actual
compilation unit, since there really isn't any reason for it not to
be.
2008-05-13 14:29:47 -07:00
H. Peter Anvin
0a4d23219e insnsb.c: use 5 digits for index, not 4
We already have indexes up to 9500, so use 5 digits instead of 4.
2008-05-12 15:28:33 -07:00
H. Peter Anvin
ff3b57c253 Make MAX_OPERANDS a parameter in insns.pl as well
MAX_OPERANDS is present in insns.pl as well (although proper C
compilers shouldn't need this kind of zero padding.)  Make sure it's
clear to everyone.
2008-05-12 11:36: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
3720f7beae Generate a byte array instead of using strings for the byte codes
Generate a byte array instead of using C compiler strings for the byte
codes.  This has a few advantages:

- No need to special-case zero due to broken C compilers.
- Only insns.pl only ever reads the string, so we can invent our own
  syntax.
- Compaction.
- We can give it the proper, unsigned type.
2008-05-12 11:00:50 -07:00
H. Peter Anvin
387c1c2714 Factor out string decoder in insns.pl
Factor out the string decoder into its own subroutine.  This will be
useful shortly ;)
2008-05-12 10:17:27 -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
Beroset
095e6a2973 regularized spelling of license to match name of LICENSE file 2007-12-29 09:44:23 -05:00
H. Peter Anvin
f096968998 insns.pl: remove debugging output
Remove debugging output which was never meant to be checked in.
2007-11-19 11:44:05 -08:00