Why is cmp $0xffffffffffffffff, %edi used in assembly?

It compares the register %edi with the constant $0xffffffffffffffff which is actually the constant -1.

Up vote 4 down vote favorite 1 share g+ share fb share tw.

While I was studying assembly code, I saw below code segment. I am a bit confused. Mov $0x0, %ecx lea 0x3(%rdi), %eax cmp $0xffffffffffffffff, %edi ;?

Cmovle %eax, %rdi I have marked line by?. I don't understand why that line is used in assembly code? Assembly : x86 64 bit EDIT: I haven't any comparison in my code.

For this reason, I wonder why? Note: I haven't find relevant title for that question. Help and inform me if you find one.

So, I can change assembly link|improve this question edited Nov 2 '11 at 7:49 asked Nov 2 '11 at 7:37user478571.

4 It looks like a comparison against -1. – Mysticial Nov 2 '11 at 7:42 Can you show us the code that produces this? – Mysticial Nov 2 '11 at 7:51 @Mysticial, I can't.

Forgive me. I took only question sheet before leaving home not code. – user478571 Nov 2 '11 at 7:55.

2 It should be stressed that it's -1 only for a 64-bit two's compliment value. – Arafangion Nov 2 '11 at 7:52 2 ... and then the following instruction (CMOVLE) copies the contents of EAX into RDI on the condition that EDI was Less than or Equal to -1 (it can check that because the CMP instruction sets the results of comparison in the FLAGS register). Btw, I'm a bit surprised to see several operand size mismatches (RDI & EAX in LEA, 64-bit -1 & EDI in CMP, and EAX & RDI in CMOV).

I'd expect all of them 64-bit or 32-bit. Is the above (dis)assembly correct? – Alex Nov 2 '11 at 7:57 Three errors in four lines, @OP you need to be more careful when copying text – drhirsch Nov 2 '11 at 9:08.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions