Enviar búsqueda
Cargar
MIPS Merge Sort
•
Descargar como DOCX, PDF
•
0 recomendaciones
•
6,452 vistas
Adam Tucker
Seguir
Denunciar
Compartir
Denunciar
Compartir
1 de 7
Descargar ahora
Recomendados
Sets
Sets
Lakshmi Sarvani Videla
Doubly linked list
Doubly linked list
Fahd Allebdi
Python strings
Python strings
Mohammed Sikander
Javascript built in String Functions
Javascript built in String Functions
Avanitrambadiya
String Manipulation in Python
String Manipulation in Python
Pooja B S
Python list
Python list
Mohammed Sikander
Doubly circular linked list
Doubly circular linked list
Roshan Chaudhary
Python Collections
Python Collections
sachingarg0
Recomendados
Sets
Sets
Lakshmi Sarvani Videla
Doubly linked list
Doubly linked list
Fahd Allebdi
Python strings
Python strings
Mohammed Sikander
Javascript built in String Functions
Javascript built in String Functions
Avanitrambadiya
String Manipulation in Python
String Manipulation in Python
Pooja B S
Python list
Python list
Mohammed Sikander
Doubly circular linked list
Doubly circular linked list
Roshan Chaudhary
Python Collections
Python Collections
sachingarg0
String, string builder, string buffer
String, string builder, string buffer
SSN College of Engineering, Kalavakkam
Chapter 06 constructors and destructors
Chapter 06 constructors and destructors
Praveen M Jigajinni
Inline Functions and Default arguments
Inline Functions and Default arguments
Nikhil Pandit
Python Built-in Functions and Use cases
Python Built-in Functions and Use cases
Srajan Mor
Searching in Arrays
Searching in Arrays
Dhiviya Rose
A python web service
A python web service
Temian Vlad
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
ShivaniJayaprakash1
Chapter 17 Tuples
Chapter 17 Tuples
Praveen M Jigajinni
Python programming : Strings
Python programming : Strings
Emertxe Information Technologies Pvt Ltd
Stack and Queue
Stack and Queue
Apurbo Datta
String and string buffer
String and string buffer
kamal kotecha
Python Datatypes by SujithKumar
Python Datatypes by SujithKumar
Sujith Kumar
Stack application
Stack application
Student
Python - Lecture 11
Python - Lecture 11
Ravi Kiran Khareedi
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)
hasan0812
Python : Functions
Python : Functions
Emertxe Information Technologies Pvt Ltd
Python-List.pptx
Python-List.pptx
AnitaDevi158873
String in python use of split method
String in python use of split method
vikram mahendra
C++ Function
C++ Function
Hajar
Java packages
Java packages
Shreyans Pathak
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
badshetoms
Mips1
Mips1
Stefano Salvatori
Más contenido relacionado
La actualidad más candente
String, string builder, string buffer
String, string builder, string buffer
SSN College of Engineering, Kalavakkam
Chapter 06 constructors and destructors
Chapter 06 constructors and destructors
Praveen M Jigajinni
Inline Functions and Default arguments
Inline Functions and Default arguments
Nikhil Pandit
Python Built-in Functions and Use cases
Python Built-in Functions and Use cases
Srajan Mor
Searching in Arrays
Searching in Arrays
Dhiviya Rose
A python web service
A python web service
Temian Vlad
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
ShivaniJayaprakash1
Chapter 17 Tuples
Chapter 17 Tuples
Praveen M Jigajinni
Python programming : Strings
Python programming : Strings
Emertxe Information Technologies Pvt Ltd
Stack and Queue
Stack and Queue
Apurbo Datta
String and string buffer
String and string buffer
kamal kotecha
Python Datatypes by SujithKumar
Python Datatypes by SujithKumar
Sujith Kumar
Stack application
Stack application
Student
Python - Lecture 11
Python - Lecture 11
Ravi Kiran Khareedi
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)
hasan0812
Python : Functions
Python : Functions
Emertxe Information Technologies Pvt Ltd
Python-List.pptx
Python-List.pptx
AnitaDevi158873
String in python use of split method
String in python use of split method
vikram mahendra
C++ Function
C++ Function
Hajar
Java packages
Java packages
Shreyans Pathak
La actualidad más candente
(20)
String, string builder, string buffer
String, string builder, string buffer
Chapter 06 constructors and destructors
Chapter 06 constructors and destructors
Inline Functions and Default arguments
Inline Functions and Default arguments
Python Built-in Functions and Use cases
Python Built-in Functions and Use cases
Searching in Arrays
Searching in Arrays
A python web service
A python web service
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
CBSE - Class 12 - Ch -5 -File Handling , access mode,CSV , Binary file
Chapter 17 Tuples
Chapter 17 Tuples
Python programming : Strings
Python programming : Strings
Stack and Queue
Stack and Queue
String and string buffer
String and string buffer
Python Datatypes by SujithKumar
Python Datatypes by SujithKumar
Stack application
Stack application
Python - Lecture 11
Python - Lecture 11
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)
Python : Functions
Python : Functions
Python-List.pptx
Python-List.pptx
String in python use of split method
String in python use of split method
C++ Function
C++ Function
Java packages
Java packages
Similar a MIPS Merge Sort
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
badshetoms
Mips1
Mips1
Stefano Salvatori
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2
osfameron
Perl6 a whistle stop tour
Perl6 a whistle stop tour
Simon Proctor
Perl6 a whistle stop tour
Perl6 a whistle stop tour
Simon Proctor
Scripting3
Scripting3
Nao Dara
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
mydrynan
Space Invaders Source Code
Space Invaders Source Code
Mitchell Strobel
Hop ngu MIP
Hop ngu MIP
satlove02
Finish the program below that does several bit-wise manipulations of.pdf
Finish the program below that does several bit-wise manipulations of.pdf
fasttrackcomputersol
How to write code you won't hate tomorrow
How to write code you won't hate tomorrow
Pete McFarlane
perl-pocket
perl-pocket
tutorialsruby
perl-pocket
perl-pocket
tutorialsruby
perl-pocket
perl-pocket
tutorialsruby
perl-pocket
perl-pocket
tutorialsruby
The Perl6 Type System
The Perl6 Type System
abrummett
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
brian d foy
PERL for QA - Important Commands and applications
PERL for QA - Important Commands and applications
Sunil Kumar Gunasekaran
Bag of tricks
Bag of tricks
brian d foy
Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01
Javier Arturo Rodríguez
Similar a MIPS Merge Sort
(20)
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
Mips1
Mips1
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2
Perl6 a whistle stop tour
Perl6 a whistle stop tour
Perl6 a whistle stop tour
Perl6 a whistle stop tour
Scripting3
Scripting3
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx
Space Invaders Source Code
Space Invaders Source Code
Hop ngu MIP
Hop ngu MIP
Finish the program below that does several bit-wise manipulations of.pdf
Finish the program below that does several bit-wise manipulations of.pdf
How to write code you won't hate tomorrow
How to write code you won't hate tomorrow
perl-pocket
perl-pocket
perl-pocket
perl-pocket
perl-pocket
perl-pocket
perl-pocket
perl-pocket
The Perl6 Type System
The Perl6 Type System
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
PERL for QA - Important Commands and applications
PERL for QA - Important Commands and applications
Bag of tricks
Bag of tricks
Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01
MIPS Merge Sort
1.
# Merge Sort #
AdamTuckerand AmandaVerno # Assignment#6 Problem # Version12/09/2015 .data # Data declarationsection _msg0: .asciiz"UnsortedArray" _msg1: .asciiz"SortedArray" _newline: .asciiz"n" _spaces: .asciiz" " Array1: .word 7 16 3 1 5 9 8 2 6 4 10 15 19 13 14 17 20 18 12 11 Array2: .word 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .text .globl main main: addi $sp, $sp, -4 # make roomon the stack for returnaddress sw $ra, 0($sp) # save the returnaddress #Load array address la $a0, Array2 # addressof temparray la $a1, Array1 # loadaddressof unsortedarray addi $a2, $zero,20 # loadsize of array into$a2 and $a3, $zero,$zero # initializinglow =0 or $t0, $a1, $zero # addressof unsortedarray or $t3, $a2, $zero # array length #Printmessage li $v0, 4 # systemcall code forprint_str la $a0, _msg0 # addressof stringto print syscall #Printnewline li $v0, 4 # systemcall code forprint_str la $a0, _newline # addressof stringto print syscall
2.
and $t4, $zero,$zero
# seti to 0 j LoopPrintUn # jumpto printunsortedarray PrepSort: addi $sp, $sp, -16 # make roomon the stack sw $ra, 0($sp) # returnaddress sw $a1, 8($sp) # save addressunsortedarray add $a2, $a2, -1 # setting$a2 to (high - 1) sw $a2, 4($sp) # save the size of the (array-1) sw $a3, 0($sp) # low parameter jal MSORT # jumpto merge sortwitharguments(array,high,low) PrintSorted: #Printnewline li $v0, 4 # systemcall code forprint_str la $a0, _newline # addressof stringto print syscall # printthe string #Printmessage li $v0, 4 # systemcall code forprint_str la $a0, _msg1 # addressof stringto print syscall #Printnewline li $v0, 4 # systemcall code forprint_str la $a0, _newline # addressof stringto print syscall and $t7, $zero,$zero # seti to 0 jal LoopPrintSort # jumpto printthe sortedarray LoopPrintUn: # printunsortedarray #While (i < length) slt $t6, $t4, $a2 # if i < the lengthof the array beq $t6, $zero,PrepSort # if (length<=i) thenjumptoprep formerge sort # Load Array[i] andprintit sll $t0, $t4, 2 # i * 4 add $t6, $a1, $t0 # base addressof array + offest
3.
li $v0, 1
# systemcall code forprint_int lw $a0, 0($t6) # shiftamountarray itme syscall # printit #Printspaces li $v0, 4 # systemcall code forprint_str la $a0, _spaces # addressof stringto print syscall addi $t4, $t4, 1 # i ++ j LoopPrintUn # loopprintforunsortedarray LoopPrintSort: # printsortedarray #While (i < length) slt $t6, $t7, 20 # if i < the lengthof the array beq $t6, $zero,EndProgram # if (length<=i) thenexitloop sll $t0, $t7, 2 # i * 4 add $t6, $a1, $t0 # base addressof array + offest li $v0, 1 # systemcall code forprint_int lw $a0, 0($t6) # shiftamountarray itme syscall # printarray [i] #Printspaces li $v0, 4 # systemcall code forprint_str la $a0, _spaces # addressof stringto print syscall addi $t7, $t7, 1 # i ++ jal LoopPrintSort # loopprint EndProgram: addi $sp, $sp, 20 # popall itemsfromthe stack inmain li $v0, 10 # END OFPROGRAM syscall # END OFPROGRAM MSORT: addi$sp,$sp, -20 # make roomon the stack sw $ra, 16($sp) # save returnaddress sw $s1, 12($sp) # save argumentsunsortedarrayaddress sw $s2, 8($sp) # save argumentssize of array= high
4.
sw $s3, 4($sp)
# save low size of array sw $s4, 0($sp) # save registerformid or $s1, $zero,$a1 # $s1 <- array address or $s2, $zero,$a2 # $s2 <- size of array - 1 = high or $s3, $zero,$a3 # $s3 <- low size slt$t3, $s3, $s2 # low < high beq$t3, $zero,DONE # if $t3 == 0, DONE add $s4, $s3, $s2 # low + high div$s4, $s4, 2 # $s4 <- (low+high)/2 or $a2, $zero, $s4 # argumentlow or $a3, $zero, $s3 # argumentmid jal MSORT # recursive call for(array,low,mid) # mergesort(a,mid+1,high) addi$t4, $s4, 1 # argumentmid+1 or $a3, $zero, $t4 # low gets(mid+1) or $a2, $zero, $s2 # highgetshigh jal MSORT # recursive call for(a,mid+1,high) or $a1, $zero,$s1 # Argument1 getsarray address or $a2, $zero,$s2 # Argument2 getshigh or $a3, $zero,$s3 # Argument3 getslow or $a0, $zero,$s4 # Argument4 getsmid jal MERGE # jumpto merge (array,high,low,mid) DONE: lw $ra, 16($sp) # loadreturnaddress lw $s1, 12($sp) # loadargumentsarray address lw $s2, 8($sp) # loadargumentssize of array = high lw $s3, 4($sp) # low size of array lw $s4, 0($sp) # registerformid addi $sp, $sp, 20 # clearroom onthe stack jr $ra # jumpto register MERGE: addi$sp,$sp, -20 # make roomon the stack sw $ra, 16($sp) # save returnaddress sw $s1, 12($sp) # save argumentsunsortedarrayaddress sw $s2, 8($sp) # save argumentssize of array= high sw $s3, 4($sp) # save low size of array sw $s4, 0($sp) # save registerformid or $s1, $zero,$a1 # array address
5.
or $s2, $zero,$a2
# $s2 <- size of array = high or $s3, $zero,$a3 # $s3 <- low size or $s4, $zero,$a0 # $s4 <- mid or $t1, $zero, $s3 # i= $t1 getslow or $t2, $zero, $s4 # j= $t2 getsmid addi$t2, $t2, 1 # j= $t2 getsmid+ 1 or $t3, $zero, $a3 # k = low WHILE: slt $t4, $s4, $t1 # mid< i (i>=mid) bne $t4, $zero,while2 # go to while 2if i >= mid slt $t5, $s2, $t2 # high< j (j>=high) bne $t5, $zero,while2 # && go to while 2if j >= high sll $t6, $t1, 2 # i*4 add $t6, $s1, $t6 # $t6 = addressa[i] lw $s5, 0($t6) # $s5 = a[i] sll $t7, $t2, 2 # j*4 add $t7, $s1, $t7 # $t7 = addressa[j] lw $s6, 0($t7) # $s6 = a[j] slt $t4, $s5, $s6 # a[i] < a[j] beq $t4, $zero,ELSE # go to else if a[i] >=a[j} sll $t8, $t3, 2 # k*4 la $a0, Array2 # loadaddressof temporaryarray (neccasaryif using$a0 forprint statements) add $t8, $a0, $t8 # $t8 = addressc[k] sw $s5, 0($t8) # c[k] = a[i] addi $t3, $t3, 1 # k++ addi $t1, $t1, 1 # i++ j WHILE ELSE: sll $t8, $t3, 2 # i*4 la $a0, Array2 # # loadaddressof temporaryarray(neccasaryif using$a0 for print statements) add $t8, $a0, $t8 # $t8 = addressc[k] sw $s6, 0($t8) # c[k] = a[j] addi $t3, $t3, 1 # k++ addi $t2, $t2, 1 # j++ j WHILE while2:
6.
slt $t4, $s4,
$t1 # mid< i (i>=mid) bne $t4, $zero,while3 # go to while3if i >= mid sll $t6, $t1, 2 # i*4 add $t6, $s1, $t6 # $t6 = addressa[i] lw $s5, 0($t6) # $s5 = a[i] sll $t8, $t3, 2 # i*4 la $a0, Array2 # loadaddressof temporaryarray (neccasaryif using$a0 forprint statements) add $t8, $a0, $t8 # $t8 = addressc[k] sw $s5, 0($t8) # c[k] = a[i] addi $t3, $t3, 1 # k++ addi $t1, $t1, 1 # i++ j while2 while3: slt $t5, $s2, $t2 # high< j (j>=high) bne $t5, $zero,start # go to forloopif j >= high sll $t7, $t2, 2 # i*4 add $t7, $s1, $t7 # $t7 = addressa[j] lw $s6, 0($t7) # $s6 = a[j] sll $t8, $t3, 2 # i*4 la $a0, Array2 # loadaddressof temporaryarray (neccasary if using$a0 forprint statements) add $t8, $a0, $t8 # $t8 = addressc[k] sw $s6, 0($t8) # c[k] = a[j] addi $t3, $t3, 1 # k++ addi $t2, $t2, 1 # j++ j while3 start: or $t1, $zero,$s3 # i <- low forloop: slt $t5, $t1, $t3 # i < k beq $t5, $zero,DONE # branchif mergingiscomplete sll $t6, $t1, 2 # i*4 add $t6, $s1, $t6 # $t6 = addressa[i] sll $t8, $t1, 2 # i*4 la $a0, Array2 # loadaddressof temporaryarray (neccasaryif using$a0 forprint statements) add $t8, $a0, $t8 # $t8 = addressc[i]
7.
lw $s7, 0($t8)
# $s7 = c[i] sw $s7, 0($t6) # a[i] addi $t1, $t1, 1 # i++ j forloop
Descargar ahora