×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

HELP How do I Make this SORT Assembly Work.

HELP How do I Make this SORT Assembly Work.

HELP How do I Make this SORT Assembly Work.

(OP)
This Assembly is to be sort the 200 array number in assending order.But i don't know what i did wrong in the sort part could anyone can help me with this. 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
Sort:
    la $a0, array
    li $t0, 0         
loop1:
    li $t1,0
loop2:
    lw $s0, 0($a0)         
    lw $s1, 1($a1)         
    bgt $s0, $s1, swap     
    
again:
    addi $t1, $t1, -1     
    bgt $t1, $t3, loop1
    addi $t0, $t0,1
    la $a0, array
    bgt $t0, $t3,loop2
swap:
    sw $s0, 4($a0)
    sw $s1, 0($a0)
    j again
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close