| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
|
|
|
|
|
|
|
| |
Hopefully this should catch all of them... but please keep an eye out
for any other uses of int32_t for the operand flags.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
|
|
|
|
|
|
| |
At moment we can't overrun buffer even if we would like to
but better to stay on a safe side and use snprintf.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
|
|
|
|
|
|
| |
*To the best of my knowledge*, we now have authorization from everyone
who has significantly contributed to NASM in the past. As such,
change the license to the 2-clause BSD license.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
|
|
|
|
|
|
|
|
| |
Add copyright headers to the *.c/*.h files in the main directory. For
files where I'm sure enough that we have all the approvals, I have
given them the 2-BSD license, the others have been given the "LGPL for
now" license header. Most of them can probably be changed after
auditing.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
|
|
|
|
|
| |
Fix the disassembly of JRCXZ; in 64-bit mode, we should only accept
JECXZ for disassembly with 32-bit address size override.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
|
|
|
|
|
|
|
| |
Add a byte code to explicitly support instructions which only uses the
low 8-bit registers (as if a REX prefix always was present.) This is
usable for instructions which are officially documented as using "the
low byte of a 32-bit register" and so on.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
|
|
| |
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
F2 is REPNE, F3 is REP(E)
|
|
|
|
|
| |
If we can't find a matching instruction, rather than printing it as a
"db" literal, consider first if we can disassemble it as a naked prefix.
|
|
|
|
|
|
| |
WAIT is technically an instruction, but from an assembler standpoint
it behaves as if it had been a prefix. In particular, it has to be
ordered *before* any real hardware prefixes.
|
|
|
|
|
|
|
| |
Introduce the opy pointer into the disassembler, and use it where
appropriate.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
|
|
|
|
|
| |
Add support to the disassembler for the extension bytes (for operand
4+).
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
| |
As far as the disassembler is concerned, the segment register push/pop
bytecodes can be collapsed to a simple expression; the remaining
differences are handled by the filter expressions in insns.pl.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
Accept the VIA XCRYPT instructions either with or without a REP
prefix, as documented.
Add the missing XCRYPTCTR instruction.
|
|
|
|
|
|
|
| |
R12 can be used as an index register. Special encodings in the modr/m
byte are done *without* consideration for the REX prefix, but special
encodings in the SIB byte *do* take the REX prefix into consideration,
since it doesn't affect the overall instruction format.
|
|
|
|
|
|
| |
We would incorrectly set a bunch of VEX-related state for C4 and C5
bytes, even though we had already rejected it as not a VEX prefix due
to the top two bits of the following byte not being 11.
|
|
|
|
|
| |
Mask the high bit of is4 bytes in 32-bit mode. Provide a generic
"regmask" variable that we can use for equivalent purposes as needed.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Add the DY instruction, YWORD keyword, and an SY marker for
instruction sizes. Add a few more AVX sample instructions.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
We can now have zero bytecodes with impunity, so remove any special
hacks we had to avoid zeroes in the bytecode.
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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...)
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Relative operands are signed, not unsigned; record them as such and
then apply proper truncation after offset addition.
|
| |
|
|
|
|
|
|
|
|
|
| |
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]
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Factor out the common operand-extraction code in the disassembler, as
previously done in the assembler.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
More correct -- but not fully correct -- handing of 64-bit addressing
in ndisasm. In particular, we need to generate "a32" versus "dword"
where applicable.
|
|
|
|
|
| |
"REX.B 90" in 64-bit mode is "xchg eax,r8d" not "nop"; equivalent
situation for "REX.WB 90" (xchg rax,r8).
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
"Stealth whitespace" makes it harder to read diffs, and just generally
cause unwanted weirdness. Do a source-wide pass to get rid of it.
|