Skip to content

Instantly share code, notes, and snippets.

@hogelog
Created March 17, 2009 09:51
Show Gist options
  • Save hogelog/80435 to your computer and use it in GitHub Desktop.
Save hogelog/80435 to your computer and use it in GitHub Desktop.
.file "loop_while_for.c"
.text
.globl sum_for
.type sum_for, @function
sum_for:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl $0, -8(%ebp)
movl $0, -4(%ebp)
jmp .L2
.L3:
movl -4(%ebp), %eax
addl %eax, -8(%ebp)
addl $1, -4(%ebp)
.L2:
cmpl $999, -4(%ebp)
jle .L3
movl -8(%ebp), %eax
leave
ret
.size sum_for, .-sum_for
.globl sum_while
.type sum_while, @function
sum_while:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl $0, -8(%ebp)
movl $0, -4(%ebp)
jmp .L6
.L7:
movl -4(%ebp), %eax
addl %eax, -8(%ebp)
addl $1, -4(%ebp)
.L6:
cmpl $999, -4(%ebp)
jle .L7
movl -8(%ebp), %eax
leave
ret
.size sum_while, .-sum_while
.ident "GCC: (Ubuntu 4.3.2-1ubuntu12) 4.3.2"
.section .note.GNU-stack,"",@progbits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment