Marcelo Toledo Blog

startups, empreendedorismo e tecnologia

Tag Archives: while

For or While?

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