	.text
	.global sum
	
sum:	# Setup code
	pushl %ebp
	movl %esp, %ebp
	# No callee-save regs being used
	# If we use eax, ecx, and edx we don't have to save/restore

	# Body
	movl 8(%ebp), %edx
	movl $0, %eax
	movl $1, %ecx

	# Jump to middle so don't have to repeat test
	jmp test

loop:	addl %ecx, %eax
	incl %ecx
test:	cmpl %edx, %ecx
	jle loop

	# Finish code
	movl %ebp, %esp
	popl %ebp
	ret
