|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include <iostream>
- using namespace std;
- int main(int argc, char const *argv[])
- {
- /* code */
- const int a=1;
- cout <<&a<<endl;
- int *p=(int *)&a;
- *p=20;
- cout << a<<endl<<&a<<endl<<p<<endl<<*p<<endl<<*(&a)<<endl;
- return 0;
- }
复制代码
我用的是MinGW-W64,这个a打印出来是1,但是*&a是20,???/
- cout << a << endl << &a << endl << p << endl << *p << endl << *(&a) << endl;
- 002E6B27 mov esi,esp
- 002E6B29 push offset std::endl<char,std::char_traits<char> > (02E1410h)
- 002E6B2E mov edi,esp
- 002E6B30 push 1
- 002E6B32 mov ebx,esp
- 002E6B34 push offset std::endl<char,std::char_traits<char> > (02E1410h)
- 002E6B39 mov eax,esp
- 002E6B3B mov ecx,dword ptr [p]
- 002E6B3E mov edx,dword ptr [ecx]
- 002E6B40 push edx
- 002E6B41 mov ecx,esp
- 002E6B43 push offset std::endl<char,std::char_traits<char> > (02E1410h)
- 002E6B48 mov edx,esp
- 002E6B4A mov dword ptr [ebp-0E0h],esi
- 002E6B50 mov esi,dword ptr [p]
- 002E6B53 push esi
- 002E6B54 mov esi,esp
- 002E6B56 push offset std::endl<char,std::char_traits<char> > (02E1410h)
- 002E6B5B mov dword ptr [ebp-0E4h],edi
- 002E6B61 mov edi,esp
- 002E6B63 mov dword ptr [ebp-0E8h],ebx
- 002E6B69 lea ebx,[a]
- 002E6B6C push ebx
- 002E6B6D mov ebx,esp
- 002E6B6F push offset std::endl<char,std::char_traits<char> > (02E1410h)
- 002E6B74 mov dword ptr [ebp-0ECh],eax
- 002E6B7A mov eax,esp
- 002E6B7C push 1
- 002E6B7E mov dword ptr [ebp-0F0h],ecx
- 002E6B84 mov ecx,dword ptr [_imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A (02EC098h)]
- 002E6B8A mov dword ptr [ebp-0F4h],eax
- 002E6B90 mov dword ptr [ebp-0F8h],edx
- 002E6B96 call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (02EC09Ch)]
- 002E6B9C mov ecx,dword ptr [ebp-0F4h]
- 002E6BA2 cmp ecx,esp
- 002E6BA4 call __RTC_CheckEsp (02E1276h)
- 002E6BA9 mov ecx,eax
- 002E6BAB call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (02EC0ACh)]
- 002E6BB1 cmp ebx,esp
- 002E6BB3 call __RTC_CheckEsp (02E1276h)
- 002E6BB8 mov ecx,eax
- 002E6BBA call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (02EC0A8h)]
- 002E6BC0 cmp edi,esp
- 002E6BC2 call __RTC_CheckEsp (02E1276h)
- 002E6BC7 mov ecx,eax
- 002E6BC9 call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (02EC0ACh)]
复制代码
在vs2017下这一句的反汇编结果,可以看到,这几个地方直接push的是1,也就是直接把字面值给push进去了
|
|