Author Topic: Comprehensive x86 instruction set for MSVS2010?  (Read 15564 times)

bl4z0r313

  • Guest
Comprehensive x86 instruction set for MSVS2010?
« on: June 05, 2012, 08:27:08 AM »
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

  • Member
  • *****
  • Posts: 10464
  • Assembler is fun ;-)
    • MasmBasic
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #1 on: June 05, 2012, 10:10:52 AM »
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:
Quote
include \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:
Code: [Select]
Reading 176194 lines took 24 ms
Writing 1615 lines took 44 ms
Results attached, it needs some manual cleaning. Example:
Code: [Select]
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

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #2 on: June 05, 2012, 10:54:04 AM »
ouch !   :dazzled:

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

zooba

  • Guest
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #3 on: June 05, 2012, 11:38:13 AM »
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

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #4 on: June 05, 2012, 11:59:13 AM »
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

  • Guest
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #5 on: June 06, 2012, 02:57:55 PM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 7460
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #6 on: June 06, 2012, 05:24:11 PM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 10464
  • Assembler is fun ;-)
    • MasmBasic
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #7 on: June 06, 2012, 07:11:50 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--

  • Administrator
  • Member
  • ******
  • Posts: 7460
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #8 on: June 06, 2012, 07:25:04 PM »
Here is a cleaned (cleaned) set ALA QE Global replace.  :biggrin:
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 10464
  • Assembler is fun ;-)
    • MasmBasic
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #9 on: June 06, 2012, 08:26:00 PM »
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
Code: [Select]
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)
« Last Edit: June 06, 2012, 10:46:25 PM by jj2007 »

dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #10 on: June 07, 2012, 12:40:15 AM »
Holy crap!

is that Italiano or Deutsch ?


dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #12 on: June 07, 2012, 09:51:12 AM »
that's probably what the Pope says when he stubs his toe or something - must be Italian   :biggrin:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7460
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #13 on: June 07, 2012, 11:35:06 AM »
A German pope living in the Vatican probably swears in latin.

Quote
Irrumabo quod nocere.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 10464
  • Assembler is fun ;-)
    • MasmBasic
Re: Comprehensive x86 instruction set for MSVS2010?
« Reply #14 on: June 07, 2012, 12:04:57 PM »
That doesn't look correct, Hutch, it should be sancti stercore (German->Latin) :bgrin: