How to view the disassembly in Code::Blocks?

2019-04-07 18:32发布

问题:

I read this article about some low level underpinnings of C/C++, and the author is basically showing us through the assembly code generated by the compiler, line by line. He is using VS 2010, but I don't, I use Code::Blocks. How do I view the disassembly there? When I go to debugger, and click disassembly, it shows me a blank window...

This is the C++ (.cpp) code (the whole code) I compiled:

int main()
{
    int x = 1;
    int y = 2;
    int z = 0;

    z = x + y;

    return 0;
}

回答1:

The kind of disassembly that the author shows in the article is called inter-leaved disassembly ( C and disassembly interleaved ) which a few IDEs like Visual Studio support. Code Blocks does not support. But Code Blocks has a separate disassembly window like this

Select a source line. Right Click. Say Run to Cursor. Now Debug->Debugging Windows->Disassembly. Instead of Run to cursor you can also set break points and then do this. But somehow it wasn't going well with mine, so I am suggesting Run to Cursor method.

Hope it helps.