I’m running through some code right now on gdb and I have no clue what these two instructions actually do. If anyone could help me out, I’d really appreciate it.
add -0x2c(%ebp, %ebx, 4), %eax
cmp %eax, -0x28(%ebp, %ebx, 4)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
x86 assembly is usually much easier to understand when you write it in Intel syntax instead of AT&T syntax.
In Intel syntax it would be:
The first instruction (
add) adds the value of word stored in the memory address[ebp+4*ebx-0x2C]to the value ofeax, and stores the sum ineax.The second instruction (
cmp) compareseaxwith[ebp+4*ebx-0x28]by subtracting the value ofeaxfrom the value of the word stored in the memory address[ebp+4*ebx-0x28], and sets flags (OF,SF,ZF,AF,PF,CF) accordingly but does not save the result anywhere.cmpis exactly the same assub, the only difference being the fact that insubthe result is saved, incmpnot.The type of comparison is usually created in the form a conditional jump. In x86 assembly there are a lot of conditional jumps and whether they branch depends on the values of the flags.