Question: can you check my mips code: . data enter: . asciiz Enter the number of elements? number: . asciiz Enter number colon: .
can you check my mips code:
data
enter: asciiz "Enter the number of elements?
number: asciiz "Enter number
colon: asciiz :
space: asciiz
array: word
errormessage: asciiz "Error, array can't have more than elements, try again!!
line: asciiz
median: asciiz "The median is:
text
main:
li $v
la $a enter
syscall
la $s array
li $t
tryagain:
li $v
syscall
add $s $v $
add $t $s $
li $t
li $t
bgt $s $t error
ble $s $t error
bge $s $t error
li $v
la $a line
syscall
#taking in input
fillArray: beq $s $ next
li $v
la $a number
syscall
li $v
add $a $t $
syscall
li $v
la $a colon
syscall
li $v
syscall
sw $v$s
addi $s $s
addi $s $s
addi $t $t
j fillArray
next:
li $t
li $t
division:
div $t $t
mflo $t #quotient
mfhi $t #remainder
mult $t $t
mflo $t
add $s $t $t
bne $t $ even
odd:
lw $t$s
li $v
add $a $t $
syscall
j exit
even:
lw $t$s
lw $t$s
add $t $t $t
div $t $t
mflo $t
li $v
add $a $t $
syscall
exit:
li $v
la $a space
la $a line
syscall
li $v
syscall
error:
li $v
la $a errormessage
syscall
j tryagain
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
