The Problem A Zeckendorf number is defined for all positive integers as the number of Fibonacci numbers which must be added to equal a given number k. So, the positive integer 28 is the sum of three Fibonacci numbers (21, 5, and 2), so the Zeckendorf number for k = 28 is three. Wikipedia is a satisfactory reference for our purposes for more details of the Zeckendorf and Fibonacci numbers. In both cases, you do not need to read the entire Wikipedia entry. Your assignment is to write two ARM assembly language functions which calculate Zeckendorf and Fibonacci numbers. Zeck function The first function, which should be named zeck, receives an integer parameter in register zero. This will be the variable k we discussed above. Your code should return the Zeckendorf number for k in register zero when complete.   If the parameter k is zero, return zero. If the parameter k is negative, return minus 1. If the parameter k is too large to calculate, return minus 1. Fib function The other function, which should be named fib, receives an integer parameter in register zero. This will also be the variable k we discussed above. Your code should return the Fibonacci number which is less than or equal to k in register zero when complete.   If the parameter k is zero, return zero. If the parameter k is negative, return minus 1. If the parameter k is too large to calculate, return minus 1. Notes Your program must only use positive integers for all calculations and the result variable. The zeck function should call the fib function to obtain the nearest Fibonacci number to k. You may find it easiest to develop the fib function first. It then subtracts the Fibonacci number from the current value of k, adds one to a counter (the Zeckendorf number), and continues calling fib() until k is zero. You may find it easiest to look up the Fibonacci numbers in a table within the fib function. The largest Fibonacci number that fits in 31 bits is 1836311903. Test Program Your functions should be tested within the following program: MOV R0,#33 ; this will be the value of k BL zeck END    Requirements Correct numeric result for all cases Correct rejection of invalid input  Following naming and message format standards  Test Data You should test your program with various integer values. Include test cases of: k = one less than a given Fibonacci number, k = that Fibonacci number, k = one more than that Fibonacci number, zero, negative numbers, 1836311902 1836311903, and 1836311904 It appear

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
icon
Concept explainers
Question

The Problem

Zeckendorf number is defined for all positive integers as the number of Fibonacci numbers which must be added to equal a given number k. So, the positive integer 28 is the sum of three Fibonacci numbers (21, 5, and 2), so the Zeckendorf number for k = 28 is three.

Wikipedia is a satisfactory reference for our purposes for more details of the Zeckendorf and Fibonacci numbers. In both cases, you do not need to read the entire Wikipedia entry.

Your assignment is to write two ARM assembly language functions which calculate Zeckendorf and Fibonacci numbers.

Zeck function

The first function, which should be named zeck, receives an integer parameter in register zero. This will be the variable k we discussed above. Your code should return the Zeckendorf number for k in register zero when complete.

 

If the parameter k is zero, return zero.

If the parameter k is negative, return minus 1.

If the parameter k is too large to calculate, return minus 1.

Fib function

The other function, which should be named fib, receives an integer parameter in register zero. This will also be the variable k we discussed above. Your code should return the Fibonacci number which is less than or equal to k in register zero when complete.

 

If the parameter k is zero, return zero.

If the parameter k is negative, return minus 1.

If the parameter k is too large to calculate, return minus 1.

Notes

Your program must only use positive integers for all calculations and the result variable.

The zeck function should call the fib function to obtain the nearest Fibonacci number to k. You may find it easiest to develop the fib function first. It then subtracts the Fibonacci number from the current value of k, adds one to a counter (the Zeckendorf number), and continues calling fib() until k is zero.

You may find it easiest to look up the Fibonacci numbers in a table within the fib function.

The largest Fibonacci number that fits in 31 bits is 1836311903.

Test Program

Your functions should be tested within the following program:

MOV R0,#33 ; this will be the value of k

BL zeck

END 

 

Requirements

  1. Correct numeric result for all cases
  2. Correct rejection of invalid input 
  3. Following naming and message format standards 

Test Data

You should test your program with various integer values. Include test cases of:

  • k = one less than a given Fibonacci number,
  • k = that Fibonacci number,
  • k = one more than that Fibonacci number,
  • zero,
  • negative numbers,
  • 1836311902
  • 1836311903, and
  • 1836311904

It appears that the largest positive integer which fits into an ARM-modified immediate value is 2139095040.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning