Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of lea 0x0(%esi),%esi

lea    0x0(%esi),%esi

I believe it has no result and is simply filling space. Is this the case?

like image 883
Brian Avatar asked May 08 '12 20:05

Brian


People also ask

What does Lea mean in assembly?

lea — Load effective address. The lea instruction places the address specified by its first operand into the register specified by its second operand. Note, the contents of the memory location are not loaded, only the effective address is computed and placed into the register.

What does Lea mean in C?

lea is an abbreviation of "load effective address". It loads the address of the location reference by the source operand to the destination operand.

What is ESI register for?

Registration is the process by which every employer/factory and its every employee employed for wages, is identified for the purpose of the Scheme, and their individual records are set up for them. EMPLOYERS CAN NOW SUBMIT APPLICATION ONLINE FOR REGISTRATION UNDER ESI ACT THROUGH.

Which flags are affected after performing LEA instruction?

LEA does not affect any flag. This instruction loads new values into the specified register and into the DS register from four successive memory locations. The word from two memory locations is copied into the specified register and the word from the next two memory locations is copied into the DS registers.


1 Answers

Its a NOP. It adds the contents of %esi and 0x0, and puts the result in %esi. Somebody either has a clumsy code generator or needs to fill N bytes, where this instruction is the right size.

LEA instructions execute quite fast (typically 1 clock), so this is a lot better than N nops.

The x86 being as quirky as it is, has a variety of instructions that effectively don't do anything but fill differing numbers of bytes. You may find other useless instructions of different lengths. You tend to find instructions that are long but execute in 1 clock or less.

The AMD x86-64 manual has some suggestions as to what should be used for NOPs; they suggest one of the prefix opcodes repeated a number of times before an actual NOP, IIRC. Such prefix opcodes are consumed very quickly by the instruction fetch engine; mostly their cost is hidden in instruction pre-fetch, and not in instruction execution time.

like image 146
Ira Baxter Avatar answered Oct 06 '22 02:10

Ira Baxter