Recursive FibonacciRecursively calculate the nth Fibonacci n

Recursive Fibonacci//Recursively calculate the nth Fibonacci number int fib(int n) {if (n

Solution

fib:

pushq r1

movq r2,r1

subq r2

movl r3, r1

cmpl 0, r1

jg .L4

movl 0, r4

jmp .L5

.L4:

movl r1, r4

subl 1, r4

movl r4, r3

call fib

movl r4, r1

movl r1, r4

subl 2, r4

movl r4, r3

call fib

movl r4, r1

movl r1, r6

movl r1,r4

addl r6, r4

.L5:

leave

ret

main:

pushq r1

movq r2, r1

subq r2

movl 8, r3

call fib

movl r4, r1

movl r1, r4

movl r4, r5

movl 0, r3

movl 0, r4

call printf

movl 0, r4

leave

ret

 Recursive Fibonacci//Recursively calculate the nth Fibonacci number int fib(int n) {if (n Solutionfib: pushq r1 movq r2,r1 subq r2 movl r3, r1 cmpl 0, r1 jg .L
 Recursive Fibonacci//Recursively calculate the nth Fibonacci number int fib(int n) {if (n Solutionfib: pushq r1 movq r2,r1 subq r2 movl r3, r1 cmpl 0, r1 jg .L

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site