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

Info iconThis 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background 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

This note was uploaded on 03/11/2008 for the course CS 264 taught by Professor Salloum during the Spring '08 term at Cal Poly Pomona.

Page1 / 2

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online