WHAT THE FUCK DOES THE DAMN LEA INSTRUCTION DO THAT MOV DOESN'T?
Name:
Anonymous2007-04-19 20:06 ID:26amq1tl
doesn't affect the flags
Name:
Anonymous2007-04-19 20:48 ID:923hHve8
you can do a lot with lea actually
its useful for quick additions
for example
lea eax,[edx+ecx]
would result in eax = edx+ecx
don't forget that you can have multipliers for it, its useful in general
I believe I heard somewhere that Mov is also faster
Name:
Anonymous2007-04-20 5:52 ID:iOAX+s8M
>>6
algorithm used > difference between instructors.
remember that
Name:
Anonymous2007-04-20 6:43 ID:nnknohvK
Both names can be confusing.
MOV (Move) just copies data (reg-reg, reg-imm, reg-mem, mem-reg, and IIRC, mem-imm).
LEA (Load Effective Address) uses the processor effective address calculation unit (different from usual arithmetic operations) as if it would calculate a memory address for a memory operation, but stores the result in a register. This engine is able to perform certain operations with certain registers (IIRC, in 32 bit mode, addition of two any registers plus immediate value and a bit shift), all optional and in a simple clock cycle (in theory). As a drawback, it doesn't set FLAGS/EFLAGS.
In theory, LEA is faster than its equivalent series of MOV, ADD, and SHL/SHR instructions, so while this unit was intended to calculate memory offsets (e.g. as required by MOV EAX, [ESI+ECX]), it's also offered as an alternative simple, fast, incomplete arithmetic unit.
Whether LEA is faster than the equivalent regular ALU instructions, it depends on the processor you're using. I know it used to be a good optimization. I don't know how it's now. Benchmark, then let me know, for curiosity.
Name:
Anonymous2007-04-20 7:27 ID:9nOyFz8D
>>7 algorithm used > difference between instructors
actually a given algorithm will execute a number of extructions dependant on the inputs, that number of instructions is important.
the algorithm defines the relation.