News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

LEA

Started by bomz, July 04, 2011, 10:00:07 PM

Previous topic - Next topic

bomz

#60
The main - how use LEA right. Now I'm measured my last code in dedndave ticks count program and optimize it

QuoteItanium 2 (2002+), MMX, SSE2
1233 1227 1229 1235 1230 - empty
8872 8886 8885 8897 8877 - mov eax, value; mov value, eax
14120 14121 14118 14119 14119 - push value; pop value
Press any key to continue ...

hutch--

bomz,

Try a few of these and you can experiment with more.


    lea eax, [eax+eax]      ; *2
    lea eax, [eax+eax*2]    ; *3
    lea eax, [eax*4]        ; *4
    lea eax, [eax+eax*4]    ; *5

    lea eax, [eax+eax*2]    ;
    lea eax, [eax+eax]      ; *6

    mov ecx, eax
    lea eax, [eax*8]        ; *7
    sub eax, ecx

    lea eax, [eax*8]        ; *8
    lea eax, [eax+eax*8]    ; *9

    lea eax, [eax+eax*4]    ;
    lea eax, [eax+eax]      ; *10

    lea eax, [eax+eax*2]    ;
    lea eax, [eax*4]        ; *12

    lea eax, [eax+eax*4]    ;
    lea eax, [eax+eax*2]    ; *15

    lea eax, [eax*4]        ;
    lea eax, [eax*4]        ; *16

    lea eax, [eax+eax*8]    ;
    lea eax, [eax+eax]      ; *18
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

bomz

QuoteItanium 2 (2002+), MMX, SSE2
1231 1231 1229 1226 1229 - empty
5027 5028 5026 5027 5027 - lea eax, [eax+eax*2]; lea eax, [eax+eax]
5027 5027 5027 5027 5027 - lea edx, [eax+eax*2]; lea eax, [edx+edx]
Press any key to continue ...

Itanium 2 (2002+), MMX, SSE2
1228 1234 1231 1231 1230 - empty
5027 5028 5027 5027 5027 - lea eax, [eax+eax*2]; lea eax, [eax+eax]
5033 5032 5033 5032 5032 - mov edx, eax; lea edx, [edx+eax*2] ;lea eax, [edx+edx]      ; *6
Press any key to continue ...

Itanium 2 (2002+), MMX, SSE2
1228 1226 1227 1227 1231 - empty
5028 5028 5028 5026 5026 - lea eax, [eax+eax*2]; lea eax, [eax+eax]
5663 5662 5659 5665 5663 - mov ecx, eax; lea edx, [ecx+eax*2]; mov ecx, edx; lea eax, [ecx+edx]
Press any key to continue ...

Itanium 2 (2002+), MMX, SSE2
1234 1228 1228 1234 1229 - empty
5028 5028 5027 5026 5027 - lea eax, [eax+eax*2]; lea eax, [eax+eax]
10064 10064 10065 10064 10064 -  mov edx, eax; shl eax, 1; add eax, edx; shl eax, 1
Press any key to continue ...

Itanium 2 (2002+), MMX, SSE2
1229 1226 1230 1229 1229 - empty
5028 5028 5028 5027 5027 - lea eax, [eax+eax*2]; lea eax, [eax+eax]
9067 9067 9068 9069 9068 - lea edx, [eax+eax*2]; lea eax, [edx*2]
Press any key to continue ...



QuoteItanium 2 (2002+), MMX, SSE2
1236 1232 1253 1225 1234 - empty
1497 1511 1496 1494 1502 - lea     edx,[4*eax+eax]
3997 3995 3997 3996 3996 - lea     eax,[4*eax+eax]
Press any key to continue ...

Itanium 2 (2002+), MMX, SSE2
1226 1226 1234 1229 1235 - empty
8053 8056 8057 8054 8053 - lea eax, [4*EAX+EAX]; add edx, 1; lea eax, [2*EAX+ECX]
8052 8051 8051 8051 8049 - lea ebx, [4*EAX+EAX]; add edx, 1; lea eax, [2*EBX+ECX]
Press any key to continue ...

QuoteItanium 2 (2002+), MMX, SSE2
1227 1231 1228 1238 1233 - empty
8054 8056 8053 8054 8053 - lea eax, [4*EAX+EAX]; lea eax, [4*EAX+EAX]
2109 2111 2111 2113 2112 - lea eax, [4*EBX+ECX]; lea eax, [4*EDX+EDI]
Press any key to continue ...

QuoteItanium 2 (2002+), MMX, SSE2
1233 1225 1238 1226 1226 - empty
8058 8064 8059 8055 8054 - lea eax, [4*EAX+EAX]; lea eax, [2*EAX+ECX]
8052 8049 8052 8055 8049 - lea eax, [4*EAX+EAX]; lea ebx, [esi+edi]; lea eax, [2*EAX+ECX]
Press any key to continue ...

QuoteItanium 2 (2002+), MMX, SSE2
1233 1224 1232 1230 1239 - empty
8054 8057 8057 8054 8054 - lea eax, [4*EAX+EAX]; lea eax, [2*EAX+ECX]
8051 8053 8060 8051 8054 - lea eax, [4*EAX+EAX]; lea ebx, value; lea eax, [2*EAX+ECX]
Press any key to continue ...

QuoteItanium 2 (2002+), MMX, SSE2
1229 1236 1231 1232 1239 - empty
8056 8057 8055 8055 8054 - lea eax, [4*EAX+EAX]; lea eax, [2*EAX+ECX]
9058 9058 9058 9058 9058 - lea ebx, [4*EAX+EAX]; mov edx, ebx; lea eax, [2*EDX+ECX]
Press any key to continue ...


hutch--

bomz,

An Itanium 2 is not a native x86 architecture, are you running an Itanium in x86 emulation mode ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

bomz

QuoteItanium 2 (2002+), MMX, SSE2
1228 1228 1229 1231 1230 - empty
8054 8057 8055 8053 8053 - lea eax, [4*EAX+EAX]; lea eax, [2*EAX+ECX]
4034 4034 4034 4034 4034 - lea eax, [4*EAX+EAX]; mov ebx, eax; lea ebx, [2*EBX+ECX]
Press any key to continue ...

bomz

I have Pentium 4. Program recognize it like Itanium I don't know why



QuoteItanium 2 (2002+), MMX, SSE2
1227 1234 1230 1230 1226 - empty
8062 8070 8062 8063 8114 - lea eax, [4*EAX+EAX]; lea eax, [2*EAX+ECX]
9063 9062 9058 9059 9057 - lea eax, [4*EAX+EAX]; mov ebx, eax; lea eax, [2*EBX+ECX]
Press any key to continue ...

I am not already catch regularity

Quotelea ebx, [4*EAX+EAX]
   mov edx, ebx
   lea ebx, [2*EDX+ECX]
- 3000

hutch--

Your OS is giving the correct processor ID, its a Northwood core PIV, not an Itanium. An Itanium is a 64 bit native processor with a different instruction set. They are mainly useful for large processor count parallel processing. I still have a 2.8 gig Northwood processor running and they were a bit easier to code for than the later Prescott cores.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

bomz

I begin testing all code string-to-dword. there is no difference use lea or not. any combination of registers gives the same result to convert 100 to 100 need about 18000 program ticks

dedndave

Quoteconvert 100 to 100 need about 18000 program ticks

ouch !!!!

bomz - don't be concerned about the improper CPU identification
it is an old version of Jochen's ShowCpu function   :P

bomz

need 18000 p ticks for doing it 1000 times  :lol

lea ebx, [4*EAX+EAX]
   mov edx, ebx
   lea ebx, [2*EDX+ECX] this need 3000 but when put in s2w cycle it became 8000

jj2007

Quote from: dedndave on July 09, 2011, 03:46:23 PM
bomz - don't be concerned about the improper CPU identification
it is an old version of Jochen's ShowCpu function   :P

Bomz, what CPU does it show with the attachment of reply #50?

bomz

with the attachment of reply #50?  - ???????????????


bomz


bomz

Quote   lea ebx, [4*EAX+EAX]
   mov edx, ebx
   lea ebx, [2*EDX+ECX]  - 3000

Quote   lea ebx, [4*EAX+EAX]
   mov edx, ebx
   lea ebx, [2*EDX+ECX]
   mov eax, ebx - 10000