[C Development] infinite loop while (1) and (;;)

Source: Internet
Author: User

There are two common methods for infinite loops:

While (1) and (;;).

The two methods have the same effect. In contrast, which one is better?

After compilationCodeComparison:

1. While (1 );

00401028MoV eax,10040102d test eax, eax0040102f je main+ 23 h (00401033)00401031JMP main + 18 h (00401028)

2. (;;);

00401033JMP main + 23 h (00401033)

The comparison shows that the for (;) command is less than the while (1) command, and does not occupy registers, and does not judge or jump.


PS: In vc6.0, Set breakpoint debugging. Choose View> debug Windows> disassembly to view the compiled code.




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.