Question

ARM assembly language Write a program "fibonacci.s" that computes the Nth Fibonacci number where N is...

ARM assembly language

Write a program "fibonacci.s" that computes the Nth Fibonacci number where N is not so large that overflow of integer arithmetic is a concern. When your assembly language program is called it should expect the value of N to be passed using register r0 and your program should return the Nth Fibonacci number in register r0. Please include comments as well.

Do not just use the output generated by gcc -S

0 0
Add a comment Improve this question Transcribed image text
Answer #1
.MODEL SMALL

.STACK 64

.DATA
        VAL1    DB      01H
        VAL2    DB      01H
        LP      DB      00H
        V1      DB      00H
        V2      DB      00H
        NL      DB      0DH,0AH,'$'

.CODE

MAIN PROC
        MOV AX,@DATA
        MOV DS,AX

        MOV AH,01H
        INT 21H
        MOV CL,AL
        SUB CL,30H
        SUB CL,2

        MOV AH,02H
        MOV DL,VAL1
        ADD DL,30H
        INT 21H

        MOV AH,09H
        LEA DX,NL
        INT 21H

        MOV AH,02H
        MOV DL,VAL2
        ADD DL,30H
        INT 21H

        MOV AH,09H
        LEA DX,NL
        INT 21H


DISP:
        MOV BL,VAL1
        ADD BL,VAL2

        MOV AH,00H
        MOV AL,BL
        MOV LP,CL
        MOV CL,10
        DIV CL
        MOV CL,LP

        MOV V1,AL
        MOV V2,AH

        MOV DL,V1
        ADD DL,30H
        MOV AH,02H
        INT 21H

        MOV DL,V2
        ADD DL,30H
        MOV AH,02H
        INT 21H

        MOV DL,VAL2
        MOV VAL1,DL
        MOV VAL2,BL

        MOV AH,09H
        LEA DX,NL
        INT 21H


        LOOP DISP

        MOV AH,4CH
        INT 21H

MAIN ENDP
END MAIN
Add a comment
Know the answer?
Add Answer to:
ARM assembly language Write a program "fibonacci.s" that computes the Nth Fibonacci number where N is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence....

    Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence. Your program should prompt for an integer input n from the user. The program should call a recursive function to compute the nth fibonacci number. Your program must follow programming convention. You should submit program and screenshot of output in a single word/pdf file. You should use following recursive definition of fibonacci function: fib(0) = 0 fib(1) = 1 fib(n) = fib(n-1) +fib(n-2)

  • Write an ARM assembly language subroutine (named nfibo) to calculate and return the n-th Fibonacci number....

    Write an ARM assembly language subroutine (named nfibo) to calculate and return the n-th Fibonacci number. Fibonacci numbers (or a Fibonacci sequence) are a series of numbers with a property that the next number in the series is a sum of previous two numbers. Starting the series from 0, 1 as the first two numbers we have 0, 1, (0 + 1) = 1, (1 + 1) = 2, (1 + 2) = 3, (2 + 3) = 5, (3...

  • Write an assembly language program that reads in a number, n, and outputs, Fibonacci number, F_n....

    Write an assembly language program that reads in a number, n, and outputs, Fibonacci number, F_n. Test your program on input 13. Turn in a listing of your program, and the results of this test run. (Your answer should be 233.)

  • Question 2 ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the...

    Question 2 ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper. (5 marks) Explain the difference between eor and eors instruction. Use an example to show why both forms are useful. а. b. (5 marks) Explain using an example what the "Idr r3, [r7,#4]" instruction does. c. (10 marks) The following is the assembly language generated by a C compile type mystery, %function mystery: args 0, pretend = 0, frame =...

  • Write a simple program in arm, assembly language , using only Registers, to test if 371...

    Write a simple program in arm, assembly language , using only Registers, to test if 371 is an Armstrong number. The program written should only have instruction set from the Cortex m0+. And then put a 1 in a register to show it It is, or 0 if it isn’t. The second program is about the Armstrong numbers. You assume it will be a 3-digit number which will be entered through the data area. You can use a register so...

  • python Write a function that takes as input a single integer parametern and computes the nth...

    python Write a function that takes as input a single integer parametern and computes the nth Fibonacci Sequence number The Fibonacci sequence first two terms are 1 and 1(so, if n - 2 your function should return 1). From there, the previous two values are summed to come up with the next result in the sequence 1.1,2,3,5,8,13, 21, 34, 55, etc.) For example, if the input is 7 then your function should return 13 26561.1615880 1 def Fibonacci(n): # your...

  • Write a program that computes the Fibonacci number for some input integer. (See segments 7.37 –...

    Write a program that computes the Fibonacci number for some input integer. (See segments 7.37 – 7.41 in your book for some info on the Fibonacci sequence or you can look it up on the Internet). The sequence is defined as the first two elements are each 1, after that each element in the sequence is the sum of the previous two elements. The first few numbers of the sequence are 1,1,2,3,5,8,13,21,34,55,… Your assignment is to write a program with...

  • Write a Java program that generates an array of Fibonacci numbers. Specifications: The program -Fills a...

    Write a Java program that generates an array of Fibonacci numbers. Specifications: The program -Fills a one-dimensional array with the first 30 Fibonacci numbers using a calculation to generate the numbers. Note: The first two Fibonacci numbers 0 and 1 should be generated explicitly as in -long[] series = new long[limit]; //create first 2 series elements series[0] = 0; series[1] = 1; -But, it is not permissible to fill the array explicitly with the Fibonacci series’ after the first two...

  • In mathematics, the Fibonacci numbers are the series of number that exhibit the following pattern: 0,1,1,2,3,5,8,13,21,34,55,89,144,.......

    In mathematics, the Fibonacci numbers are the series of number that exhibit the following pattern: 0,1,1,2,3,5,8,13,21,34,55,89,144,.... In mathematical notation the sequence Fn of Fibonacci number is defined by the following recurrence relation: Fn=Fn-1+Fn-2 With the initial values of F0=0 and F1=1. Thus, the next number in the series is the sum of the previous two numbers. Write a program that asks the user for a positive integer N and generate the Nth Fibonacci number. Your main function should handle user...

  • In Haskell: Write a recursive function fibonacci that computes the n-th Fibonacci number. fibonacci :: Int...

    In Haskell: Write a recursive function fibonacci that computes the n-th Fibonacci number. fibonacci :: Int -> Int Write a recursive function myProduct that multiplies all the numbers in a list. myProduct :: [Integer] -> Integer Using the technique of List Comprehension write a function that would remove even numbers from a list of lists. For Example: given input: [[1,2,3,4], [6,3,45,8], [4,9,23,8]] expected output: [[1,3], [3,45],[9,23]]. Show how the library function replicate :: Int -> a-> [a] that produces a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT