Using the ILDASM

Translate This Page

Using the ILDASM

  • Comments 4

What does the code look like when it is prepared for use by the microprocessor?  To do this you would examine the code using the Ildasm.exe (MSIL Disassembler), which is installed when you install Professional or Ultimate versions of Visual Studio or the Windows SDK. 

Installation requirements:

If you don’t have Visual Studio, you can always download Visual Studio Express for Windows Phonhe via the AppHub at:

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27570 

But this only gets you Visual Studio 2010 Express for Windows Phone 7, in this case you will need to also download the following to get the  iLDASM.exe

Once you have that installed, you will need the Windows SDK, this installation can take a bit of time, about 10 minutes or so:

http://www.microsoft.com/download/en/details.aspx?id=8442

Using iLASM

Once you have downloaded and install the Visual Studio and/or the Windows SDK, you can run the ILDASM.EXE from the XNA Studio Command Line (or Visual Studio Command Line) command line or simply type in ILDASM in the search box on the start menu.

You will get a small form either way and here you can disassemble your code.  I show this in an illustration toward the bottom of the blog, you may need to scroll down.

Let’s take a look at disassembly of some simple code, like a “hello world” program. 

Create the code using the command line and notepad:

Let’s take the following code:

using System;
// A "Hello World!" program in C# 
namespace HelloWorld
{
    class Hello
    {
        static void Main()
        {
            System.Console.WriteLine("Hello World!");
        }
    }
} 

 

Open Notepad and paste the code into Notepad, save the Notepad is saved it with a cs extension, for example:

Hello.cs

Put into a folder you can use the cmd prompt to get to and run from either Visual Studio Command prompt or Windows SDK Command prompt:

image

Using the iLDASM

Now that you have the executable, you can disassemble the code using iLDASM

image

 

That’s it, you have now seen the assembly language that is used by the hardware on your system.

Leave a Comment
  • Please add 4 and 8 and type the answer here:
  • Post
  • IL is not assembly language. The IL that ILDASM shows you is later converted to native code (assembly) during runtime.

  • Thanks Oded!  This is exactly correct, the IL is an "intermediate language" and isn't real assembly code used by the hardware.  Since there are different boards, CPUs, etc. there is an interim layer that is provided by the vendors of laptops and desktops.  The IL is served up to this, let's call it the OEM Application Layer which then changes this standardized intermediate language into the appropriate language.

    Nice work ODED!

  • Sorry, but the comment from Oded isn't "exactly correct". Native code is machine language (pure binary). Assembler code is a symbolic text-based representation of it.

    Picky, picky, picky...

  • Larry Smith,

    Thank you, when I said "This is exactly correct" I meant that I don't get very many comments and I wrote that in a way to indicate that Oded was correct but actually stating that I was exactly correct.  Which is very confusing and outside of the Law is a poor way to write.

    So now the whole thread is confused.

    Oh crud, bottom line: I appreciate every comment.

    Now that is EXACTLY CORRECT!

Page 1 of 1 (4 items)
Generic Content

Legal Note:

  1. The author, Sam Stokes, is an employee of Microsoft
  2. There is no guarantee that anything I write is correct, I do try to make sure that what I write is correct.
  3. Use anything written in this blog at your own risk
  4. Test what I write about before using the information
  • Sometimes posts will disappear because I realized that they really don't fit with the total chaos of what I write about
  • Links are tested and available on date of publication, what others do with their links are out of my control

Restrictions:

  • Whatever I write on this blog is unedited by management or anyone, which should be obvious from the randomness of the blog.  I simply write about things I like.
  • Microsoft does not restrict me in anyway, so I generallyblather about whatever I want to.
  • For personal reasons I will not write about:
    • Company confidential stuff, mainly because Microsoft is more transparent than any company I have ever worked for.
    • Other people unless they give me permission to write about them