Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to find and print a Fibonacci sequence of numbers. The Fibonacci

ID: 3687362 • Letter: W

Question

Write a program to find and print a Fibonacci sequence of numbers. The Fibonacci sequence is defined as follows:

Fn = Fn-2 + Fn-1 , where F0 = 0 and F1 = 1

Your program should prompt the user to enter a limit, print the sequence up to the limit, and then indicate the greatest power of 2 that the final number printed is divisible by. Assume user input will be between 1 and 4096.

Here is what the user will see when the program is executed:

-----------------------------------

This program prints the Fibonacci sequence

1 1 2 3 5 8 13 21 34

The last number 34 is divisible by 2.

1 1 2 3 5 8 13 21 34 55 89 144

The last number 144 is divisible by 16.

Goodbye.

------------------------------ Requirements:

1. Follow the requirements as described above.

2. Name your source file ‘lastname4.m’.

3. Document your code

Notes:

1. Make sure to declare word elements before declaring bytes or strings.

2. After using the scanf function, you can then use either the ld or ldub commands to access the input values. The command ld is for the word size elements and ldub is for the byte size elements.

-------------------------------------------------------

Use sparc architecture and not another programming language like C or java or else.

Explanation / Answer

.section ".data" prompt1:.asciz " enter a limit on the largest number to be displayed:" fibio:.asciz "%d " fibio:.asciz "%d " maximum:.word 0 yesno:.byte 0 nl: .byte 0 format1:.asciz"%d%c" format2:.asciz"%c%c" .section ".text" .align 4 .global main main: save %sp,-96,%sp set prompt1,%o0 call printf nop set format1,%o0 set maximum,%o1 set nl,%o2 set nl,%o2 call scanf nop ld[%o1],%l0 !counter ldub[%o2],%l1 mov 1,%l2 !older mov 1,%l3 !old mov 2,%l4 !current test:cmp %l4,%l0 bge done nop add %l2,%l3,%l2 add %l2,%l4,%l2 mov %l2,%l5 !next number mov %l3,%l2 mov %l4,%l3 mov %l5,%l4 cmp %l5,%l0 bg done nop set fibio,%o0 mov %l5,%o1 call printf nop ba test nop done: ret restore

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote