C/C++語言的本質(Directly)

    記得大三實習的時候在一位喜歡做破解的哥們的影響下了解反彙編調試這麼一回事兒,於是實踐後
恍然悟到:(1)學彙編不爲寫彙編,而爲透析c/c++諸多細節的本質(2)大神的境界應該是每寫一句
c/c++語言,其相應彙編代碼便了然於心。
    題外話:本文總是把c語言和c++語言寫在一起,是因爲筆者喜歡,筆者認爲如果說彙編語言是機器
語言的第一重映射,那麼c語言就是彙編語言的第一重映射、c++是c語言的第1.5重映射。因此要精通
c語言,必然要熟悉彙編,要精通c++必然要精通c語言。
   列舉下我通過彙編透析到的的語言本質吧:
   (1)The different of pointer and reference
       int i=0;
       int& j=i;
       int* k=&i;// int* k=&j;
      General explain:reference: alias(the same entity) ; pointer: address(addressof entity)
      In fact, the implement of pointer and reference by assembly is the same. Such as following:
       int i = 5;
       int* pi = &i;
       int ri = i;
     相關的彙編語言代碼:

```asm
       mov dword ptr [i], 5
    
       lea eax, [i]
       mov dword ptr[pi], eax;
    
       lea eax, dword ptr[i]
       mov dword ptr[ri], eax

```

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章