Question

The MIPS assembly program given here is expected to find the sum of elements in array myArr. Even though the code is syntact
0 0
Add a comment Improve this question Transcribed image text
Answer #1

In this program, the value in $t1 is being used as a reference to the size of the array. I can tell this because, it is being decremented at every iteration in loop1, and it is the variable that is used in deciding whether to loop again or break out of the loop.

I find two logical errors:

1.)line 5: the intial content of $t1 is 5. But there are 8 elements in myArr. So, change this line to load 8 into $t1. The altered code will be : li $t1, 8

2.)line 14: The condition specified in this line is that to loop again if $t1 is less than zero. This is wrong, the loop will terminate after the first iteration. We have to loop again only if $t1 is greater than zero. Change this line to : bgtz $t1, loop1


answered by: ANURANJAN SARSAM
Add a comment
Know the answer?
Add Answer to:
The MIPS assembly program given here is expected to find the sum of elements in array...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 2. Q2 [25 points) Consider the MIPS code given in the following. main: addi Ssp, Ssp,...

    2. Q2 [25 points) Consider the MIPS code given in the following. main: addi Ssp, Ssp, -4 addi Sa0, $0, 2 sw $a0, 4(Ss1) addi Sal, $0, 3 sw Sal, 8(Ss1) jal dofsum sw SvO, 16(8s1) lw Sra, O(Ssp) addi Ssp, Ssp, 4 jr Sra dofsum: jal sum jr Sra sum: add SvO, Sa0, Sal jr Sra Draw the snapshot of the stack before, during, and after dofsum) function call. As- sume SSP, 0x45fff00 before dofsum() function call.

  • MIPS Insertion program.........I could really use some help ASAP

    I have this MIPS program and I'm having trouble with it. This program is user inputs numbers until zero and sorts and print the numbers in order. Please soove this issue. You can use any sorting algorithm except bubble sort.  Need it as soon as possible. Here is the code:.datanum: .word 0space: .byte ' ' .text main:  # la $t0, val # loads val into a register  # li $t1, 0      #keeps track of how many numbers entered  la $a0,...

  • QT Spim question. Program and answer already given please explaine it. Please explain the reason why...

    QT Spim question. Program and answer already given please explaine it. Please explain the reason why each instruction was used throughout the program step by step given the prompt, what is its purpose to achive the goal asked in the prompt, why is written in that order. Please not just write to the side what each instruction means in words like load $t0 to $t1. I want to understand the program thoroughly. Thanks in advance Previous information needed to solve...

  • im trying to complete mips program code about a calculator program that can calculate integer addition...

    im trying to complete mips program code about a calculator program that can calculate integer addition / subtraction written using the MIPS assembler. im having hard times to debug this. The input is given to the array of Formula char (base address $ s0) in the form of a formula. The null character (\ 0, ASCII code 0) is placed at the end. The calculation result is given to the register $ s1 and the overflow is ignored. For example,...

  • The task will be to write a program in assembler to enter a number and calculate...

    The task will be to write a program in assembler to enter a number and calculate its associated Fibonacci number using a procedure (subroutine) that is called recursively. Factorial and Fibonacci(outline Programs) # MIPS assembly assembly assemblyassemblycode .data n: .word 4 .text main: la $s0,n lw $a0, 0($s0) jal factorial # move what ever is returned into $a0 move $a0, $v0 li $v0,1 syscall b finished factorial: add $sp , $sp , -8 # make room sw $a0, 4($sp )...

  • How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++...

    How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++ .data # Defines variable section of an assembly routine. array: .word x, x, x, x, x, x, x, x, x, x # Define a variable named array as a word (integer) array # with 10 unsorted integer numbers of your own. # After your program has run, the integers in this array # should be sorted. .text # Defines the start of the code...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT