I’m writing MIPS program that will examine a list of 10 numbers to be input from the terminal. And these numbers will output on the terminal in an ascending order. And below are my MIPS program…please can someone help me look into it, because i m running and isn’t working proply….
.data
array: .space 40
prompt: .asciiz "Enter a number: "
spacee: .asciiz " "
output: .asciiz "The numbers are: "
.text
main:
li $t1,10
la $a1,array
loop:
addi $t1,$t1,-1
li $v0,4
la $a0,prompt
syscall
li $v0,5
syscall
sw $v0,0($a1)
addi $a1,$a1,4
bnez $t1,loop
li $t1,9
li $t2,9
la $a1,array
loop1:
beqz $t2,here
addi $t2,$t2,-1
lw $t5,0($a1)
lw $t6,4($a1)
add $a1,$a1,4
ble $t5,$t6,loop1
sw $t5,0($a1)
sw $t6,-4($a1)
bnez $t2,loop1
here:
la $a1,array
addi $t1,$t1,-1
add $t2,$t2,$t1
bnez $t1,loop1
li $v0,4
la $a0,output
syscall
la $a1,array
li $t1,10
loop2:
li $v0,1
lw $a0,0($a1)
syscall
li $v0,4
la $a0,spacee
syscall
add $a1,$a1,4
addi $t1,$t1,-1
bnez $t1,loop2
li $v0,10 #exit
syscall
If you use addi instead of add, does it work? Also with assembly, it sometimes helps to comment a lot since it doesn’t read anywhere close to a natural language.
I don’t have a MIPS processor, but this worked in C:
#include “stdafx.h”