chapter1.4.3
// chapter1.4.3.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
int _tmain(int argc, _TCHAR* argv[])
{
std::cout<<"Enter two numbers:"<<std::endl;
int v1,v2;
std::cin>>v1>>v2;
int lower,upper;
if(v1<=v2)
{
lower=v1;
upper=v2;
}else
{
lower=v2;
upper=v1;
}
int sum=0;
for(int val=lower;val<=upper;++val)
{
sum+=val;
}
std::cout<<"Sum of "<<lower
<<" to "<<upper
<< " inclusive is "
<< sum<<std::endl;
return 0;
}
debug
od
004114C0 55 push ebp
004114C1 8BEC mov ebp, esp
004114C3 81EC 0C010000 sub esp, 10C
004114C9 53 push ebx
004114CA 56 push esi
004114CB 57 push edi
004114CC 8DBD F4FEFFFF lea edi, dword ptr [ebp-10C]
004114D2 B9 43000000 mov ecx, 43
004114D7 B8 CCCCCCCC mov eax, CCCCCCCC
004114DC F3:AB rep stos dword ptr es:[edi]
004114DE 8BF4 mov esi, esp
004114E0 A1 18A34100 mov eax, dword ptr [<&MSVCP90D.std::>
004114E5 50 push eax
004114E6 68 28784100 push 00417828 ; ASCII "Enter two numbers:"
004114EB 8B0D 14A34100 mov ecx, dword ptr [<&MSVCP90D.std::>; MSVCP90D.std::cout
004114F1 51 push ecx
004114F2 E8 6CFCFFFF call 00411163
004114F7 83C4 08 add esp, 8
004114FA 8BC8 mov ecx, eax
004114FC FF15 10A34100 call dword ptr [<&MSVCP90D.std::basic>; MSVCP90D.std::basic_ostream<wchar_t,std::char_traits<wchar_t> >::operator<<
00411502 3BF4 cmp esi, esp
00411504 E8 AAFCFFFF call 004111B3
00411509 8BF4 mov esi, esp
0041150B 8D45 EC lea eax, dword ptr [ebp-14]
0041150E 50 push eax
0041150F 8BFC mov edi, esp
00411511 8D4D F8 lea ecx, dword ptr [ebp-8]
00411514 51 push ecx
00411515 8B0D 0CA34100 mov ecx, dword ptr [<&MSVCP90D.std::>; MSVCP90D.std::cin
0041151B FF15 08A34100 call dword ptr [<&MSVCP90D.std::basic>; MSVCP90D.std::basic_istream<char,std::char_traits<char> >::operator>>
00411521 3BFC cmp edi, esp
00411523 E8 8BFCFFFF call 004111B3
00411528 8BC8 mov ecx, eax
0041152A FF15 08A34100 call dword ptr [<&MSVCP90D.std::basic>; MSVCP90D.std::basic_istream<char,std::char_traits<char> >::operator>>
00411530 3BF4 cmp esi, esp
00411532 E8 7CFCFFFF call 004111B3
00411537 8B45 F8 mov eax, dword ptr [ebp-8] ; v1
0041153A 3B45 EC cmp eax, dword ptr [ebp-14] ; v1<=v2
0041153D 7F 0E jg short 0041154D ; 大于
0041153F 8B45 F8 mov eax, dword ptr [ebp-8]
00411542 8945 E0 mov dword ptr [ebp-20], eax ; lower=v1
00411545 8B45 EC mov eax, dword ptr [ebp-14]
00411548 8945 D4 mov dword ptr [ebp-2C], eax ; upper=v2
0041154B EB 0C jmp short 00411559
0041154D 8B45 EC mov eax, dword ptr [ebp-14]
00411550 8945 E0 mov dword ptr [ebp-20], eax
00411553 8B45 F8 mov eax, dword ptr [ebp-8]
00411556 8945 D4 mov dword ptr [ebp-2C], eax
00411559 C745 C8 0000000>mov dword ptr [ebp-38], 0 ; val=0
00411560 8B45 E0 mov eax, dword ptr [ebp-20]
00411563 8945 BC mov dword ptr [ebp-44], eax
00411566 EB 09 jmp short 00411571
00411568 8B45 BC mov eax, dword ptr [ebp-44] ; val进eax
0041156B 83C0 01 add eax, 1 ; ++val
0041156E 8945 BC mov dword ptr [ebp-44], eax ; 保存val
00411571 8B45 BC mov eax, dword ptr [ebp-44] ; val进eax
00411574 3B45 D4 cmp eax, dword ptr [ebp-2C] ; val<=upper
00411577 7F 0B jg short 00411584
00411579 8B45 C8 mov eax, dword ptr [ebp-38] ; sum进eax
0041157C 0345 BC add eax, dword ptr [ebp-44] ; sum+=val
0041157F 8945 C8 mov dword ptr [ebp-38], eax
00411582 ^ EB E4 jmp short 00411568
00411584 8BF4 mov esi, esp
00411586 A1 18A34100 mov eax, dword ptr [<&MSVCP90D.std::>
0041158B 50 push eax
0041158C 8BFC mov edi, esp
0041158E 8B4D C8 mov ecx, dword ptr [ebp-38] ; sum
00411591 51 push ecx
00411592 68 14784100 push 00417814 ; ASCII " inclusive is "
00411597 8BDC mov ebx, esp
00411599 8B55 D4 mov edx, dword ptr [ebp-2C]
0041159C 52 push edx
0041159D 68 0C784100 push 0041780C ; ASCII " to "
004115A2 8BC4 mov eax, esp
004115A4 8B4D E0 mov ecx, dword ptr [ebp-20]
004115A7 51 push ecx
004115A8 68 00784100 push 00417800 ; ASCII "Sum of "
004115AD 8B15 14A34100 mov edx, dword ptr [<&MSVCP90D.std::>; MSVCP90D.std::cout
004115B3 52 push edx
004115B4 8985 F4FEFFFF mov dword ptr [ebp-10C], eax
004115BA E8 A4FBFFFF call 00411163
004115BF 83C4 08 add esp, 8
004115C2 8BC8 mov ecx, eax
004115C4 FF15 04A34100 call dword ptr [<&MSVCP90D.std::basic>; MSVCP90D.std::basic_ostream<char,std::char_traits<char> >::operator<<
004115CA 8B8D F4FEFFFF mov ecx, dword ptr [ebp-10C]
004115D0 3BCC cmp ecx, esp
004115D2 E8 DCFBFFFF call 004111B3
004115D7 50 push eax
004115D8 E8 86FBFFFF call 00411163
004115DD 83C4 08 add esp, 8
004115E0 8BC8 mov ecx, eax
004115E2 FF15 04A34100 call dword ptr [<&MSVCP90D.std::basic>; MSVCP90D.std::basic_ostream<char,std::char_traits<char> >::operator<<
004115E8 3BDC cmp ebx, esp
004115EA E8 C4FBFFFF call 004111B3
004115EF 50 push eax
004115F0 E8 6EFBFFFF call 00411163
004115F5 83C4 08 add esp, 8
004115F8 8BC8 mov ecx, eax
004115FA FF15 04A34100 call dword ptr [<&MSVCP90D.std::basic>; MSVCP90D.std::basic_ostream<char,std::char_traits<char> >::operator<<
00411600 3BFC cmp edi, esp
00411602 E8 ACFBFFFF call 004111B3
00411607 8BC8 mov ecx, eax
00411609 FF15 10A34100 call dword ptr [<&MSVCP90D.std::basic>; MSVCP90D.std::basic_ostream<wchar_t,std::char_traits<wchar_t> >::operator<<
0041160F 3BF4 cmp esi, esp
00411611 E8 9DFBFFFF call 004111B3
00411616 33C0 xor eax, eax
00411618 52 push edx
00411619 8BCD mov ecx, ebp
0041161B 50 push eax
0041161C 8D15 40164100 lea edx, dword ptr [411640]
00411622 E8 88FAFFFF call 004110AF
00411627 58 pop eax
00411628 5A pop edx
00411629 5F pop edi
0041162A 5E pop esi
0041162B 5B pop ebx
0041162C 81C4 0C010000 add esp, 10C
00411632 3BEC cmp ebp, esp
00411634 E8 7AFBFFFF call 004111B3
00411639 8BE5 mov esp, ebp
0041163B 5D pop ebp
0041163C C3 retn
ida
.text:004114C0
.text:004114C0 ; =============== S U B R O U T I N E =======================================
.text:004114C0
.text:004114C0 ; Attributes: bp-based frame
.text:004114C0
.text:004114C0 _wmain proc near ; CODE XREF: j__wmainj
.text:004114C0
.text:004114C0 var_10C = dword ptr -10Ch
.text:004114C0 val = dword ptr -44h
.text:004114C0 sum = dword ptr -38h
.text:004114C0 upper = dword ptr -2Ch
.text:004114C0 lower = dword ptr -20h
.text:004114C0 v2 = dword ptr -14h
.text:004114C0 v1 = dword ptr -8
.text:004114C0
.text:004114C0 push ebp
.text:004114C1 mov ebp, esp
.text:004114C3 sub esp, 10Ch
.text:004114C9 push ebx
.text:004114CA push esi
.text:004114CB push edi
.text:004114CC lea edi, [ebp+var_10C]
.text:004114D2 mov ecx, 43h
.text:004114D7 mov eax, 0CCCCCCCCh
.text:004114DC rep stosd
.text:004114DE mov esi, esp
.text:004114E0 mov eax, ds:__imp_?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z ; std::endl(std::basic_ostream<char,std::char_traits<char>> &)
.text:004114E5 push eax
.text:004114E6 push offset aEnterTwoNumber ; "Enter two numbers:"
.text:004114EB mov ecx, ds:__imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A ; std::basic_ostream<char,std::char_traits<char>> std::cout
.text:004114F1 push ecx
.text:004114F2 call j_??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z ; std::operator<<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char const *)
.text:004114F7 add esp, 8
.text:004114FA mov ecx, eax
.text:004114FC call ds:__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z ; std::basic_ostream<char,std::char_traits<char>>::operator<<(std::basic_ostream<char,std::char_traits<char>> & (*)(std::basic_ostream<char,std::char_traits<char>> &))
.text:00411502 cmp esi, esp
.text:00411504 call j___RTC_CheckEsp
.text:00411509 mov esi, esp
.text:0041150B lea eax, [ebp+v2]
.text:0041150E push eax
.text:0041150F mov edi, esp
.text:00411511 lea ecx, [ebp+v1]
.text:00411514 push ecx
.text:00411515 mov ecx, ds:__imp_?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A ; std::basic_istream<char,std::char_traits<char>> std::cin
.text:0041151B call ds:__imp_??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z ; std::basic_istream<char,std::char_traits<char>>::operator>>(int &)
.text:00411521 cmp edi, esp
.text:00411523 call j___RTC_CheckEsp
.text:00411528 mov ecx, eax
.text:0041152A call ds:__imp_??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z ; std::basic_istream<char,std::char_traits<char>>::operator>>(int &)
.text:00411530 cmp esi, esp
.text:00411532 call j___RTC_CheckEsp
.text:00411537 mov eax, [ebp+v1]
.text:0041153A cmp eax, [ebp+v2]
.text:0041153D jg short v1greaterv2
.text:0041153F mov eax, [ebp+v1]
.text:00411542 mov [ebp+lower], eax
.text:00411545 mov eax, [ebp+v2]
.text:00411548 mov [ebp+upper], eax
.text:0041154B jmp short loc_411559
.text:0041154D ; ---------------------------------------------------------------------------
.text:0041154D
.text:0041154D v1greaterv2: ; CODE XREF: _wmain+7Dj
.text:0041154D mov eax, [ebp+v2]
.text:00411550 mov [ebp+lower], eax
.text:00411553 mov eax, [ebp+v1]
.text:00411556 mov [ebp+upper], eax
.text:00411559
.text:00411559 loc_411559: ; CODE XREF: _wmain+8Bj
.text:00411559 mov [ebp+sum], 0
.text:00411560 mov eax, [ebp+lower]
.text:00411563 mov [ebp+val], eax
.text:00411566 jmp short loc_411571
.text:00411568 ; ---------------------------------------------------------------------------
.text:00411568
.text:00411568 valaddone: ; CODE XREF: _wmain+C2j
.text:00411568 mov eax, [ebp+val]
.text:0041156B add eax, 1
.text:0041156E mov [ebp+val], eax
.text:00411571
.text:00411571 loc_411571: ; CODE XREF: _wmain+A6j
.text:00411571 mov eax, [ebp+val]
.text:00411574 cmp eax, [ebp+upper]
.text:00411577 jg short printresult
.text:00411579 mov eax, [ebp+sum]
.text:0041157C add eax, [ebp+val]
.text:0041157F mov [ebp+sum], eax
.text:00411582 jmp short valaddone
.text:00411584 ; ---------------------------------------------------------------------------
.text:00411584
.text:00411584 printresult: ; CODE XREF: _wmain+B7j
.text:00411584 mov esi, esp
.text:00411586 mov eax, ds:__imp_?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z ; std::endl(std::basic_ostream<char,std::char_traits<char>> &)
.text:0041158B push eax
.text:0041158C mov edi, esp
.text:0041158E mov ecx, [ebp+sum]
.text:00411591 push ecx
.text:00411592 push offset aInclusiveIs ; " inclusive is "
.text:00411597 mov ebx, esp
.text:00411599 mov edx, [ebp+upper]
.text:0041159C push edx
.text:0041159D push offset aTo ; " to "
.text:004115A2 mov eax, esp
.text:004115A4 mov ecx, [ebp+lower]
.text:004115A7 push ecx
.text:004115A8 push offset aSumOf ; "Sum of "
.text:004115AD mov edx, ds:__imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A ; std::basic_ostream<char,std::char_traits<char>> std::cout
.text:004115B3 push edx
.text:004115B4 mov [ebp+var_10C], eax
.text:004115BA call j_??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z ; std::operator<<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char const *)
.text:004115BF add esp, 8
.text:004115C2 mov ecx, eax
.text:004115C4 call ds:__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z ; std::basic_ostream<char,std::char_traits<char>>::operator<<(int)
.text:004115CA mov ecx, [ebp+var_10C]
.text:004115D0 cmp ecx, esp
.text:004115D2 call j___RTC_CheckEsp
.text:004115D7 push eax
.text:004115D8 call j_??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z ; std::operator<<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char const *)
.text:004115DD add esp, 8
.text:004115E0 mov ecx, eax
.text:004115E2 call ds:__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z ; std::basic_ostream<char,std::char_traits<char>>::operator<<(int)
.text:004115E8 cmp ebx, esp
.text:004115EA call j___RTC_CheckEsp
.text:004115EF push eax
.text:004115F0 call j_??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z ; std::operator<<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char const *)
.text:004115F5 add esp, 8
.text:004115F8 mov ecx, eax
.text:004115FA call ds:__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z ; std::basic_ostream<char,std::char_traits<char>>::operator<<(int)
.text:00411600 cmp edi, esp
.text:00411602 call j___RTC_CheckEsp
.text:00411607 mov ecx, eax
.text:00411609 call ds:__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z ; std::basic_ostream<char,std::char_traits<char>>::operator<<(std::basic_ostream<char,std::char_traits<char>> & (*)(std::basic_ostream<char,std::char_traits<char>> &))
.text:0041160F cmp esi, esp
.text:00411611 call j___RTC_CheckEsp
.text:00411616 xor eax, eax
.text:00411618 push edx
.text:00411619 mov ecx, ebp
.text:0041161B push eax
.text:0041161C lea edx, dword_411640
.text:00411622 call j_@_RTC_CheckStackVars@8 ; _RTC_CheckStackVars(x,x)
.text:00411627 pop eax
.text:00411628 pop edx
.text:00411629 pop edi
.text:0041162A pop esi
.text:0041162B pop ebx
.text:0041162C add esp, 10Ch
.text:00411632 cmp ebp, esp
.text:00411634 call j___RTC_CheckEsp
.text:00411639 mov esp, ebp
.text:0041163B pop ebp
.text:0041163C retn
.text:0041163C _wmain endp
.text:0041163C
.text:0041163C ; ---------------------------------------------------------------------------
release
od
00401000 /$ 55 push ebp
00401001 |. 8BEC mov ebp, esp
00401003 |. 83E4 F8 and esp, FFFFFFF8
00401006 |. A1 38204000 mov eax, dword ptr [<&MSVCP90.std::e>
0040100B |. 83EC 08 sub esp, 8 ; 分配V1和V2
0040100E |. 53 push ebx
0040100F |. 55 push ebp
00401010 |. 56 push esi
00401011 |. 57 push edi
00401012 |. 50 push eax
00401013 |. 51 push ecx
00401014 |. 8B0D 44204000 mov ecx, dword ptr [<&MSVCP90.std::c>; MSVCP90.std::cout
0040101A |. 68 34214000 push 00402134 ; ASCII "Enter two numbers:"
0040101F |. 51 push ecx
00401020 |. E8 0B020000 call 00401230
00401025 |. 83C4 0C add esp, 0C
00401028 |. 8BC8 mov ecx, eax
0040102A |. FF15 40204000 call dword ptr [<&MSVCP90.std::basic_>; MSVCP90.std::basic_ostream<wchar_t,std::char_traits<wchar_t> >::operator<<
00401030 |. 8B0D 48204000 mov ecx, dword ptr [<&MSVCP90.std::c>; MSVCP90.std::cin
00401036 |. 8D5424 14 lea edx, dword ptr [esp+14] ; v2
0040103A |. 52 push edx
0040103B |. 8D4424 14 lea eax, dword ptr [esp+14] ; v1
0040103F |. 50 push eax
00401040 |. FF15 68204000 call dword ptr [<&MSVCP90.std::basic_>; MSVCP90.std::basic_istream<char,std::char_traits<char> >::operator>>
00401046 |. 8BC8 mov ecx, eax
00401048 |. FF15 68204000 call dword ptr [<&MSVCP90.std::basic_>; MSVCP90.std::basic_istream<char,std::char_traits<char> >::operator>>
0040104E |. 8B4424 10 mov eax, dword ptr [esp+10] ; eax->v1
00401052 |. 8B7424 14 mov esi, dword ptr [esp+14] ; esi->v2
00401056 |. 3BC6 cmp eax, esi ; v1>v2
00401058 |. 7F 04 jg short 0040105E
0040105A |. 8BD0 mov edx, eax ; v1<=v2;edx<-v1;lower
0040105C |. EB 04 jmp short 00401062
0040105E |> 8BD6 mov edx, esi
00401060 |. 8BF0 mov esi, eax
00401062 |> 33FF xor edi, edi
00401064 |. 33C9 xor ecx, ecx
00401066 |. 33ED xor ebp, ebp ; sum
00401068 |. 3BD6 cmp edx, esi ; esi:upper;edx:lower
0040106A |. 8BC2 mov eax, edx ; edx:lower->eax
0040106C |. 7F 29 jg short 00401097
0040106E |. 8BDE mov ebx, esi
00401070 |. 2BDA sub ebx, edx
00401072 |. 43 inc ebx
00401073 |. 83FB 02 cmp ebx, 2
00401076 |. 7C 15 jl short 0040108D
00401078 |. 8D5E FF lea ebx, dword ptr [esi-1]
0040107B |. EB 03 jmp short 00401080
0040107D | 8D49 00 lea ecx, dword ptr [ecx]
00401080 |> 03F8 /add edi, eax ; 奇数相加
00401082 |. 8D4C01 01 |lea ecx, dword ptr [ecx+eax+1] ; 偶数相加
00401086 |. 83C0 02 |add eax, 2
00401089 |. 3BC3 |cmp eax, ebx
0040108B |.^ 7E F3 \jle short 00401080
0040108D |> 3BC6 cmp eax, esi
0040108F |. 7F 02 jg short 00401093
00401091 |. 8BE8 mov ebp, eax
00401093 |> 03CF add ecx, edi ; ecx为总和
00401095 |. 03E9 add ebp, ecx ; ebp为总和
00401097 |> 8B0D 38204000 mov ecx, dword ptr [<&MSVCP90.std::e>; MSVCP90.std::endl
0040109D |. 51 push ecx
0040109E |. 55 push ebp
0040109F |. 68 48214000 push 00402148 ; ASCII " inclusive is "
004010A4 |. 56 push esi
004010A5 |. 68 58214000 push 00402158 ; ASCII " to "
004010AA |. 52 push edx
004010AB |. 8B15 44204000 mov edx, dword ptr [<&MSVCP90.std::c>; MSVCP90.std::cout
004010B1 |. 68 60214000 push 00402160 ; ASCII "Sum of "
004010B6 |. 52 push edx
004010B7 |. E8 74010000 call 00401230
004010BC |. 83C4 08 add esp, 8
004010BF |. 8BC8 mov ecx, eax
004010C1 |. FF15 5C204000 call dword ptr [<&MSVCP90.std::basic_>; MSVCP90.std::basic_ostream<char,std::char_traits<char> >::operator<<
004010C7 |. 50 push eax
004010C8 |. E8 63010000 call 00401230
004010CD |. 83C4 08 add esp, 8
004010D0 |. 8BC8 mov ecx, eax
004010D2 |. FF15 5C204000 call dword ptr [<&MSVCP90.std::basic_>; MSVCP90.std::basic_ostream<char,std::char_traits<char> >::operator<<
004010D8 |. 50 push eax
004010D9 |. E8 52010000 call 00401230
004010DE |. 83C4 08 add esp, 8
004010E1 |. 8BC8 mov ecx, eax
004010E3 |. FF15 5C204000 call dword ptr [<&MSVCP90.std::basic_>; MSVCP90.std::basic_ostream<char,std::char_traits<char> >::operator<<
004010E9 |. 8BC8 mov ecx, eax
004010EB |. FF15 40204000 call dword ptr [<&MSVCP90.std::basic_>; MSVCP90.std::basic_ostream<wchar_t,std::char_traits<wchar_t> >::operator<<
004010F1 |. 5F pop edi
004010F2 |. 33C0 xor eax, eax
004010F4 |. 5E pop esi
004010F5 |. 5D pop ebp
004010F6 |. 5B pop ebx
004010F7 |. 8BE5 mov esp, ebp
004010F9 |. 5D pop ebp
004010FA \. C3 retn
ida
.text:00401000
.text:00401000 ; =============== S U B R O U T I N E =======================================
.text:00401000
.text:00401000 ; Attributes: bp-based frame
.text:00401000
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char *envp)
.text:00401000 _main proc near ; CODE XREF: ___tmainCRTStartup+10Ap
.text:00401000
.text:00401000 v1 = dword ptr -8
.text:00401000 v2 = dword ptr -4
.text:00401000 argc = dword ptr 8
.text:00401000 argv = dword ptr 0Ch
.text:00401000 envp = dword ptr 10h
.text:00401000
.text:00401000 push ebp
.text:00401001 mov ebp, esp
.text:00401003 and esp, 0FFFFFFF8h
.text:00401006 mov eax, ds:__imp_?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z ; std::endl(std::basic_ostream<char,std::char_traits<char>> &)
.text:0040100B sub esp, 8 ; 分配v1 v2
.text:0040100E push ebx
.text:0040100F push ebp
.text:00401010 push esi
.text:00401011 push edi
.text:00401012 push eax
.text:00401013 push ecx
.text:00401014 mov ecx, ds:__imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A ; std::basic_ostream<char,std::char_traits<char>> std::cout
.text:0040101A push offset aEnterTwoNumber ; "Enter two numbers:"
.text:0040101F push ecx
.text:00401020 call ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z ; std::operator<<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char const *)
.text:00401025 add esp, 0Ch
.text:00401028 mov ecx, eax
.text:0040102A call ds:__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z ; std::basic_ostream<char,std::char_traits<char>>::operator<<(std::basic_ostream<char,std::char_traits<char>> & (*)(std::basic_ostream<char,std::char_traits<char>> &))
.text:00401030 mov ecx, ds:__imp_?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A ; std::basic_istream<char,std::char_traits<char>> std::cin
.text:00401036 lea edx, [esp+18h+v2]
.text:0040103A push edx
.text:0040103B lea eax, [esp+1Ch+v1]
.text:0040103F push eax
.text:00401040 call ds:__imp_??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z ; std::basic_istream<char,std::char_traits<char>>::operator>>(int &)
.text:00401046 mov ecx, eax
.text:00401048 call ds:__imp_??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z ; std::basic_istream<char,std::char_traits<char>>::operator>>(int &)
.text:0040104E mov eax, [esp+18h+v1]
.text:00401052 mov esi, [esp+18h+v2]
.text:00401056 cmp eax, esi
.text:00401058 jg short v1greaterv2
.text:0040105A mov edx, eax
.text:0040105C jmp short loc_401062 ; 奇数和
.text:0040105E ; ---------------------------------------------------------------------------
.text:0040105E
.text:0040105E v1greaterv2: ; CODE XREF: _main+58j
.text:0040105E mov edx, esi
.text:00401060 mov esi, eax
.text:00401062
.text:00401062 loc_401062: ; CODE XREF: _main+5Cj
.text:00401062 xor edi, edi ; 奇数和
.text:00401064 xor ecx, ecx ; 偶数和
.text:00401066 xor ebp, ebp ; sum
.text:00401068 cmp edx, esi ; lower>upper
.text:0040106A mov eax, edx ; eax:lower
.text:0040106C jg short printresult
.text:0040106E mov ebx, esi
.text:00401070 sub ebx, edx
.text:00401072 inc ebx
.text:00401073 cmp ebx, 2
.text:00401076 jl short loc_40108D
.text:00401078 lea ebx, [esi-1]
.text:0040107B jmp short loc_401080 ; edx为奇数和
.text:0040107B ; ---------------------------------------------------------------------------
.text:0040107D align 10h
.text:00401080
.text:00401080 loc_401080: ; CODE XREF: _main+7Bj
.text:00401080 ; _main+8Bj
.text:00401080 add edi, eax ; edx为奇数和
.text:00401082 lea ecx, [ecx+eax+1] ; ecx为偶数和
.text:00401086 add eax, 2 ; eax为下一个奇数
.text:00401089 cmp eax, ebx ; 大于uppper
.text:0040108B jle short loc_401080 ; edx为奇数和
.text:0040108D
.text:0040108D loc_40108D: ; CODE XREF: _main+76j
.text:0040108D cmp eax, esi
.text:0040108F jg short loc_401093 ; 奇数和偶数相加
.text:00401091 mov ebp, eax
.text:00401093
.text:00401093 loc_401093: ; CODE XREF: _main+8Fj
.text:00401093 add ecx, edi ; 奇数和偶数相加
.text:00401095 add ebp, ecx
.text:00401097
.text:00401097 printresult: ; CODE XREF: _main+6Cj
.text:00401097 mov ecx, ds:__imp_?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z ; std::endl(std::basic_ostream<char,std::char_traits<char>> &)
.text:0040109D push ecx
.text:0040109E push ebp ; 总和
.text:0040109F push offset aInclusiveIs ; " inclusive is "
.text:004010A4 push esi
.text:004010A5 push offset aTo ; " to "
.text:004010AA push edx
.text:004010AB mov edx, ds:__imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A ; std::basic_ostream<char,std::char_traits<char>> std::cout
.text:004010B1 push offset aSumOf ; "Sum of "
.text:004010B6 push edx
.text:004010B7 call ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z ; std::operator<<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char const *)
.text:004010BC add esp, 8
.text:004010BF mov ecx, eax
.text:004010C1 call ds:__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z ; std::basic_ostream<char,std::char_traits<char>>::operator<<(int)
.text:004010C7 push eax
.text:004010C8 call ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z ; std::operator<<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char const *)
.text:004010CD add esp, 8
.text:004010D0 mov ecx, eax
.text:004010D2 call ds:__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z ; std::basic_ostream<char,std::char_traits<char>>::operator<<(int)
.text:004010D8 push eax
.text:004010D9 call ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z ; std::operator<<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char const *)
.text:004010DE add esp, 8
.text:004010E1 mov ecx, eax
.text:004010E3 call ds:__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z ; std::basic_ostream<char,std::char_traits<char>>::operator<<(int)
.text:004010E9 mov ecx, eax
.text:004010EB call ds:__imp_??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z ; std::basic_ostream<char,std::char_traits<char>>::operator<<(std::basic_ostream<char,std::char_traits<char>> & (*)(std::basic_ostream<char,std::char_traits<char>> &))
.text:004010F1 pop edi
.text:004010F2 xor eax, eax
.text:004010F4 pop esi
.text:004010F5 pop ebp
.text:004010F6 pop ebx
.text:004010F7 mov esp, ebp
.text:004010F9 pop ebp
.text:004010FA retn
.text:004010FA _main endp
.text:004010FA
.text:004010FA ; ---------------------------------------------------------------------------