[C Language] Note q = (++ j) + (++ j) Value

Source: Internet
Author: User

Different compilers may produce different codes, resulting in different results.

 

The Code is as follows:

 #include <stdio.h>    j =   q =(++j)+(++j)+(++ }

 

Environment: win7

Compiler: GCC

IDE: vc ++ 6.0/DEV-C ++

Result: q = 22

: Q = (++ j) + (++ mov eax, dword ptr [ebp-] Move J = add eax, add 1 to the Register eax value, eax = 0040103C mov dword ptr [ebp-], eax moves the register value to the variable j, j = 0040103F mov ecx, dword ptr [ebp-] Move J = add ecx, in the register, ecx +, j = mov dword ptr [ebp-], ecx moves the value on the register ecx to J, J = mov edx, dword ptr [ebp-] Move J = 7 to register edx = 0040104B add edx, dword ptr [ebp-] edx value + j at this time j =, edx = + 0040104E mov eax, dword ptr [ebp-] add j = add eax and eax to 1. In this case, register eax = mov dword ptr [ebp-], eax moves the eax value to j = add edx, dword ptr [ebp-] edx value = edx + j = + 0040105A mov dword ptr [ebp-0Ch], move the edx value to j =

 

Environment: win7

Compiler: GCC

IDE: VC ++ 2008

Running result: 24

  q =(++j)+(++j)+(++  003A1818  add         eax,   //eax = 6   003A1821  add         ecx,  ecx = 7   003A182A  add         edx,   edx = 8     003A1839  mov         dword ptr [q],eax 

 

Related Article

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.