Could anyone help me to check what wrong to with my assembly code. For this assembly code that write is to sort the 200 random number in order. And i got error with my sorting part that i coundn't fix it because it didn't print out the output.
Your help is very helpful to me THANK YOU
--------------------------------------------------------
--------------------------------------------------------
.data
array: .space 800
initstr:
.asciiz "Initial Array: "
finalstr:
.asciiz "Final Array: "
spacestr:
.asciiz " "
newlinestr:
.asciiz "\n"
###########################################################
.text
main:
la $a0, array
addi $a1, $a0, 800
li $s0, 11
li $s1, 106
li $s2, 6075
FillLoop:
mul $s0, $s1, $s0
addi $s0, $s0, 1283
rem $s0, $s0, $s2
sw $s0, 0($a0)
addi $a0, $a0, 4
bne $a0, $a1, FillLoop
########################################################### la $a1, array
addi $a2, $a1, 800
li $v0, 4
la $a0, initstr
syscall
###########################################################
PrintLoop1:
lw $a0, 0($a1)
li $v0, 1
syscall
la $a0, spacestr
li $v0, 4
syscall
addi $a1, $a1, 4
bne $a1, $a2, PrintLoop1
la $a0, newlinestr
syscall
###########################################################
bubbleSort:
la $a0, array
move $a2, $a1
li $t0, 0
for1:
beq $a2, $t0, exit1
addi $a1, $t0, -1
for2:
bltz $a1, exit2
sll $a3, $a1, 2
add $a3, $a0, $a3
lw $t2, 0($a3)
lw $t3, 4($a3)
ble $t3, $t2, else
jal swap
else:
addi $a1, $a1, -1
j for2
exit2:
addi $t0, $t0, 1
j for1
exit1:
jr $ra
###########################################################
la $a1, array
addi $a2, $a1, 800
li $v0, 4
la $a0, finalstr
syscall
PrintLoop2:
lw $a0, 0($a1)
li $v0, 1
syscall
la $a0, spacestr
li $v0, 4
syscall
addi $a1, $a1, 4
bne $a1, $a2, PrintLoop2
la $a0, newlinestr
syscall
# End of file.
Your help is very helpful to me THANK YOU
--------------------------------------------------------
--------------------------------------------------------
.data
array: .space 800
initstr:
.asciiz "Initial Array: "
finalstr:
.asciiz "Final Array: "
spacestr:
.asciiz " "
newlinestr:
.asciiz "\n"
###########################################################
.text
main:
la $a0, array
addi $a1, $a0, 800
li $s0, 11
li $s1, 106
li $s2, 6075
FillLoop:
mul $s0, $s1, $s0
addi $s0, $s0, 1283
rem $s0, $s0, $s2
sw $s0, 0($a0)
addi $a0, $a0, 4
bne $a0, $a1, FillLoop
########################################################### la $a1, array
addi $a2, $a1, 800
li $v0, 4
la $a0, initstr
syscall
###########################################################
PrintLoop1:
lw $a0, 0($a1)
li $v0, 1
syscall
la $a0, spacestr
li $v0, 4
syscall
addi $a1, $a1, 4
bne $a1, $a2, PrintLoop1
la $a0, newlinestr
syscall
###########################################################
bubbleSort:
la $a0, array
move $a2, $a1
li $t0, 0
for1:
beq $a2, $t0, exit1
addi $a1, $t0, -1
for2:
bltz $a1, exit2
sll $a3, $a1, 2
add $a3, $a0, $a3
lw $t2, 0($a3)
lw $t3, 4($a3)
ble $t3, $t2, else
jal swap
else:
addi $a1, $a1, -1
j for2
exit2:
addi $t0, $t0, 1
j for1
exit1:
jr $ra
###########################################################
la $a1, array
addi $a2, $a1, 800
li $v0, 4
la $a0, finalstr
syscall
PrintLoop2:
lw $a0, 0($a1)
li $v0, 1
syscall
la $a0, spacestr
li $v0, 4
syscall
addi $a1, $a1, 4
bne $a1, $a2, PrintLoop2
la $a0, newlinestr
syscall
# End of file.