Denio raised this question:

“What is faster, this while or this for?”

He wrote this in the blackboard:

        for (;;) {                
        }
        while (1) {
        }

The answer in assembly is:

For:

	.text
.globl _main
_main:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
L2:
	jmp	L2
	.subsections_via_symbols

While:

	.text
.globl _main
_main:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
L2:
	jmp	L2
	.subsections_via_symbols

If you enjoyed this post, make sure you subscribe to my RSS feed!