Question: Using QtSPIM output the sum, count and average. If no data is enter, eg. 0 is the first input, then output the following message and

Using QtSPIM

output the sum, count and average. If no data is enter, eg. 0 is the first input, then output the following message and quit: No data entered .

I'm not understanding how where I input average or count entered variables. can someone help me understand. so far my program adds the sum, but I cant get anything else to work.

.data title: .asciiz "Enter numbers. when done use 0 to end input. " prompt: .asciiz "enter value: " sumis: .asciiz " Tsum is " averageis: .asciiz " Average is " countis: .asciiz " Count is " noentry .asciiz " Noentery "

.text main: la $a0, title #output program heading. load address title into argument register 0 li $v0, 4 # load immediate 4 into return value 0 syscall li $t0, 0 #sum:t0. load immediate 0 into temporary register 0 while: la $a0, prompt #display prompt li $v0, 4 # load immediate 4 into return value 0 syscall la $v0, 5 #read data syscall beqz $v0, endw #if data == 0, done add $t0, $t0, $v0 #add input to sum b while endw: la $a0, sumis #output result message li $v0, 4 #return values from a function syscall move $a0, $t0 #output sum li $v0, 1 syscall li $a0, ' ' #new line li $v0, 11 syscall Average: la $v0, 4 #read data syscall div $v0,2 #divide input by 2 la $a0,averageis #output result message li $v0,4 syscall move $a0,$t1 #output average li $v0,1 syscall li $v0, 10 #exit syscall

.end main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!