I am attempting to learn how to write and understand x86 Assembly
as well as how to use GDB
and related tools effectively. To do this, I am using DDD
as a front-end for GDB
.
I am having trouble understanding what the condition flags (eflags?) are given that they appear to all be stored in the same register. I will post the register, the assembly code, and the related C code. Thank you for any assistance.
The register is displayed as follows at the given breakpoint: 0x293 [CF AF SF IF]
The following is the C code being run. (This is not an example of my coding style. I am trying to force GCC to use the compl
operation.)
int main( int argc, char* argv[] )
{
int a = 0;
int b = 2;
if( a == b ) // There is a breakpoint here!
goto EQUAL;
else
goto NEQUAL;
EQUAL:
return 3;
NEQUAL:
return 1;
}
The following is the assembly my machine broke it down into:
Dump of assembler code for function main:
0x0000000000400474 <+0>: push %rbp
0x0000000000400475 <+1>: mov %rsp,%rbp
0x0000000000400478 <+4>: mov %edi,-0x14(%rbp)
0x000000000040047b <+7>: mov %rsi,-0x20(%rbp)
0x000000000040047f <+11>: movl $0x0,-0x8(%rbp)
0x0000000000400486 <+18>: movl $0x2,-0x4(%rbp)
0x000000000040048d <+25>: mov -0x8(%rbp),%eax
0x0000000000400490 <+28>: cmp -0x4(%rbp),%eax
0x0000000000400493 <+31>: jne 0x40049d <main+41> # Break point here
0x0000000000400495 <+33>: nop
0x0000000000400496 <+34>: mov $0x3,%eax
0x000000000040049b <+39>: jmp 0x4004a3 <main+47>
0x000000000040049d <+41>: nop
0x000000000040049e <+42>: mov $0x1,%eax
0x00000000004004a3 <+47>: leaveq
0x00000000004004a4 <+48>: retq
End of assembler dump.