Question: Question 1 segment . bssfib _ array resq 5 ; space for 5 fibonacci numberssegment . textglobal mainmain: mov qword [ fib _ array ]

Question 1 segment .bssfib_array resq 5 ; space for 5 fibonacci numberssegment .textglobal mainmain: mov qword [fib_array],0 ; store fib(0)=0 mov qword [fib_array +8],1 ; store fib(1)=1 mov rcx,2 ; start at fib(2)start: cmp rcx,5 ; stop at fib(5) jge end ; exit loop if rcx greater than 5 push rcx ; save current index call fibonacci ; call fib(rcx) pop rcx ; restore index mov [fib_array + rcx *8], rax ; store result in fib_array inc rcx ; next index jmp start ; repeatend: leave retfibonacci: cmp rcx,0 ; check if rcx is 0 je base_case_zero ; return 0 cmp rcx,1 ; check if rcx is 1 je base_case_one ; return 1 push rcx ; save rcx dec rcx ; rcx -1 call fibonacci ; compute fib(rcx -1) mov rbx, rax ; save fib(rcx -1) result in rbx pop rcx ; restore rcx push rcx ; save rcx again sub rcx,2 ; rcx -2 call fibonacci ; fib(rcx -2) add rax, rbx ; add fib(rcx -1)+ fib(rcx -2) pop rcx ; restore rcx ret ; return resultbase_case_zero: mov rax, 0 ; fib(0)=0 retbase_case_one: mov rax, 1 ; fib(1)=1 ret
47
Microphone Muted
Tap to Unmute
Complete two ot the tollowing three programming problems.
Write an assembly program to compute Fibonacci numbers storing all the computed Fibonacci numbers in a quad-word array in memory. Fibonacci numbers are defined by:
f(n)={n=0,0n=1,1n>1,f(n-1)+f(n-2)
What is the largest i for you which you can compute fib(i)?
Write an assembly program to sort an array of double words using bubble sort. Bubble sort is defined as:PreviousNextDashboard
Question 1, I GOT IT WRONG SO I NEED HELP
Question 1 segment . bssfib _ array resq 5 ;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!