Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 198439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:56:15+00:00 2026-05-11T16:56:15+00:00

I’m writing MIPS program that will examine a list of 10 numbers to be

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:56:16+00:00Added an answer on May 11, 2026 at 4:56 pm

    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.

    .data
    array:  .space 40  
    prompt: .asciiz "Enter a number: " 
    spacee: .asciiz " "
    output: .asciiz "The numbers are: "
    .text
    
    main:
     li $t1,10         #load 10 into $t1
     la $a1,array      #load a pointer to array into $a1
    
    loop:
     addi $t1,$t1,-1   #subtract 1 from $t1, save to $t1
     li $v0,4          #load 4 into $v0 (print string)
     la $a0,prompt     #load prompt text into $a
     syscall           #display prompt
     li $v0,5          #load 5 into $v0 (read integer)
     syscall           #prompt for input
     sw $v0,0($a1)     #store input int to array
     addi $a1,$a1,4    #add 4 to $a1, save to $a1
     bnez $t1,loop     #if $t1 isn't zero,goto loop
     li $t1,9          #if $t1 is zero, load 9 into $t1
     li $t2,9          #and load 9 into $t2
     la $a1,array      #load array pointer into $a1
    
    loop1:
     beqz $t2,here     #if $t2 is zero, goto here
     addi $t2,$t2,-1   #subtract 1 from $t2, save to $t2
     lw $t5,0($a1)     #load an input int into $t5
     lw $t6,4($a1)     #load the next one into $t6
     addi $a1,$a1,4    #add 4 to $a1, save to $a1
     ble $t5,$t6,loop1 #if $t5 <= $t6, goto loop1
     sw $t5,0($a1)     #else, store $t5 in $a1
     sw $t6,-4($a1)     #and store $t6 in $a1-4 (swapping them)
     bnez $t2,loop1    #if $t2 is not zero, to go loop1
    
    here:
     la $a1,array      #load array into $a1
     addi $t1,$t1,-1   #subtract 1 from $t1, save to $t1
     add $t2,$t2,$t1   #add $t2 to $t1, save to $t2
     bnez $t1,loop1    #if $t1 isn't zero, goto loop1
     li $v0,4          #load 4 into $v0 (print string)
     la $a0,output     #load 'the numbers are' into $a0
     syscall           #display message to screen
     la $a1,array      #load array pointer into $a1
     li $t1,10         #load 10 into $t1
    
    loop2:
     li $v0,1          #load 1 into $v0 (print int)
     lw $a0,0($a1)     #load $a1 into $a0
     syscall           #print first number to screen
     li $v0,4          #load 4 into $v1 (print string)
     la $a0,spacee     #load ' ' into $a0
     syscall           #print ' ' to screen
     addi $a1,$a1,4    #add 4 to $a1, save to $a1
     addi $t1,$t1,-1   #subtract 1 from $t1, save to $t1
     bnez $t1,loop2    #if $t1 isn't zero, goto loop2
    
     li $v0,10              #exit
    
     syscall
    

    I don’t have a MIPS processor, but this worked in C:
    #include “stdafx.h”

    int _tmain(int argc, _TCHAR* argv[])
    {
    int t1;
    int t2;
    
    int* a1;
    int t5;
    int t6;
    
    int arr[10] = {10,9,8,7,6,5,4,3,2,1};
    
    t1 = 9;
    t2 = 9;
    a1 = arr;
    
    loop1:
    if(t2 == 0)
        goto here;
    
    t2 = t2 - 1;
    t5 = *a1;
    t6 = *(a1 + 1);
    a1 = a1 + 1;
    if(t5 <= t6)
        goto loop1;
    
    *a1 = t5;
    *(a1-1) = t6;
    if(t2 != 0)
        goto loop1;
    
    here:
    a1 = arr;
    t1 = t1 - 1;
    t2 = t2 + t1;
    if(t1 != 0)
        goto loop1;
    printf("the numbers are\n");
    a1 = arr;
    t1 = 10;
    
    loop2:
    printf("%i ", *a1);
    a1 = a1 + 1;
    t1 = t1 - 1;
    if(t1 != 0)
        goto loop2;
    
    return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.