打开全局优化和速度优先是这样:
程序代码:
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.30319.01 TITLE C:\Users\TonyDeng\Documents\Visual Studio 2010\Projects\test4\test4\test.cpp .686P .XMM include listing.inc .model flat INCLUDELIB OLDNAMES EXTRN @__security_check_cookie@4:PROC PUBLIC _main ; Function compile flags: /Odtp /RTCsu ; File c:\users\tonydeng\documents\visual studio 2010\projects\test4\test4\test.cpp _TEXT SEGMENT tv65 = -16 ; size = 4 _max$ = -12 ; size = 4 _b$ = -8 ; size = 4 _a$ = -4 ; size = 4 _main PROC ; 2 : { 00000 55 push ebp 00001 8b ec mov ebp, esp 00003 83 ec 10 sub esp, 16 ; 00000010H 00006 b8 cc cc cc cc mov eax, -858993460 ; ccccccccH 0000b 89 45 f0 mov DWORD PTR [ebp-16], eax 0000e 89 45 f4 mov DWORD PTR [ebp-12], eax 00011 89 45 f8 mov DWORD PTR [ebp-8], eax 00014 89 45 fc mov DWORD PTR [ebp-4], eax ; 3 : int a = 1; 00017 c7 45 fc 01 00 00 00 mov DWORD PTR _a$[ebp], 1 ; 4 : int b = 2; 0001e c7 45 f8 02 00 00 00 mov DWORD PTR _b$[ebp], 2 ; 5 : int max; ; 6 : ; 7 : max = (a > b) ? a : b; 00025 8b 45 fc mov eax, DWORD PTR _a$[ebp] 00028 3b 45 f8 cmp eax, DWORD PTR _b$[ebp] 0002b 7e 08 jle SHORT $LN3@main 0002d 8b 4d fc mov ecx, DWORD PTR _a$[ebp] 00030 89 4d f0 mov DWORD PTR tv65[ebp], ecx 00033 eb 06 jmp SHORT $LN4@main $LN3@main: 00035 8b 55 f8 mov edx, DWORD PTR _b$[ebp] 00038 89 55 f0 mov DWORD PTR tv65[ebp], edx $LN4@main: 0003b 8b 45 f0 mov eax, DWORD PTR tv65[ebp] 0003e 89 45 f4 mov DWORD PTR _max$[ebp], eax ; 8 : } 00041 33 c0 xor eax, eax 00043 8b e5 mov esp, ebp 00045 5d pop ebp 00046 c3 ret 0 _main ENDP _TEXT ENDS END
授人以渔,不授人以鱼。