int fib(int y) { if(y==0) return(0); if(y==1) return(1); return(fib(y-2)+fib(y-1)); } ------------------------------- .file "t.c" .text .globl fib .type fib, @function fib: pushl %ebp ; function prologue movl %esp, %ebp ; bp = sp pushl %ebx ; save bx subl $4, %esp ; allocate stack sp=sp-4 cmpl $0, 8(%ebp) ; compare mem[bp+8] to 0 jne .L2 ; jump not equal to L2 movl $0, -8(%ebp) ; store 0 into mem[bp-8] jmp .L1 ; jump to l1 .L2: cmpl $1, 8(%ebp) ; compare mem[bp+8] to 1 jne .L3 ; jump movl $1, -8(%ebp) jmp .L1 .L3: subl $12, %esp movl 8(%ebp), %eax ; eax = mem[bp+8] subl $2, %eax ; eax = eax - 2 pushl %eax call fib addl $16, %esp movl %eax, %ebx subl $12, %esp movl 8(%ebp), %eax decl %eax pushl %eax call fib addl $16, %esp addl %eax, %ebx movl %ebx, -8(%ebp) .L1: movl -8(%ebp), %eax movl -4(%ebp), %ebx leave ret .size fib, .-fib .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)" ------------------------------- .file "t.c" .text .p2align 2,,3 .globl fib .type fib, @function fib: pushl %ebp movl %esp, %ebp pushl %esi movl 8(%ebp), %esi xorl %eax, %eax ; eax = 0 testl %esi, %esi ; pushl %ebx je .L1 cmpl $1, %esi movl $1, %eax je .L1 subl $12, %esp leal -2(%esi), %edx ;edx = esi - 2 pushl %edx call fib leal -1(%esi), %edx movl %eax, %ebx movl %edx, (%esp) call fib leal (%eax,%ebx), %eax ; eax = eax + ebx .p2align 2,,3 .L1: leal -8(%ebp), %esp popl %ebx popl %esi leave ret .size fib, .-fib .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)"