Implement the above fib function in assembly

Assignment Help Assembly Language
Reference no: EM131299254

Assembly Language Lab

Fibonacci numbers are integers 0, 1, 1, 2, 3, 5, 8, 13, 21 ... If function fib(n) represents the nth Fibonacci number, we have fib(n) = fib(n-1) + fib(n-2) for n > 2, and fib(1) = 0, fib(2) = 1. Therefore, we can implement the recursive function fib in c++ as follows:

int fib(int n){
if ((n == 1) || (n == 2))
return n - 1;
else
return fib(n-1) + fib(n-2);
}

In this lab, we will write an assembly program that computes and displays the nth Fibonacci number for any positive integer n that the user entered. To implement this program, we need to

1) Implement the above fib function in assembly, i.e., translate fib into an equivalent assembly procedure;

2) Implement your main procedure which lets the user enter the number n, calls the procedure fib to get the nth Fibonacci number, and displays this Fibonacci number.

Please avoid using directives such as IF-ELSE in your assembly code.

Requirements:

1. Submit your source code (.asm file) which should run correctly.
2. Necessary comments are needed in your code.
3. Turn in a lab report. The lab report should include three parts: Introduction, Implementation, and Summary. The introduction briefly describes the purpose of this lab. The implementation part gives detailed description on how you implemented the task, including the runtime screen shots, as well as necessary discussions. The summary concludes the lab.

Reference no: EM131299254

Questions Cloud

Find the solution by applying suitable numerical methods : Provide a plot comparing f(t) to f~(t). Formulate the problem as an optimization problem with a proper objective function, I(ωo), and find the solution by applying suitable numerical methods. You may use LSE minimization
Prove that the output spectrum of the system exhibits growth : Assuming a third-order nonlinearity for the envelope detector in Figure, prove that the output spectrum of the system exhibits growth in the adjacent channels.
Identify a plan that addresses legal and ethical issues : Identify the principles and legalities of ethical issues within the health care system - Identify a plan that addresses legal and ethical issues in a health care policy.
Possible unemployment in the market : Explain the effect on wages, levels of employment, and possible unemployment in the market most directly affected by this law. Also, what forms of competition among workers might be more prevalent with the higher minimum wage?
Implement the above fib function in assembly : Implement the above fib function in assembly, i.e., translate fib into an equivalent assembly procedure; Implement your main procedure which lets the user enter the number n, calls procedure fib to get the nth Fibonacci number.
Are you surprised that 42% of fatalities occur on those days : What percent of the week do Friday, Saturday, and Sunday make up? Are you surprised that 42% of fatalities occur on those days?
Derive conditional demand for labour and capital : Derive conditional demand for labour and capital. Derive minimized total cost. Derive the equation of firm's expansion path. Draw the expansion path.
How is tylenol''s claim misleading even if true : The makers of Bayer Aspirin, in a reply headlined "Makers of Tylenol, Shame on You!" accused Tylenol of misleading by giving the truth but not the whole truth. You be the detective. How is Tylenol's claim misleading even if true?
Determine the efficiency of the stage : If transistor M2 in Figure has an average current of I0 and an average drainsource voltage of V0, determine the efficiency of the stage. Neglect the on-resistance of M1.

Reviews

Write a Review

Assembly Language Questions & Answers

  Write a subroutine for the equation using shift operations

Computer Architecture and Assembly Language Programming (CS401) - You cannot use MUL or DIV instructions, you have to perform multiplication and division (if required) using shift operations. AX and DX are the general purpose registers.

  Write two-pass assembler for subset of mips instruction set

Write a two-pass assembler for a subset of the MIPS instruction set. It should be able to read an assembly file from the command line and write the object code to standard output.

  Create simple 8-bit alu using add-subtract-shift functions

Create a simple 8-bit ALU. Requirements:The eight functions that you will implement are: add, subtract, and, or, shift left logical, less than, shift right logical.

  Write a single arm assembly language instruction

Write a single ARM assembly language instruction equivalent to a function that takes in three strings and checks if any are a substring to one another, if so return 1, if not return 0.

  Compute number of lines of the address bus

Compute number of lines of the address bus connecting the RAM and the CPU - what is the maximum size in Bytes for RAM.

  Implement a simple login and password system

You are to implement a simple login and password system. Your system should allow for TEN usernames and their associated passwords to be stored.

  Create a program that uses ia-32 assembly language

create a program that usesIA-32 assembly language. It converts integers in the array X to its hex string ad save its to array Y in the respictive locations.

  Write a mips assembly language program

write a MIPS assembly language program that can be loaded and executed using the MARS simulator.

  Program (starting at address $4000) to find the average

Write a program (starting at address $4000) to find the average of four 16-bit

  Document the protocols for passing

You must document the protocols for passing parameters and returning the result to the subroutine and also follow the convertion of saving and restoring registers in the subroutine.

  What problems would have to be solved to do it the other way

Most assemblers for the x86 have the destination address as the first operand and the source address as the second operand. What problems would have to be solved to do it the other way?

  Calculates the odds of winning any of the lottery jackpot

Calculates the odds of winning any of the lottery jackpot grand prizes. The calculated value is to be displayed on the QtSpim console screen with an appropriate commentary text. Such as "The odds are 1 in nnnn."

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd