printf stack out stack _printf pressure stack

Source: Internet
Author: User
printf function of the stack sequence is from right to left pressure stack, the calculation of the expression value of the order is also from right to left, due to the variety of input data types, pressure stack when the data or data address MOV to register, and then the register pressure stack example:
#include <iostream>
using namespace std;
int main () {
    int arr[] = {6, 7, 8, 9,};
    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;
}

The output of the program in VS2013 is as follows:

Analysis:

Description

The real start of the pressure stack operation is from the Mov esi,esp start.
EAX is the addition register
MOV Eax,dword ptr[ptr] is an indirect addressing of the source operand.

The 360 questions are as follows:

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;
}

Output: 5101100

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.