Using the ILDASM

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:

https://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:

https://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.