?
quasimodule schrieb:
freecrac schrieb:
LEA soll bei Shifts um 2, 4 und 8 Bits schneller als SHL/SHR (486+) sein.
du meinst sicherlich left shifts um 1,2 oder 3 Bits
Ja genau, so war es gemeint.
http://en.wikibooks.org/wiki/X86_Disassembly/Code_Obfuscation
The difference is that lea is quick (because it only adds a register and a small constant), whereas the add and mul instructions are more versatile, but slower. lea is used for arithmetic in this fashion very frequently, even when compilers are not actively optimizing the code.
http://en.wikibooks.org/wiki/X86_Assembly/Data_Transfer
lea can be used not only for calculating addresses, but also general-purpose unsigned integer arithmetic (with the caveat and possible advantage that FLAGS are unmodified). This can be quite powerful, since the src operand can take up to 4 parameters: base register, index register, scalar multiplier and displacement, e.g. [eax + edx*4 -4] (Intel syntax) or -4(%eax, %edx, 4) (GAS syntax). The scalar multiplier is limited to constant values 1, 2, 4, or 8 for byte, word, double word or quad word offsets respectively.
http://www.fermi.mn.it/linux/quarta/x86/lea.htm
(mit Liste aus dem INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986)
Operand Size Address Size Action Performed
16 16 16-bit effective address is calculated and
stored in requested 16-bit register
destination.
16 32 32-bit effective address is calculated. The
lower 16 bits of the address are stored in
the requested 16-bit register destination.
32 16 16-bit effective address is calculated. The
16-bit address is zero-extended and stored
in the requested 32-bit register destination.
32 32 32-bit effective address is calculated and
stored in the requested 32-bit register
destination.
freecrac schrieb:
unser Ergebniss muss eine gültige Adresse ergeben.
muss es nicht, da kein Speicherzugriff erfolgt.
Für diese Adressberechnung ist zwar kein Speicherzugriff nötig, aber unsere effektive Adresse die sich daraus errechnen läßt, die muss ja in unser Zielregister auch hinein passen und dort kann deswegen auch keine ungültige Adresse hinein gebracht werden.
Dirk