为什么单片机C语言中用for(;;)比用while(1)好

来源:百度知道 编辑:UC知道 时间:2024/06/21 15:29:56
我在一本书上看到这么说的

我们看看它们编译后的代码:
编译前:
while (1);
编译后:
mov eax,1
test eax,eax
je foo+23h
jmp foo+18h
编译前:
for (;;);
编译后:
jmp foo+23h
显然,for (;;)指令少,不占用寄存器,而且没有判断、跳转,比while (1)好。

up