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

Please provide a well commented, fully functional MIPS code. Write a MIPS assemb

ID: 3870409 • Letter: P

Question

Please provide a well commented, fully functional MIPS code.

Write a MIPS assembly language program that

a) Prompt the user for an integer in the range of 0 to 50. If the user inputs 0 the program stops.

b) Otherwise, the program stores the numbers from 0 up to the input value into an array of words in memory, i.e. initializes the array with values from 0 up to N where N is the value that user has inputted.

c) The program then adds the value of all items of the array together (up to N) by loading them from the main memory then add them up, then prints out the sum with the message "The sum of integers from 0 to N is:". For example, if the user gave 5 as the input the program prints out "The sum of integers from 0 to 5 is 15".

Explanation / Answer


main:

        addiu   $sp,$sp,-40
   sw   $31,36($sp)

lw   $5,%got($LC0)($28)
   nop
   movz   $31,$31,$0
   addiu   $5,$5,%lo($LC0)
   li   $4,1           # 0x1
   lw   $25,%call16(__printf_chk)($28)
   nop
  
1:   jalr   $25
   nop

   lw   $28,16($sp)
   addiu   $5,$sp,24
   lw   $4,%got($LC1)($28)
   nop
   addiu   $4,$4,%lo($LC1)
   lw   $25,%call16(__isoc99_scanf)($28)
   nop
  
1:   jalr   $25
   nop

   lw   $28,16($sp)
   sw   $0,24($sp)
   move   $6,$0
   lw   $5,%got($LC2)($28)
   nop
   addiu   $5,$5,%lo($LC2)
   li   $4,1          
   lw   $25
   nop
  
1:   jalr   $25
   nop

   lw   $28,16($sp)
   li   $2,1          
   lw   $31,36($sp)
   nop
   j   $31
   addiu   $sp,$sp,40

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