Reference and pointer assembly code in C + +

Source: Internet
Author: User

int main (int argc, char * * argv)
{
。。。。。。。。
int x = 3;
003913DE mov dword ptr [x],3
int &y = x;
003913E5 Lea Eax,[x]
003913E8 mov dword ptr [Y],eax
int *z = &x;
003913EB Lea Eax,[x]
003913EE mov dword ptr [Z],eax

*z = 4;

003913F1 mov eax,dword ptr [z]
003913F4 mov dword ptr [eax],4

y = 5;
003913FA mov eax,dword ptr [y]
003913FD mov dword ptr [eax],5

x = 6;
00391403 mov dword ptr [x],6

cout<<x<<endl;
0039140A mov Esi,esp
0039140C mov eax,dword ptr [__imp_std::endl (398298h)]
00391411 push EAX
00391412 mov Edi,esp
00391414 mov Ecx,dword ptr [x]
00391417 push ECX
00391418 mov ecx,dword ptr [__imp_std::cout (398290h)]
0039141E call DWORD ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< ( 398294H)]
00391424 CMP EDI,ESP
00391426 call @ILT +325 (__RTC_CHECKESP) (39114Ah)
0039142B mov ecx,eax
0039142D call DWORD ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< ( 39829CH)]
00391433 CMP ESI,ESP
00391435 call @ILT +325 (__RTC_CHECKESP) (39114Ah)
return 0;
0039143A XOR Eax,eax
}

。。。。。。。。。

In C + +, the essence of a reference is a pointer

Reference is the compiler's encapsulation of pointers

Reference is addressed by the compiler and the pointer is addressed by the programmer

Concepts that are not referenced in disassembly code

Reference and pointer assembly code in C + +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.