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:
add eax,[ebp+4*ebx-0x2C]
cmp [ebp+4*ebx-0x28],eax
The first instruction (add
) adds the value of word stored in the memory address [ebp+4*ebx-0x2C]
to the value of eax
, and stores the sum in eax
.
The second instruction (cmp
) compares eax
with [ebp+4*ebx-0x28]
by subtracting the value of eax
from 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. cmp
is exactly the same as sub
, the only difference being the fact that in sub
the result is saved, in cmp
not.
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.