Possible Duplicate:
Retrieve JIT output
Generating Assembly from C# code?
I started to learn assembler!
I would like to know if it is possible to see the assembly code for my c# code?
For example if I have:
int i;
How can I:
- see the assembly code?
- identify exactly in the assembly code what that does?
Use the debugger to see the machine code that’s generated by the jitter. Start debugging and single step or set a breakpoint. Right-click the editor window, select Go To Disassembly. Or use Debug + Windows + Disassembly. Other debug windows you’ll want to use are Registers and Memory, they show the raw cpu register and memory view. Right-click the Registers window to add registers to the view.
There are a few quirks about the assembly code you see there. All code starts at address 0, it doesn’t show the actual address since that’s entirely unpredictable due to the jitter. But that also causes a bug, the target address of CALL instructions is wrong. And you typically want to see the optimized code since that’s what actually runs on the user’s machine. Switch to the Release build and use Tools + Options, Debugging, General, untick the “Suppress JIT optimization on module load” option.