printf壓棧出棧_printf壓棧

來源:互聯網
上載者:User
printf函數的壓棧順序是從右至左壓棧,計算運算式值的順序也是從右至左,由於輸入資料類型的多樣性,壓棧的時候將資料或資料的地址mov到寄存器中,然後將寄存器壓棧 例子:
#include <iostream>using namespace std;int main(){    int arr[] = { 6, 7, 8, 9, 10 };    int *ptr = arr;    *(ptr++) += 123;    printf("%d,%d\n", *ptr, *(++ptr));    printf("%d,%d,%d,%d,%d\n", *ptr--,*ptr+20, *(ptr--), *ptr, *(++ptr));    int i = 5;    char ch = 't';    char str[10] = "test";    printf("%s %c %d\n", str, ch, i);    printf("%d %d %d %d\n", i, --i, i, i--);    system("pause");    return 0;}

程式在VS2013中的輸出如下:

分析:

說明:

真正開始壓棧操作是從mov esi,esp開始。
eax是加法寄存器
mov eax,dword ptr[ptr] 是源運算元的間接定址。

360筆試題如下:

int a[] = { 3, 4 }, b[] = { 5, 6 };struct st{    int num;    int *p;}s[2] = {100,a,100,b},*q = s;int main(){    int n;    printf("%d%d%d",*q->p,++q->num,(q++)->num);    return 0;}

輸出:5101100

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.