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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education