What does CMP dword ptr [EBP + local_c],0xdeadbeef mean?

0

Can somebody please explain what does

CMP        dword ptr [EBP + local_c], 0xdeadbeef

means. As far as I understand it compare the EBP+local_c location value with 0xdeadbeef, but I am not sure if that is true.

Thanks in advance

assembly
x86
asked on Stack Overflow Jul 13, 2020 by aurora • edited Jul 13, 2020 by fcdt

2 Answers

4

EBP + local_c is considered as memory address here, pointing to a dword value. The instruction

CMP  dword ptr [EBP + local_c], 0xdeadbeef

therefore compares the value at this memory position with 0xdeadbeef.

answered on Stack Overflow Jul 13, 2020 by fcdt
4

[EBP + local_c] is an address, in an indirect addressing mode. EBP plus some offset. For this assembly language (defined by the assembler not the target) to indicate what size this indirect address based instruction should operate on has dword ptr meaning the first operand is a 32 bit value at the address indicated. The second operand is an immediate value, a constant 0xdeadbeef.

This instruction is saying read the 32 bit value from address EBP + local_c and do a CMP instruction with the value 0xdeadbeef. CMP means do a subtract operation, save the flags but do not save the result. So the zero flag and others will be modified based on the subtract between these two operands.

Instructions that follow will ideally make decisions based on the flags computed during this instruction.

answered on Stack Overflow Jul 13, 2020 by old_timer

User contributions licensed under CC BY-SA 3.0