Commit Graph

220 Commits

Author SHA1 Message Date
H. Peter Anvin
37c6d166d2 Add a few missing \15 -> \275 conversions
Add a few \15 -> \275 conversions that had been missed earlier.
Still haven't done the work on IMUL.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-07 10:56:32 -07:00
H. Peter Anvin
55f58acdae Change \40 class opcodes to \254, except IMUL
Change \40 class opcodes which need to be changed to \254.  IMUL will
need a separate audit; I'm not convinced we are really sure what all
the IMUL conditions should be.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-07 10:53:08 -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
e9d7f1a074 Better warnings for out-of-range values
Issue better warnings for out-of-range values.  This is not yet
complete.

In particular, note we may have out-of-range for values that end up
being subject to optimization.  That is because the optimization takes
place on the *truncated* value, not the pre-truncated value.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-06 18:47:29 -07:00
H. Peter Anvin
ee6789ceb1 BR 2148476: Fix arguments for a bunch of the CVT* instructions
Fix bugs exposed by test for BR 2148476.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-10-06 17:58:57 -07:00
H. Peter Anvin
6f87180c3f JMP reg64 does not require a REX.W prefix.
We were redundantly emitting a REX.W prefix for JMP reg64.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-09-25 23:42:28 -07:00
H. Peter Anvin
163e5874d9 Accept implicit memory size for VMREAD/VMWRITE 2008-08-28 18:05:23 -07:00
H. Peter Anvin
5e7d6f1105 BR 2029472: Wrong operand size for VMREAD/VMWRITE in 64-bit mode
Fix the operand size for VMREAD/VMWRITE in 64-bit mode
2008-08-28 18:03:49 -07:00
H. Peter Anvin
dd1de39ece BR 2028995: Missing MOVNTI m64, r64
Fix MOVNTI with a 64-bit argument.
2008-08-28 17:54:55 -07:00
H. Peter Anvin
962e30519c BR 2029829: Accept VIA XCRYPT instructions with or without REP
Accept the VIA XCRYPT instructions either with or without a REP
prefix, as documented.

Add the missing XCRYPTCTR instruction.
2008-08-28 17:47:16 -07:00
H. Peter Anvin
7b4dc622c6 BR 2039212: Handle indirect far jumps in 64-bit mode
Handle indirect far jumps in 64-bit mode.  Default to 64 bit unless
overridden, for consistency with other jumps.
2008-08-28 17:35:25 -07:00
H. Peter Anvin
04f54809d2 Add 256-bit AVX stores per the latest AVX spec.
Add 256-bit forms of VMOVNTPD, VMOVNTPS, and VMOVNT[DQ]Q.
2008-08-27 18:47:05 -07:00
H. Peter Anvin
06425512ae Add AVX forms of the AES instructions (new in the latest AVX spec)
The AES instructions, too, have gotten VEX forms.
2008-08-27 18:42:26 -07:00
H. Peter Anvin
51e403152a BR 2067820: add the MOVSXD instruction
The official mnemonic for 32-to-64-bit sign extension is MOVSXD for
some idiotic reason.  Add support for it while continue to recognize
MOVSX for this as an alias.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2008-08-24 18:12:20 -07:00
H. Peter Anvin
2a09b3bf11 BR 2030823: Problem with the 256-bit FMA instructions
Fix the 256-bit FMA instructions per bug report.
2008-08-13 16:25:08 -07:00
H. Peter Anvin
38c6b44909 BR 2043111: Typo in insns.dat: VCMPFT_OQPD VCMPFT_OQPS
Fix typo
2008-08-13 16:18:23 -07:00
H. Peter Anvin
ecf8c3e382 BR 2025977: Handle SLDT with a 64-bit register operand
Handle SLDT with a 64-bit register operand.  Don't generate a REX.W
prefix in the assembler, since zero-extending is just fine, but do
support it in the disassembler.
2008-07-30 17:28:05 -07:00
H. Peter Anvin
bb266eaa4b BR 2023036: MOV reg32,dreg and vice versa are NOLONG
MOV reg32,dreg and MOV dreg,reg32 are NOLONG; in 64-bit mode we always
move to/from reg64.
2008-07-20 14:59:18 -07:00
H. Peter Anvin
96a6954db4 BR 2017453: indirect jumps in 64-bit mode are implicitly 64 bits
Indirect jumps in 64-bit mode implicitly have 64-bit operand size.
Fix this; the disassembly is still unnecessarily ugly, however.
2008-07-13 15:21:01 -07:00
Charles Crayne
a8ef7ab51d Fix Bugs item #2017455 (LTR in long mode)
LTR is valid in long (64-bit) mode, but still uses
16-bit operand, so remove NOLONG restriction.
2008-07-13 12:52:02 -07:00
H. Peter Anvin
f89d681805 AES instructions are WESTMERE, not NEHALEM
Still need to make this crap saner...
2008-06-27 11:41:59 -07:00
H. Peter Anvin
358c97d21f The XSAVE group are SSE-spefix-sensitive
The XSAVE group are SSE-prefix-sensitive (null prefix), and therefore
take the \360 flag.
2008-06-05 16:23:35 -07:00
H. Peter Anvin
92c4704ddb insns.dat: whitespace cleanup 2008-05-27 14:22:19 -07:00
H. Peter Anvin
fd507e7a79 Fix double 66 prefixes on INVEPT/INVVPID (BR 1956955)
Fix double 66 prefixes on INVEPT/INVVPID in 16-bit mode, per BR
1956955.
2008-05-27 14:20:21 -07:00
H. Peter Anvin
62449a6ce0 VCVTPD2PS, VCVTPD2DQ, VCVTTPD2DQ mem need explicit op size (BR 1974170)
BR 1974170: VCVTPD2PS, VCVTPD2DQ, VCVTTPD2DQ with a memory operand are
ambiguous without a specific operand size, so force one to be added.

