Author Topic: How to debug assembly piece of code  (Read 4533 times)

Offline skirby

  • Almost regular
  • **
  • Posts: 137
How to debug assembly piece of code
« 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.

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: How to debug assembly piece of code
« Reply #1 on: August 17, 2006, 12:19:04 pm »
use the disassembly window and step through your code with Alt-F7

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: How to debug assembly piece of code
« Reply #2 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]
« Last Edit: August 17, 2006, 12:23:01 pm by mandrav »
Be patient!
This bug will be fixed soon...

Offline skirby

  • Almost regular
  • **
  • Posts: 137
Re: How to debug assembly piece of code
« Reply #3 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.