Question: I need this to be coded in YASM assembly language. Please use cmp and conditional jump statement like jnl or jmp. I am not advanced

I need this to be coded in YASM assembly language. Please useI need this to be coded in YASM assembly language. Please use "cmp" and conditional jump statement like "jnl" or "jmp". I am not advanced in assembly, so please use simple conditional statements.

Below is what I have currently:

section .data

fib_array: dq 0, 1 ;initialize array with first two fibonacci numbers

times 8 dq 0 ;reserve 8 quad-words for the array

section .text

global main

main:

mov rsi, 2 ;start computing fib numbers from index 2

.loop:

cmp rsi, 10 ;check if 10 numbers has been computed

jge .done ;if 10 numbers has been calculated, exit loop

mov rax, [fib_array + rsi*8 - 16] ;get previous fib number

add rax, [fib_array + rsi*8 - 8] ;add to previous two numbers

mov [fib_array + rsi*8], rax ;store computed number in array

inc rsi ;move to the next index within array

jmp .loop ;go back through loop

.done:

mov eax, 1

xor rdi, rdi

ret

1. Write an assembly program to compute Fibonacci numbers storing all the computed Fibonacc numbers in a quad-word array in memory. Fibonacci numbers are defined by: f(n)=n=0n=1n>101f(n1)+f(n2) - What is the largest i for you which you can compute fib(i)

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 Databases Questions!