Split the instruction pattern due to our current clunky handling of
MMX/XMM/YMM registers together with sizes.  Fix in the future, please!
2008-05-26 22:48:51 -07:00
H. Peter Anvin
4a49b6770f Fix parameters to VCVTPD2DQ (BR 1974159) 2008-05-26 22:42:02 -07:00
H. Peter Anvin
216fea010d Fix mnemnonics for SSE5 PCOMU instructions 2008-05-25 09:25:47 -07:00
H. Peter Anvin
8cb2ae916b Fix mnemonics for VTESTP[SD] (BR 1971570)
Incorrectly entered as VPTEST* due to illogical placement in the manual.
2008-05-24 22:15:56 -07:00
H. Peter Anvin
7aacbeb537 Fix the VPSHUF*W instructions (BR 1971567)
The VPSHUF*W instructions had both wrong mnemonics and opcodes.
2008-05-24 22:13:33 -07:00
H. Peter Anvin
05430f64b5 Fix typo in VPCMPESTRM instruction (BR 1971565)
The VPCMPESTRM instruction was typoed.
2008-05-24 22:11:44 -07:00
H. Peter Anvin
ee71120a63 Add VCVTSI2SS (BR 1971564)
The VCVTSI2SS instruction was missing.
2008-05-24 22:09:51 -07:00
H. Peter Anvin
f2c10aee70 Fix immediate for PCLMULHQ* instructions (BR 1971555)
The immediate for the PCLMULHQ* instructions was wrong.
2008-05-24 22:07:03 -07:00
H. Peter Anvin
89031ff5d2 Remove imm from specific versions of VCMPxx
For the versions of VCMPxx which already embed their condition code,
we do not want an extra immediate argument.

Todo: fix bytecode compiler to complain more about these.
2008-05-24 22:04:23 -07:00
H. Peter Anvin
d0da1c7202 Add VLDQQU as an alias for 256-bit VLDDQU (BR 1971539)
Accept VLDQQU as an alias for VLDDQU when used with 256-bit values.
2008-05-24 21:58:59 -07:00
H. Peter Anvin
6c8042c0eb VFMSUBADDP[SD], not VFMADDSUBS[SD] (BR 1971573)
There are VFMSUBADDP instructions, but there are no VFMADDSUBS
instructions.
2008-05-24 21:54:09 -07:00
H. Peter Anvin
dd84acedcc AVX FMA: Instruction table for the AVX FMA instructions
This adds the AVX FMA instructions to the instruction table, which
should complete the AVX work.
2008-05-23 17:46:08 -07:00
H. Peter Anvin
55ca614e62 AVX: Remaining AVX instructions (still need FMA)
Implement the remaining set of AVX instructions
2008-05-23 17:27:15 -07:00
H. Peter Anvin
2ee4c67e7d AVX instruction table through "P"
AVX instruction table through the letter P in the manual
2008-05-23 17:03:30 -07:00
H. Peter Anvin
7c71949931 AVX: instruction table up to PE
Complete the instruction table up to and including PE (document
319433-002, start next on page 5-330).
2008-05-21 23:21:57 -07:00
H. Peter Anvin
283ba9103e AVX: instruction table through M
Implement the AVX instruction table through the letter M.
2008-05-21 18:10:09 -07:00
H. Peter Anvin
982a7bd3dd Implement aliases for specific SSE5 compare operations
Implement aliases for specific SSE5 compare operations, per BR 1930630.
2008-05-21 15:02:30 -07:00
H. Peter Anvin
eaf3d491ad insns.dat: reimplement SSE5 compares using the bytecode compiler
Use the bytecode compiler for the SSE5 compare instructions.  While we
are at it, give it correct flags.
2008-05-21 14:45:46 -07:00
H. Peter Anvin
eccd1acca9 Add the PCLMUL instructions (BR 1933742)
Add the PCLMUL group instructions, from the AVX spec but not actually
AVX instructions.
2008-05-21 14:28:42 -07:00
H. Peter Anvin
cf6682fb01 Add INVEPT and INVVPID (BR 1956955) 2008-05-21 14:17:33 -07:00
H. Peter Anvin
bce9da223f Add the MOVBE instructions (BR 1956954)
Add the MOVBE instructions (load/store and swap)
2008-05-21 14:03:56 -07:00
H. Peter Anvin
18c3ce2517 insns typo fix: SSE5 FNM* instructions misspelled
The SSE5 FNM* instructions were misspelled as FMN*

(Bug 1930322)
2008-05-21 08:45:17 -07:00
H. Peter Anvin
2b524d5e62 Merge branch 'master' of git+ssh://repo.or.cz/srv/git/nasm 2008-05-21 08:42:55 -07:00
H. Peter Anvin
be5133cb13 UDx instructions are 186+, not 286+
The UDx instructions are valid as far back as the #UD trap, which is
the 186, not the 286.
2008-05-21 08:41:58 -07:00
H. Peter Anvin
c882715a8e AVX instructions up to VMINSS 2008-05-20 23:28:46 -07:00
H. Peter Anvin
330cbd1c90 A few more AVX instructions (up to VLDMXCSR)
More AVX instructions, up to VLDMXCSR
2008-05-20 23:16:27 -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
9681ef4144 AVX: implement all the convert instructions...
Make our way through the AVX instructions: conversions.
This is all I have time for now... hopefully this can service as a
generous source of examples.
2008-05-20 18:14:30 -07:00
H. Peter Anvin
4ae88e1a83 Accept the gas mnemonics "ud2a" and "ud2b"; fix ud0
Accept the gas mnemonics "ud2a" and "ud2b" for the instructions we
call ud2 and ud1 respectively, and Intel call ud2 and undocumented :)

Also, 0F FF is ud0 regardless of prefixes, at least as far as we know.
2008-05-20 17:14:17 -07:00
H. Peter Anvin
f99359c03a Finish the VCMP series... 2008-05-20 16:59:17 -07:00
H. Peter Anvin
e6d0eb4d68 More AVX instructions
Add additional AVX instructions to the list.
2008-05-20 16:48:34 -07:00
H. Peter Anvin
73252a92ae PTEST is SSE4.1; although AMD says it's SSE5.
Fix this when we have proper support for feature sets, or forget about
the concept entirely.
2008-05-20 13:07:09 -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
d82dd4f1a3 insns.dat: no subheader for "must be last" 2008-05-20 11:05:59 -07:00
H. Peter Anvin
1e5203872d insns.dat: make even wider to make space for AVX
The AVX instructions take more space, so add a few tab stops across
the entire file.
2008-05-20 11:04:26 -07:00
H. Peter Anvin
8597e6900c insns.dat: use compiler-generated bytecodes for AVX
Use compiler-generated bytecodes for the AVX instruction demos.  This
should make it a lot easier for other people (HINT, HINT) to add the
instruction table.
2008-05-20 11:01:28 -07:00
H. Peter Anvin
2812ff5181 Use the \360..\363 annotations for SSE prefixes 2008-05-20 10:21:57 -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
e303936391 Fix encoding of VPERMIL2PS instructions 2008-05-06 20:06:14 -07:00
H. Peter Anvin
42a8caecb5 Sandy Bridge, not Sandy Banks; add Westmere 2008-05-06 19:54:28 -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
32cd4c2a62 Correctly identify SBYTE in the optimizer
Correctly identify SBYTE in the optimizer, *HOWEVER*, this change will
cause nuisance warnings to be issued; that will have to be fixed.
2008-04-04 13:34:53 -07:00
Charles Crayne
fa93735742 Remove KATMAI support for CLFLUSH
Minimal cpu level is WILLAMETTE,SSE2
2008-03-22 20:07:08 -07:00
H. Peter Anvin
65e823978b insns.dat: add "MOV reg64,imm32" as a special rule
Add "MOV reg64,imm32" as a special rule, to handle the case of
"mov rax,dword <foo>", where <foo> is sign-extended; this is a 7-byte
form, as opposed to "mov eax,<foo>" (5 bytes) and "mov rax,<foo>" (10
bytes).

At some point, the optimizer needs to be able to handle these.
2008-03-19 14:42:20 -07:00
Charles Crayne
6372b9c5fc Correct opcode for CLFLUSH
Correct opcode is 0FAEh
2008-03-18 15:21:14 -07:00
H. Peter Anvin
373281afde BR 1893952: XGETBV is not privileged. 2008-02-16 13:29:56 -08:00
H. Peter Anvin
f6c51f084b Add XSAVE instruction features (CPU feature is bogus, but oh well.)
Add the XSAVE group of instructions: XSAVE, XRSTOR, XGETBV, XSETBV.
The CPU feature information is bogus, but so is our entire handling of
CPU feature sets for anything but the bare necessities (long jump
emulation, etc.)
2008-02-14 11:25:36 -08:00
Ismail Dönmez
e7d855209a BR 1879590: More MMX/SSE size fixes
Fix more instances of MMX/SSE having "SM" instead of "SQ" or "SO".
This should hopefully resolve bug report 1879590.
2008-01-30 14:09:45 -08:00
Charles Crayne
c17a0eb31b Add autogenerated instruction list to NASM documentation
1. Allow included files in rdsrc.pl
2. New program inslist.pl to generate instruction list from insns.dat
3. Mark certain comments in insns.dat as documentation subheaders
4. Add Instruction List appendix to nasmdoc.src
5. Update build process to invoke inslist.pl
2008-01-20 16:27:03 -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
69f0557345 Remove bogus duplicates of the PREFETCH* instructions 2007-12-25 15:24:07 -08:00
H. Peter Anvin
1bec91e567 (Hopefully) fix the handing of MMX instructions with prefixes
Mark MMX instructions with \323 (do not add REX.W) unless they involve
the integer instruction file.

Change SM -> SQ for MMX instructions.

Something not complete attached, so my understanding is
mmxreg,mmxrm needs SQ

