sorting - Sort a list of user-entered numbers in MIPS -


I am writing a MIMS program that will check a list of 10 numbers to be input from the terminal. And these numbers will output to the terminal in an ascending order. And below are my MIPS program ... please someone can help me because see me in it, because IM is running and not working ....

 . Data array : .space 40 prompt: .asciiz "Enter number:" Space: .exeas "" Output: .ccis "numbers are:" .text main: li $ t1, $ 10aa $ a1, array loop: adi $ t 1, $ t1, -1l $ v0.4l $ a0, prompt sscal li $ v0.5 syscall sw $ v0,0 ($ a1) plus $ a1, $ a1,4 bnez $ t1, loop li $ t1 , $ 9, $ t2.9, $ 1, array loop 1: bq $ T2, ADI $ T2, $ T2, -1 LW $ T5,0 ($ A1) LW $ T6,4 ($ A1) $ A1, $ A1, 194 Bill $ T5, $ add t6, loop 1 self $ t5,0 ($ a1) sw $ t6, -4 ($ a1) bnez $ t2, loop 1 here: la $ a1, array addi $ t1, $ t1, - Add 1 $ t2, $ t2, $ T1 bnez $ t1, Loop 1 li $ v0.4 la $ a0, output syscall la $ a1, sir li li $ t 1,10 loop 2: ltd $ v0,1 lw $ a0 , 0 ($ a1) syscall li $ v0.4 la $ a0, add space cosall $ a1, $ a1,4 addit $ t1, $ t1, -1 bange $ t1, loop 2 li $ v0,10 # ext. / Code>   

If you do not do this, instead of using AiAid, does it work? With the assembly, it sometimes helps to comment a lot because it does not read anywhere near a natural language.

  .data array: .space 40 prompt: .seciiz "Enter a number:" Space: .Secs "" Output: .ccies "numbers are:" .text main: li $ t1 Load a pointer for the array in $ 10 in $ 10, $ # 1 in the load 10, array # $ 1 App: addi $ T1, $ T1, -1 # T1 dollar to 1 SoftTrack, $ T1 Li Save $ v0.4 # $ 4 in $ v0 (print string) $ a0, prompt # load prompt text $ syscall #display Prompt $ V0.5 # Load 5 $ v0 (integer) read syscall #prompt Sw $ v0,0 ($ a1) #store array for addi $ int1, $ a1,4 # Add $ 4 to $ a1, $ A1 bnez to $ t1, loop #if $ t1 is not zero, goto loop li $ t19 #if $ t1 is zero, $ t1 li $ t2 for $ 9, 9 # and load 9 $ $ 2 in $ A1, $ a1 in loop1 array # load arrow pointer: beacuse $ t2, here #if $ t2 is zero, here addi $ t2, $ t2, -1 #subtract 1 To save $ T2, $ T2 LW $ T5,0 ($ A1) from $ T6 LW $ T6,4 ($ A1) Load an input input # $ 6, $ Add a1, $ a1,4 # 4 to $ a1, $ a1 ble $ t5, $ t6, loop 1 #if $ t5 & lt; Save $ = T6, Goto Loop 1 self $ t5,0 ($ a1) # $ $ 5 $ $ 1 $ sw $ Store T6, -4 ($ a1) # and store $ t6 $ a1-4 (swap them ) Bnez $ t2, loop1 #if $ t2 is not zero, here to go to loop1: la $ a1, array #load array in $ a1 ai $ t1, $ t1, -1 # t 1 dollar to 1 rupee Add $ T2 to save $ T1, Save $ T2, $ T1 # Save $ T2 to $ T1, Save $ T2 BANGS $ T1, Loop 1 #If $ T1 Zero Not Gotto Loop $ li $ v0.4 # $ v0 in load 4 (print string) La $ a0, output # loads are 'numbers' in $ a0 syscall #display Load the screen $ 1, load the load ARE pointer in array # $ A1 li $ t1,10 Load in $ T1 Loop 2: $ li0 $ # 1 in $ v0 (print int) lw $ a0,0 ($ a1) ) # Load $ a1 in $ a0 Syscall #print first number $ li v0.4 # $ 4 in $ v1 (print string) $ a0, spac ady $ a1, $ a1,4 #add 4 to $ a1 To save, add $ a1 addi $ t1, $ t1, -1 # subtract 1 $ $ 1, add $ a0 syscall to #print, save $ T1 bnez $ t1, loop 2 #if $ t1 is not zero, goto loop 2 li $ v0,10 #exit syscall  

I have no MIPS processor But it has 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, 8, 7, 6, 5, 4, 3, 2, 2.1}; T1 = 9; T2 = 9; A1 = arr; Loop 1: If (T2 == 0) goto here; T2 = T2 - 1; T5 = * a1; T6 = * (a1 + 1); A1 = a1 + 1; If (T5 and LT; = T6) Goto loop 1; * A1 = T5; * (A1-1) = T6; If (t2! = 0) goto loop 1; Here: a1 = arr T1 = T1 - 1; T2 = T2 + T1; If (t1! = 0) goto loop1; Printf ("numbers are \ n"); A1 = arr; T1 = 10; Loop 2: Printf ("% i", * a1); A1 = a1 + 1; T1 = T1 - 1; If (t1! = 0) goto loop 2; Return 0; }  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -