# fibonacci in assembler :-)
# Andreas Jaggi, 2007
#
# To run it, do the following:
# as --gstabs fibonacci.s -o fibonacci.o
# ld fibonacci.o -o fibonacci
# ./fibonacci ; echo $?

.section .text

.globl _start

_start:
	movl $12, %edx	# put the starting number in %edx

	movl $0, %ecx	# initialize counter
	
	movl $1, %eax	# initialize %eax and %ebx
	movl $0, %ebx

loop:
	cmpl %ecx, %edx
	je end_loop
	incl %ecx

	movl %eax, %esi
	movl %ebx, %eax
	addl %esi, %ebx

	jmp loop
end_loop:

	movl $1, %eax	# exit
	int $0x80
