.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson
Eminent IT

Home >> Articles >> .Net Framework >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to view disassembly code in VS 2005/2008?

Posted By:Jean Paul       Posted Date: February 07, 2011    Points: 75    Category: .Net Framework    URL: http://www.dotnetspark.com  

This article will show How to view disassembly code in VS 2005/2008?

I found that some of the community members are relying on third party tools to view the disassembly generated for .Net applications.  It would be nice to see that already this feature is supported by Visual Studio 2005/2008.

In the following application I am trying to show the disassembly generated.

Step 1: Create a console application

Create a new console application and replace the main method with the following code.

    static void Main(string[] args)
        int i = 10;
        int j = 20;

        int sum = i + j;

        Console.WriteLine(string.Format("Sum is: {0}", sum));

Step 2: Place a breakpoint at the end of Main method()

It is depicted in the image below.

Step 3: Execute the application

Press F5 to debug the application, and when control reaches the breakpoint, right click on the code and from the context menu choose  "Go to Disassembly"

You can see the following output:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DisassemblyApp
    class Program
        static void Main(string[] args)
00000000  push        ebp 
00000001  mov         ebp,esp
00000003  sub         esp,20h
00000006  mov         dword ptr [ebp-4],ecx
00000009  cmp         dword ptr ds:[04D2707Ch],0
00000010  je          00000017
00000012  call        5F311579
00000017  xor         edx,edx
00000019  mov         dword ptr [ebp-10h],edx
0000001c  xor         edx,edx
0000001e  mov         dword ptr [ebp-0Ch],edx
00000021  xor         edx,edx
00000023  mov         dword ptr [ebp-8],edx
00000026  nop             
            int i = 10;
00000027  mov         dword ptr [ebp-8],0Ah
            int j = 20;
0000002e  mov         dword ptr [ebp-0Ch],14h

            int sum = i + j;
00000035  mov         eax,dword ptr [ebp-8]
00000038  add         eax,dword ptr [ebp-0Ch]
0000003b  mov         dword ptr [ebp-10h],eax

            Console.WriteLine(string.Format("Sum is: {0}", sum));
0000003e  mov         ecx,62D708h
00000043  call        FA13826C
00000048  mov         dword ptr [ebp-14h],eax
0000004b  mov         eax,dword ptr ds:[02AF8370h]
00000051  mov         dword ptr [ebp-1Ch],eax
00000054  mov         eax,dword ptr [ebp-14h]
00000057  mov         edx,dword ptr [ebp-10h]
0000005a  mov         dword ptr [eax+4],edx
0000005d  mov         eax,dword ptr [ebp-14h]
00000060  mov         dword ptr [ebp-20h],eax
00000063  mov         ecx,dword ptr [ebp-1Ch]
00000066  mov         edx,dword ptr [ebp-20h]
00000069  call        dword ptr ds:[001F8E20h]
0000006f  mov         dword ptr [ebp-18h],eax
00000072  mov         ecx,dword ptr [ebp-18h]
00000075  call        dword ptr ds:[04816794h]
0000007b  nop             
0000007c  nop             
0000007d  mov         esp,ebp
0000007f  pop         ebp 
00000080  ret             

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend