Reference no: EM132206423
Write a MIPS program to solve the following problem:
a. Prompt the user to enter 3 integer values.
b. Read the integer.
c. Calculate and print the average of the integers as an integer result.
d. Calculate and print the average of the integers as a floating point number.
The number of decimal places is not relevant in your answer
no Pseudo-instructions allowed
This is what I have so far:
.data
data:.word 0,0,0
prompt: .asciiz "Enter 3 integers\n"
newline: .asciiz "\n"
.text
ori $v0,$0,4 # Command to print string
lui $a0,0x1001 # Sets register for data
addiu $a0,$a0,12 # Get start of prompt
syscall # Print the prompt
ori $v0,$0,5 # Command to read integer
syscall # Value in $v0
lui $t0,0x1001 # Sets register $t0
sw $v0, 0($t0) # Stores value of first integer
ori $v0,$0,5 # Command to read integer
syscall # Value in $v0
lui $t1,0x1001
sw $v0, 4($t1) # Stores value of second integer
ori $v0,$0,5 # Command to read integer
syscall # Value in $v0
lui $t2,0x1001
sw $v0, 8($t2) # Stores value of second integer
add $t0,$t0,$t1
add $t0,$t0,$t2 # Sums three integers