Code::Blocks Forums

User forums => Help => Topic started by: skirby on August 17, 2006, 12:07:41 pm

Title: How to debug assembly piece of code
Post by: skirby on August 17, 2006, 12:07:41 pm
Hello,

I would like to know if it is possible to debug a piece of code written in assembly?
If a put a break point in the assembly code, it is ignored.
Tracing the code with F7 or Shift+F7 does not enter in the assembly code.

Here is a simple piece of code if someone want to make a test.
Code
#include <stdio.h>

int A = 5;
int B = 10;
int C = 0;

int main() {
  C = A + B;
  printf("C : %d\n", C);
  C = 0;

  __asm (
    ".intel_syntax noprefix \n"
    "mov eax, dword ptr [_A] \n"
    "add eax, dword ptr [_B] \n"
    "mov dword ptr [_C], EAX \n"
    ".att_syntax \n"
  );

  printf("C : %d\n", C);

  return 0;
}

So, is there a way to debug assembly code?

Thanks and have a nice day.
Title: Re: How to debug assembly piece of code
Post by: tiwag on August 17, 2006, 12:19:04 pm
use the disassembly window and step through your code with Alt-F7
Title: Re: How to debug assembly piece of code
Post by: mandrav on August 17, 2006, 12:19:36 pm
Works fine here. But you have to put the breakpoint on the _asm line (or earlier in the file). Then, to debug the assembly, use Debug->Next instruction (Alt-F7). This should also open the disassembly window automatically...

[attachment deleted by admin]
Title: Re: How to debug assembly piece of code
Post by: skirby on August 17, 2006, 12:36:41 pm
Thank you very much tiwag and mandrav.

I didn't know this functionnality.
It will help me a lot in the futur.

Decidedly, Code::Blocks is really the best Open Source, Cross-platform, Free C/C++ IDE.

Have a nice day.