Question: Please comment every line of code I need to write a program using assembly language. I will be using mars 4.5. The assignment for this

Please comment every line of code

I need to write a program using assembly language. I will be using mars 4.5. The assignment for this program is to print out the first 20 fibonacci numbers and the running sum of the numbers as they are displayed.

For example, the output of the program should have first 5 numbers in the series.

Fibonacci series
Number total
1 1
1 2
2 4
3 7
5 12
... ...
... ...
... ...
6765 ????

Hint! Here is the skeleton of the code you will need to do this project.

Please comment every line of code I need to write a program

using assembly language. I will be using mars 4.5. The assignment for

.data fibs: .word 0 : 20 size: .word 20 prompt: .asciiz "How many fibonacci numbers to generate? (2

.text la $s0, fibs la $s5, size lw $s5, 0($s5) li $s2, 1 sw $s2, 0($s0) sw $s2, 4($s0) addi $s1, $s5, -2 loop: lw $s3, 0($s0) lw $s4, 4($s0) add $s2, $s3, $s4 sw $s2, 8($s0) addi $s0, $s0, 4 addi $s1, $s1, -1 bgtz $s1, loop la $a0, fibs add $a1, $zero, $s5 li $v0, 10 syscall

FIBONACCI SERIES Number Tota 6765 HINT: A MARS PROGRAM FOR THE FIBONACCI SERIES a compute several Fibonacci numbers and put in then print rray data fibs word 0 20 array of words to contain fib values size word 20 size of "array" agrees with array declaration prompt ascliz How many Fibonacci numbers to generate? (2 x 20 text fibs t load address of array la $s5, size load address of s iable $55 load array size H optional user inputs the number of Fibo numbers to generate (now comment ffpr la Sao, prompt load address of prompt for specify Print String service value sys cal print the prompt string t specify the Read Integer service value syscall. Read the number After this instruction the numbe bgt $s5 Check boundary on user input if invalid, resta blt 0, szero. Check boundary on user input if invalid, resta add $s5, zero transfe the number to the desired egister il 1 is the known value of first and second Fib numbe 0 ($s0 sw $s2, 4 (9s0 addi $s1 $s5, -2 t Counter for loop will execute Size-2 times F Loop to compute each Fibonacci number using the previous two Fib $s4 Get value from array F In-2 loop numbers Get value from array F In-1 add $s2 $s3, $s4 $s2 SW Store newly computed addi Ss0, $50, 4 increment address n array decrement to now-known Fib. number storage loop counter addi $s1, $s1, -1 ogtz, sl, loop repeat while not finished Fibonacci numbers are computed and stored in array add sal, szero, $5 t argument for print array jal print second argument for print size call print routine Print them. The program is finished. Exit 10 system call for orderly exit Exit sys call

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!