Comprehensive x86 instruction set for MSVS2010?

Started by bl4z0r313, June 05, 2012, 08:27:08 AM

Previous topic - Next topic

bl4z0r313

Something I've been wondering - is there a list anywhere of all the instructions Microsoft Visual Studio 2010 uses when compiling to .asm? I have some projects in mind involving using these files as input for some tools utilizing AsmJit - but AsmJit doesn't cover all of the obscure and rarely used x86 instructions. The OCD in me would like to know that these tools will never hit any hangups because of this - and it would be nice as well to not have to waste time writing extra code for instructions I won't have to parse anyway.

Thanks!

jj2007

Try the following:
- download the "combined volumes" from http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html
- select all, copy, paste into a text file named "IntelComplete.txt" (ca. 8MB)
- use & modify the snippet below to get the instructions:
Quoteinclude \masm32\MasmBasic\MasmBasic.inc   ; download
  Init
  NanoTimer()
  Recall "IntelComplete.txt", L$()
  xchg eax, ebx
  push ebx
  Print Str$("Reading %i lines ", ebx), Str$("took %i ms\n", NanoTimer(ms))
  NanoTimer()
  Open "O", #1, "InstructLines.txt"
  xor edi, edi
  xor ebx, ebx
  .Repeat
   mov esi, L$(ebx)   ; get one line
   .if Instr_(esi, "—")   ; thanks, Intel, for a clear marker ;-)
      .if edx>3 && edx<10
         mov ecx, Instr_(esi, ". . .")   ; strip the dots
         dec ecx
         mov al, [esi]
         .if al>="A" && al<="Z"
            Print #1, Str$("\nLine %i\t", ebx), Left$(esi, ecx)
            inc edi
         .endif
      .endif
   .endif
   inc ebx
  .Until ebx>[esp]
  pop eax
  Close
  Inkey Str$("Writing %i lines ", edi), Str$("took %i ms\n", NanoTimer(ms))
  Exit
end start
Output:
Reading 176194 lines took 24 ms
Writing 1615 lines took 44 ms
Results attached, it needs some manual cleaning. Example:
Line 21249 MOVAPD—Move Aligned Packed Double-Precision Floating-Point Values
Line 21250 MOVAPS—Move Aligned Packed Single-Precision Floating-Point Values
Line 21251 MOVBE—Move Data After Swapping Bytes
Line 21253 MOVDDUP—Move One Double-FP and Duplicate
Line 21254 MOVDQA—Move Aligned Double Quadword


HTH, jj

dedndave

ouch !   :dazzled:

i think the \masm32\help\opcodes.chm file has most of them

zooba

I don't think there's any way to safely assume any less than the full list. The generated code is an implementation detail, which means any update to the compiler could change the instructions used (as in, there is a limited obligation to retain backwards compatibility). In particular, optimised code will more likely use more of the rarer opcodes than unoptimised code.

Maybe your best option would be to gracefully fail when you hit an unknown opcode and provide an easy way for users to let you know? Even if you cover the full set, you're still playing a losing game as the chip manufacturers add more instructions. Whatever approach you choose, good luck!

Cheers,
Zooba  :t

dedndave

you could provide the base set by default
then allow the user to add them, as needed, in an INI file or something similar
this could also simplify your update process   :P

Mr Hippy

Are you talking about the generic x86 instruction set? x64? Enhanced-instruction sets? What?

VC++ supports x86/x64/IA-64 instruction sets, along with enhanced instruction sets. You just have to enable the option. Then you will be able to write the instructions inline.

hutch--

Simple solution, include the full Intel instruction set and you won't get into trouble on Intel processors. It may be worth the effort to include the AMD specific ones as well.

jj2007

Quote from: hutch-- on June 06, 2012, 05:24:11 PM
Simple solution, include the full Intel instruction set

Would be nice if Intel gave us the full set in a machine-readable format. I attach a manually cleaned version of what I posted above, but warning not all instructions in the "Combined set" at http://download.intel.com/products/processor/manual/325462.pdf bear the marker...

hutch--

Here is a cleaned (cleaned) set ALA QE Global replace.  :biggrin:

jj2007

#9
Sorry, I forgot that QE doesn't display UTF-8 :(
Leaving the (char 151) in has one advantage: You can specify e.g. CVT* as a search term and get immediately
Line 21071 CVTDQ2PD—Convert Packed Dword Integers to Packed Double-Precision FP
Line 21073 CVTDQ2PS—Convert Packed Dword Integers to Packed Single-Precision FP
Line 21075 CVTPD2DQ—Convert Packed Double-Precision FP Values to Packed Dword
Line 21077 CVTPD2PI—Convert Packed Double-Precision FP Values to Packed Dword
Line 21079 CVTPD2PS—Convert Packed Double-Precision FP Values to Packed Single-Precision
Line 21081 CVTPI2PD—Convert Packed Dword Integers to Packed Double-Precision FP
Line 21083 CVTPI2PS—Convert Packed Dword Integers to Packed Single-Precision FP
Line 21085 CVTPS2DQ—Convert Packed Single-Precision FP Values to Packed Dword
Line 21087 CVTPS2PD—Convert Packed Single-Precision FP Values to Packed Double-Precision
Line 21089 CVTPS2PI—Convert Packed Single-Precision FP Values to Packed Dword
Line 21091 CVTSD2SI—Convert Scalar Double-Precision FP Value to Integer
Line 21092 CVTSD2SS—Convert Scalar Double-Precision FP Value to Scalar Single-Precision FP
Line 21094 CVTSI2SD—Convert Dword Integer to Scalar Double-Precision FP Value
Line 21095 CVTSI2SS—Convert Dword Integer to Scalar Single-Precision FP Value
Line 21096 CVTSS2SD—Convert Scalar Single-Precision FP Value to Scalar Double-Precision FP
Line 21098 CVTSS2SI—Convert Scalar Single-Precision FP Value to Dword Integer

Handy, isn't it?  ;)

Edit: Holy crap! I tried to be clever and used FoxIt Readers "save as txt" feature for the fat Intel PDF. It saves but in format CrCrLf. So I went for our friend from Adobe (you know, Acrobat, the one with the GPFs), version 8.1; first it tells me "unable to save", then it freezes for ten minutes after you click ok. Copying to the clipboard is apparently allowed, at least it appears in the menu, but the clipboard remains empty. Right now I am testing the option "Save as accessible text", whatever that means, and it is "Saving page 1800 of 4175", in very slow motion 8)

dedndave



dedndave

that's probably what the Pope says when he stubs his toe or something - must be Italian   :biggrin:

hutch--

A German pope living in the Vatican probably swears in latin.

Quote
Irrumabo quod nocere.

jj2007

That doesn't look correct, Hutch, it should be sancti stercore (German->Latin) :bgrin: