Hello everyone,


Two questions after readnig this article,

http://www.microsoft.com/msj/0298/hood0298.aspx

1.

why using LEA to do multiplication is faster than using MUL?

"Using "LEA EAX,[EAX*4+EAX]" turns out to be faster than the MUL instruction."

2.

"The TEB's linear address can be found at offset 0x18 in the TEB." -- what
means linear address? Something like array, which elements are put next to
each other? What means non-linear address?


thanks in advance,
George

Re: Two basic questions about generated assembly by David

David
Wed Jul 16 03:51:25 CDT 2008

>Two questions after readnig this article,
>
>http://www.microsoft.com/msj/0298/hood0298.aspx
>
>1.
>
>why using LEA to do multiplication is faster than using MUL?
>
>"Using "LEA EAX,[EAX*4+EAX]" turns out to be faster than the MUL instruction."

The article says:

"The LEA instruction uses hardwired address generation tables that
makes multiplying by a select set of numbers very fast (for example,
multiplying by 3, 5, and 9). Twisted, but true."

Having said that, it's an old article, and it may no longer be the
case with newer processors.

>"The TEB's linear address can be found at offset 0x18 in the TEB." -- what
>means linear address? Something like array, which elements are put next to
>each other?

In this context I believe it means the contiguous address space (4GB
in Win32) that a process normally sees. It's not the real physical
address range.

For definitive answers, try something like this:

http://download.intel.com/design/processor/manuals/253665.pdf

Dave