ANON_2 - bnez$t1 loop#check if zero if not keep going in...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 .data Array1: .space 80 Zero:.word 0 prompt:.asciiz "How many values? " prompt2:.asciiz"\n Please Input a value = " promptsum:.asciiz "\n Sum is = " promptavg:.asciiz"\n Average is = " promptline:.asciiz "\n" .globl main .text main: la $t0, Array1#load the address of the array move$t4, $t0#move that address to a temporary register li$v0, 4#load Print String la$a0, prompt#load the address of "prompt" syscall#print li $v0, 5 #load Read Integer syscall#Read it move$t1, $v0#keep track of how many, changable move$t2, $v0#keep track of how many, do not change me loop: li$v0, 4#load Print String la$a0, prompt2#load address syscall#print string li $v0, 5 #load Read Integer syscall#Read integer sw $v0, 0($t0)#Store word from Read Integer return value addi$t0, $t0, 4#add 4 bytes to the Array address (next value in array) addi$t1, $t1, -1#decrement the count, to end the loop if zero
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: bnez$t1, loop#check if zero, if not, keep going in loop la$t4, Array1#begin array address again move$t1, $t2#reinitialize li$v0, 4#load print string la$a0, promptsum#load address of "prompt sum" syscall#print it la$t5, Zero#load a zero value lw$a0, 0($t5)#zero $a0 register to reset the value sumloop: lw$t3, 0($t4)#load the element from array to $t3 add$a0, $a0, $t3#add and place in the field addi$t4, $t4, 4 addi$t1, $t1, -1 bnez$t1, sumloop Sheet1 Page 2 move$t6, $a0 la$v0, 1 syscall la$t4, Array1#begin array address again la$t7, Array1#begin array address again move$t1, $t2#reinitialize move$a0, $t5 li$v0, 4 la$a0, promptavg syscall div$t6, $t1 mflo$a0 li$v0, 1 syscall setnumb: lw$t3, 0($t4)#load the element from array to $t3 #UNFINISHED End: li $v0, 10 syscall...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern