lundi 9 septembre 2019

mov && lea which one is faster

i have a question .in c++ 
int a = 1;
int *p = &a;
auto p_ptr = p;//1
auto &p_ptr2 = p;//2

//1 &&2  option ,which one is faster ,which is the best?why

// here is the assembly language:

    mov        dword ptr [a],1 
    lea        eax,[a]  
    mov        dword ptr [p],eax 
    mov        eax,dword ptr [p]  
    mov        dword ptr [p_ptr],eax 
    lea        eax,[p]  
    mov        dword ptr [p_ptr2],eax 

// compare 1 & 2 is same as (3)lea eax,[p] && (4)mov dword ptr [p_ptr],eax.

// so i want to know (3) && (4) which one is faster ? why?

Aucun commentaire:

Enregistrer un commentaire