Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Mips fibonacci number implement with hard ware .text main: # Prompt user to input non-negative number la $a0,prompt li $v0,4 syscall li $v0,5 #Read the

Mips fibonacci number implement with hard ware

.text main: # Prompt user to input non-negative number la $a0,prompt li $v0,4 syscall li $v0,5 #Read the number(n) syscall move $t2,$v0 # n to $t2 # Call function to get fibonnacci #n move $a0,$t2 move $v0,$t2 jal fib #call fib (n) move $t3,$v0 #result is in $t3 # Output message and n la $a0,result #Print F_ li $v0,4 syscall move $a0,$t2 #Print n li $v0,1 syscall la $a0,result2 #Print = li $v0,4 syscall move $a0,$t3 #Print the answer li $v0,1 syscall la $a0,endl #Print ' ' li $v0,4 syscall # End program li $v0,10 syscall fib: # Compute and return fibonacci number beqz $a0,zero #if n=0 return 0 beq $a0,1,one #if n=1 return 1 #Calling fib(n-1) sub $sp,$sp,4 #storing return address on stack sw $ra,0($sp) sub $a0,$a0,1 #n-1 jal fib #fib(n-1) add $a0,$a0,1 lw $ra,0($sp) #restoring return address from stack add $sp,$sp,4 sub $sp,$sp,4 #Push return value to stack sw $v0,0($sp) #Calling fib(n-2) sub $sp,$sp,4 #storing return address on stack sw $ra,0($sp) sub $a0,$a0,2 #n-2 jal fib #fib(n-2) add $a0,$a0,2 lw $ra,0($sp) #restoring return address from stack add $sp,$sp,4 #--------------- lw $s7,0($sp) #Pop return value from stack add $sp,$sp,4 add $v0,$v0,$s7 # f(n - 2)+fib(n-1) jr $ra # decrement/next in stack zero: li $v0,0 jr $ra one: li $v0,1 jr $ra .data prompt: .asciiz "This program calculates Fibonacci sequence with recursive functions. Enter a non-negative number: " result: .asciiz "F_" result2: .asciiz " = " endl: .asciiz " 

4. Imagine you are given the following hardware blocks:

three registers (three 3-bit D flip flops).

a 3-bit full adder

a multiplexor

an 3-bit binary constant term "001" or "000"

Try to use these devices to implement the program in hardware. You should draw out your sketch on paper, showing the blocks and wires connecting them. You might look at http://www.toves.org/books/comps/ to see what these blocks are, what they do, and how to draw them.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions