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:
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:
Using the iLDASM
Now that you have the executable, you can disassemble the code using iLDASM
That’s it, you have now seen the assembly language that is used by the hardware on your system.
Comments
Anonymous
November 16, 2011
IL is not assembly language. The IL that ILDASM shows you is later converted to native code (assembly) during runtime.Anonymous
November 16, 2011
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!Anonymous
November 16, 2011
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...Anonymous
November 17, 2011
The comment has been removed