Something like xmmreg,reg32 needs SD
xmmreg,xmmrm needs SO
2007-12-25 15:18:12 -08:00
H. Peter Anvin
15c1e5aa4d Unbreak CMPSW/CMPSD/CMPSQ
The CMPSW/CMPSD/CMPSQ instructions were broken by checkin
a30cc07224 due to an incorrect removal
of \1 (should only have been removed after \144-147 and \154-157).  I
have verified that no other instructions were affected.
2007-11-20 21:45:16 -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
7812644665 BR 993895: Support zero-operand floating-point insn
Support the zero-operand form of floating-point instructions.  Note
that in most cases, the form generated is actually the "popping" form,
e.g. "FADD" becomes "FADDP st0,st1".  This is in accordance with the
Intel documentation.  "FADDP" is also supported.
2007-11-15 14:38:19 -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
4b3390eb47 BR 1828866: fix handling of LAR/LSL
Fix handling of LAR/LSL with various sized operands
2007-11-12 22:05:31 -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
aff9c93aa4 Fix handling of XCHG in 64-bit mode
The handling of XCHG in 64-bit mode somewhat broken.  Add a register
flag for "not accumulator", so we can generate all the appropriate
modes.
2007-11-12 20:18:05 -08:00
H. Peter Anvin
ce6c8a7929 More \321 -> \324 bug fixes
Additional \321 flags (o32) that should be \324 (o64).
2007-11-12 19:36:13 -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
H. Peter Anvin
826ffa9c8e Fix FISTTP opcodes (BR 689695) 2007-10-15 19:53:10 -07:00
H. Peter Anvin
17394a7d8e insns.dat: add systematic names for the hinting NOPs (0F18-0F1F)
0F 18-1F are reserved for hinting NOPs; they all take a single memory
operand which may be sized.  Allow the use of systematic names; this
also makes sure they get sensibly disassembled.
2007-10-02 15:09:33 -07:00
H. Peter Anvin
c58642fbba Correct the handling of "MOV" with immediate in 64-bit mode
Correct the handling of "MOV" with immediate in 64-bit mode.  With
these changes, movimm.asm produces the desired results.
2007-09-25 15:40:36 -07:00
H. Peter Anvin
3e1aaa9dd0 Fix BR 1490407: size of the second operand of LAR/LSL
The second operand of LAR/LSL is always 16 bits.
2007-09-25 14:26:03 -07:00
H. Peter Anvin
415c7ced1d insns.dat: SMINT - mark ND, DMINT - fix opcode
Fix the opcode for DMINT (0F 39); mark SMINT (0F 38) as ND since 0F 38
is used as a prefix by newer processors.
2007-09-24 15:56:02 -07:00
H. Peter Anvin
2a5156b284 Additional compaction missed by script
Additional mmxreg/mem -> mmxrm and xmmreg/mem -> xmmrm compactions
which the script missed.
2007-09-24 15:48:09 -07:00
H. Peter Anvin
86317c423d insns.dat: machine-generated compaction mmx/xmmreg,mem -> mmx/xmmrm
Reduce the total instruction count by compacting mmxreg:mem pairs to
mmxrm and d:o for xmmreg:mem -> xmmrm.
2007-09-24 15:42:53 -07:00
H. Peter Anvin
fc565dd362 Implement INVLPGA according to the documentation
INVLPGA is defined as taking rax,ecx but "the portion of rax used to
form the address is determined by the effective address size", so it
is really ax/eax/rax.
2007-09-22 22:35:28 -07:00
H. Peter Anvin
438ed48c49 Reformat insns.dat to uniform column width
Add a script to reformat insns.dat to uniform width, and use it.
2007-09-22 22:02:34 -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
8fcca64a2a LDDQU needs \301 (BR 1103549) 2007-09-22 19:52:11 -07:00
H. Peter Anvin
dcb4b885d5 RDTSCP and INVLPGA aren't 64-bit specific
X64 means X86_64,LM -- long mode only.
2007-09-22 19:51:13 -07:00
H. Peter Anvin
f5c8cf0027 Cyrix GX1 instructions: BBx_RESET, CPU_READ, CPU_WRITE 2007-09-22 19:40:37 -07:00
H. Peter Anvin
763cb77c90 Centaur XSHA1, XSHA256, MONTMUL 2007-09-22 19:28:14 -07:00