您的位置:首页 > 产品设计 > UI/UE

while(true)与for(;;)的区别

2017-08-14 17:18 399 查看
//debug版本
#include<iostream>
using namespace std;
int main()
{
//for (;;);
/*
00C152BE  jmp         main + 1Eh (0C152BEh)//直接跳转到循环,只有一条语句
*/
int i;
while (true);
/*
012C52BE  mov         eax, 1
012C52C3  test        eax, eax
012C52C5  je          main + 29h (012C52C9h)
012C52C7  jmp         main + 1Eh (012C52BEh)
*/
}
/*
总结:
1. for(;;)指令少,不占用寄存器,
2. while(true)要占用寄存器,指令多一些
//在release版本下,都是一条指令
//优化等级Od(不优化)O1(优化体积最小),O2(速度最快),Ox(完全优化)
*/


////debug版本
//#include<iostream>
//using namespace std;
//int main()
//{
//  int i;
//  //for (;;);
//  //013812A0  jmp         main(013812A0h)
//  while (true);
//  //013B12A0  jmp         main (013B12A0h)
//}
///*
//  release版本下
//  都是一条指令
//*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c语言