Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can\'t get MIPS code to compile. It\'s an of array of 32-bit positive integers a

ID: 3692586 • Letter: C

Question

Can't get MIPS code to compile. It's an of array of 32-bit positive integers and finds the maximum value in x [ ], min value in x [ ], and uses integer arithmetic to calculate average. Any help?


text
.global main
main:
jal linputArray
jal lfindMMA
linputArray:
li $t0,0 # index set to 0
li $t1,0 # num set to 0
li $t2,0 # count set to 0
li $v0,4 # prompt print
la $a0,prompt1
syscall
loop:
#starts
beq $t2,10,done # loop to main , if count equals ten
li $v0, 5 # integer reading service number
syscall # OS asked for integer read
move $t1, $v0 # num set to input
sb $t1, array($t0) # integer stored to array
addi $t0,$t0,4 #index incremented by four
addi $t2,$t2,1 #count increment
j loop # input loop
done:
jr $ra
lfindMMA:
li $t3, 0 # Zero set to sum
li 4t5, 0 # Zero set to max
la $t4,($t1)
li $t6,0 # zero set to avg
li $t0,0 # index cleared to zero
li $t2,0 # count clearde to zero
while:
beq 4t2,10, avg # loop exit
lw $t1, array($t0)
addi $t3, $t3, $t1 # sum calculation
bqt $t1, $t4, max # min checks
move $t4, $t1 # min changes
max:
blt $t1,$t5,avg # max checked
move $t5,$t1 #max changes
addi $t0,$t0,4 # address increment
addi $t2,$t2,1 # increment count
j while
avg:
div $t6, $t3,$t2 # average calculation
li $v0,4 # service no.
la $a0, maxMessage
syscall # OS for message print
li $v0,4 # service no.
move $a0, $t5
syscall # OS asked for printing max
li $v0,4 # service no.
la $a0, minMessage
syscall # ask OS for message print
li $v0,4 # service no.
move $a0, $t4
syscall # ask OS for printing min
#service no.
li $v0,4 # service no.
la $a0, avgMessage
syscall # ask OS for message print
li $v0,4 # service no.
move $a0, $t6
syscall # ask OS for printing avge
li $v0,10
syscall
#convert :
#done:
.data
array: .space 40
prompt1: .asciiz " Enter ten integers : "
prompt2: .asciiz " Mention base for numbers? "
newLine: .asciiz " "
maxMessage: .asciiz" Max = "
minMessage: .asciiz " Min = "
avgMessage: .asciiz" Avg = "

Explanation / Answer

.data PromptHead: .asciiz " Enter " PromptTail: .asciiz " integers " Minstr: .asciiz "Min: " Maxstr: .asciiz "Max: " newline: .asciiz " " inputs: .word 5 .text main: # Output prompt for input ## " Enter " la $a0, PromptHead li $v0, 4 syscall ## "5" lw $a0, inputs li $v0, 1 syscall ## " integers " la $a0, PromptTail li $v0, 4 syscall # Backup sp value before allocating array move $fp, $sp # calculate size of vector (numinputs * sizeof(int) = numinputs * 4 = numinputs
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote