Marvee Amasi
Marvee Amasi
DIIDevHeads IoT Integration Server
Created by Marvee Amasi on 9/27/2024 in #firmware-and-baremetal
Understanding cmp Instruction in Assembly and Debugging with GDB
I’ve come across a specific instruction sequence that I need help understanding, particularly the comparison (cmp) operation and how to break at this point in GDB on an Intel Core i7-11700K Rocket Lake processor . It's low level assembly debugging in C and assembly mix
0x0000000000001410 <+241>: mov eax,DWORD PTR [rbp-0x74]
0x0000000000001413 <+244>: cmp DWORD PTR [rbp-0x70],eax
0x0000000000001416 <+247>: jne 0x149d <main+382>
0x000000000000141c <+253>: lea rsi,[rip+0xbf7] # 0x201a
0x0000000000001410 <+241>: mov eax,DWORD PTR [rbp-0x74]
0x0000000000001413 <+244>: cmp DWORD PTR [rbp-0x70],eax
0x0000000000001416 <+247>: jne 0x149d <main+382>
0x000000000000141c <+253>: lea rsi,[rip+0xbf7] # 0x201a
I’m particularly interested in the cmp instruction at 0x0000000000001413. From what I understand, it compares the value stored at [rbp-0x70] with the value currently in the eax register. What exactly is this cmp operation checking tho? What happens if the values are not equal? And how can I set a breakpoint at this comparison line in GDB to inspect the values before the comparison happens? I tried to break at the memory address 0x0000000000001413 using break *0x0000000000001413, but I’m not sure if that’s the correct approach
5 replies