ASM: add 0xFFFFFFFF

Im currently reversing the disassembly and stumbled upon a chain of instructions that I don't understand: This is a pointer to an object in esi .

 .text:00C20263 cmp dword ptr [esi+80h], 0 .text:00C2026A jnz short loc_C2027D 

As you can see, if the element +0x80 not equal to 0 (the member is an integer), the code goes to 00C2027D :

 .text:00C2027D add dword ptr [esi+80h], 0FFFFFFFFh .text:00C20284 jnz short loc_C20291 

These two instructions are the ones that I really don’t understand. First of all, the member is increased by 0xFFFFFFFF; but since the element is not equal to 0, will this instruction not exceed the maximum value of a 32-bit integer? And when is the jnz command jnz ?

Can I indicate what the purpose of these two instructions is?

+4
source share
1 answer

For a signed variable, 0FFFFFFFFh is the same as -1, so this subtracts the value from the value and checks to see if it made it zero. Compilers often emit "adding a negative value" rather than an auxiliary instruction, apparently because it allows you to reuse the compiler logic for addition and subtraction.

+13
source

All Articles