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 0,0,0,0,0,0,0,0,0,0
errormessage: .asciiz "Error, array can't have more than 11 elements, try again!!
"
line: .asciiz "============================================================
"
median: .asciiz "The median is: "
.text
main:
li $v0,4
la $a0, enter
syscall
la $s1, array
li $t0,1
tryagain:
li $v0,5
syscall
add $s0, $v0, $0
add $t2, $s0, $0
li $t0,0
li $t1,11
bgt $s0, $t2, error
ble $s1, $t0, error
bge $s1, $t1, error
li $v0,4
la $a0, line
syscall
#taking in input
fillArray: beq $s0, $0, next
li $v0,4
la $a0, number
syscall
li $v0,1
add $a0, $t0, $0
syscall
li $v0,4
la $a0, colon
syscall
li $v0,5
syscall
sw $v0,0($s1)
addi $s1, $s1,4
addi $s0, $s0,-1
addi $t0, $t0,1
j fillArray
next:
li $t3,2
li $t6,4
division:
div $t2, $t3
mflo $t4 #quotient
mfhi $t5 #remainder
mult $t4, $t6
mflo $t4
add $s0, $t2, $t4
bne $t5, $0, even
odd:
lw $t0,0($s1)
li $v0,1
add $a0, $t0, $0
syscall
j exit
even:
lw $t0,0($s1)
lw $t1,-4($s1)
add $t1, $t0, $t1
div $t1, $t3
mflo $t1
li $v0,1
add $a0, $t1, $0
syscall
exit:
li $v0,4
la $a0, space
la $a0, line
syscall
li $v0,10
syscall
error:
li $v0,4
la $a0, errormessage
syscall
j tryagain

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 Programming Questions!