Input Read three input values from the keyboard: the first number in the sequence, • the second number in the sequence, and the number of elements of the sequence. Each element of the sequence (beyond the first two) is equal to the sum of the previous two. For example, if the user inputs 3, 1, and 10, then your program should generate the sequence 3, 1, 4, 5, 9, 14, 23, 37, 60, 97. Output: For each element of the sequence that you generate, display the following: the number in decimal notation (using syscall 1). the number in hexadecimal. the number of 1-bits in the binary representation of the number.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 7PP: (Numerical) Using the srand() and rand() C++ library functions, fill an array of 1000 floating-point...
icon
Related questions
Topic Video
Question

Hi, can someone help write this MIPS assembly language program? It is based on the Fibonacci sequence. I am supposed to take in 3 inputs. 1st input is the first number in the sequence, the 2nd input is the 2nd number in the Fibonacci sequence. These are supposed to add up to start the sequence. The 3rd input from the user is supposed to tell the program how many numbers you need to generate. I then have to display the number is HEX and also the number of 1s in the binary sequence of the number displayed. Thanks!

Input
Read three input values from the keyboard:
the first number in the sequence,
the second number in the sequence, and
the number of elements of the sequence.
Each element of the sequence (beyond the first two) is equal to the sum of the previous two. For example, if the user inputs 3, 1, and 10, then
your program should generate the sequence 3, 1, 4, 5, 9, 14, 23, 37, 60, 97.
Output:
For each element of the sequence that you generate, display the following:
the number in decimal notation (using syscall 1).
the number in hexadecimal.
the number of 1-bits in the binary representation of the number.
For the example above, you would display
3
Ox00000003
2
1
0x00000001
1
4
0x00000004
1
Transcribed Image Text:Input Read three input values from the keyboard: the first number in the sequence, the second number in the sequence, and the number of elements of the sequence. Each element of the sequence (beyond the first two) is equal to the sum of the previous two. For example, if the user inputs 3, 1, and 10, then your program should generate the sequence 3, 1, 4, 5, 9, 14, 23, 37, 60, 97. Output: For each element of the sequence that you generate, display the following: the number in decimal notation (using syscall 1). the number in hexadecimal. the number of 1-bits in the binary representation of the number. For the example above, you would display 3 Ox00000003 2 1 0x00000001 1 4 0x00000004 1
Ox00000003
2
0x00000001
4
0x00000004
5
0x00000005
2
9
Ox00000009
2
14
O×0000000E
23
0x00000017
4
37
Ox00000025
3
60
Ox0000003C
4
97
Ox00000061
The hex version can be displayed using system call 34.
You will not need to use either arrays or recursion for this problem. You are required to write a function which counts the number of ones in a
number. (Hint: Think about using bit operations to isolate each bit in the number, and add them together.)
Make sure to document your programs thoroughly. (This is especially important in assembly language programs, since the code itself is less
easily read than high-level language code.) This should include:
A block of comment lines at the beginning of the source file, giving the name and author of the program and a black-box description of
what it does.
A few comment lines between major sections of the program, describing the contents of each section.
A comment at the end of most source lines, describing what the instruction on that line does.
Transcribed Image Text:Ox00000003 2 0x00000001 4 0x00000004 5 0x00000005 2 9 Ox00000009 2 14 O×0000000E 23 0x00000017 4 37 Ox00000025 3 60 Ox0000003C 4 97 Ox00000061 The hex version can be displayed using system call 34. You will not need to use either arrays or recursion for this problem. You are required to write a function which counts the number of ones in a number. (Hint: Think about using bit operations to isolate each bit in the number, and add them together.) Make sure to document your programs thoroughly. (This is especially important in assembly language programs, since the code itself is less easily read than high-level language code.) This should include: A block of comment lines at the beginning of the source file, giving the name and author of the program and a black-box description of what it does. A few comment lines between major sections of the program, describing the contents of each section. A comment at the end of most source lines, describing what the instruction on that line does.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 7 images

Blurred answer
Knowledge Booster
Instruction Format
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++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr