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

Hey I need help with MIPS programming in writing a loop for thePadovian Sequence

ID: 3609580 • Letter: H

Question

Hey I need help with MIPS programming in writing a loop for thePadovian Sequence and entering it into an Array.

The Padovian sequence is given by 1,1,1,2,2,3,4,5,7,9,12,16, 21...

So it must generate the Padovian sequence, element by element, andstores the elements in memory. The sequence should continue untilthe sum of all elements causes an overflow and it should print outa message about that. I understand how to print that out but I haveno clue when the sequence will be overflowed at all! I am alsohaving troubles writing the loop for this kind of sequence. Can youplease help? I really need help on this badly! Lifesaver if someone does help!

Explanation / Answer

please rate - thanks please rate - thanks changed lines in red - I think I have them allhighlighted .text     .globl main main:    addi $t4,$zero, 3       la $t0, P # loads the address of the first element of the sequence,P(0), into register $t0 loop:                             # blt   $t6,$zero,exitloop                             commented out lw $t1, ($t0) # loads the value of P(0) into register $t1. lw $t2, 4($t0) # loads the value of P(1) into register $t2 addu $t3, $t2, $t1 # adds the values of P(0) andP(1), leaving the result in register $t3. blt    $t3,$zero,exitloop sw $t3,12($t0) # stores the value in the array location associatedwith P(3). addu $t4, $t3, $t4               addi $t0,$t0, 4         j loop exitloop:     li $v0, 4         la $a0, message            syscall               li $v0, 1 #printing thevariable k where the loop ends         move $v0, $t7         syscall               li $v0,4 #printing newline character         la $v0, cr         syscall             ################################################# #                        # #             datasegment           # #                       # ################################################# .data message: .asciiz "Overflow occurred when adding element " cr:    .asciiz " " P: .word 1,1,1 # This is the same label ‘P’ at which weinitialize the first 3                # elements of the array to 1 that was mentioned above. .space 300 # This reserves a further 300 bytes of space immediatelyfollowing # the three 4-byte words with 1 , 1 , 1 at label ‘P’above. 300 bytes # should be enough because you should find that overflow occurs # when you add element P(73) of the array to the running sum. ##End