SlideShare ist ein Scribd-Unternehmen logo
1 von 2
IN MIPS ASSEMBLY LANUAGE, how do you rank a list in descending order. For example,
the user inputs the following string:
"Thank you Chegg for helping me with my homework.". Here is the list of the vowels:
A/a : 1
E/e : 4
I/i : 1
O/o : 3
U/u : 1
How do I translate this list in descending order using MIPS ASSEMBLY LANGUAGE! Thank
you!
Solution
.data prompt: .asciiz "  Enter an string of characters: " result: .asciiz "  Here is the string you
entered: " buffer: .space 80 length: .word 80 before: .asciiz "Before sort: " space: .asciiz " "
after: .asciiz "  After Sort " newLine: .asciiz " " .text .globl main main: #Prints the prompt
string li $v0, 4 la $a0, prompt syscall #reads string from user and saves in $a0 li $v0, 8 la $a0,
buffer li $a1, 80 syscall #Prints the result string li $v0, 4 la $a0, result syscall #Prints the string
entered by the user la $a0, buffer li $v0, 4 syscall li $t5, 0 # t5 is k = 0 la $t7, length lw $t7,
0($t7) # t7 = length addi $t8, $t7, -1 # t8 = length - 1 la $t6, 0($a0) # t6 = address of the array
outerLoop: slt $t0, $t5, $t8 # if k < length - 1 t0 = 1 beq $t0, $zero, breakOuterLoop # k >=
(length - 1) add $t9, $zero, $t5 # t9 is min = k addi $t1, $t5, 1 # t1 is j = k + 1 innerLoop: slt $t0,
$t1, $t7 # if j < length t0 = 1 beq $t0, $zero, breakInnerLoop add $s3, $t9, $t9 # s3 = 2 * min add
$s3, $s3, $s3 # s3 = 4 * min add $s3, $a0, $s3 # s3 is address of list[min] lw $t2, 0($s3) # t2 is
list[min] add $s0, $t1, $t1 # s0 = 2 * j add $s0, $s0, $s0 # s0 = 4 * j add $s0, $a0, $s0 # s0 is
address of list[j] lw $t3, 0($s0) # t3 is list[j] slt $t0, $t3, $t2 # if list[j] < list[min] t0 = 1 beq $t0,
$zero, secondIF # skip min = j & ++j and jump to secondIF add $t9, $zero, $t1 # min = j j
secondIF secondIF: beq $t9, $t5, incrementJ # if min != k swap, else goto incrementJ # BEGIN
SWAP : add $s0, $t9, $t9 # s0 = 2 * min add $s0, $s0, $s0 # s0 = 4 * min add $s0, $s0, $a0 # s0
= address of list[min] lw $t4, 0($s0) # t4 is temp = list[min] add $s1, $t5, $t5 # s1 = 2 * k add
$s1, $s1, $s1 # s1 = 4 * k add $s1, $a0, $s1 # s1 = address of list[k] lw $s3, 0($s1) # s3 = list[k]
sw $s3, 0($s0) # list[min] = list[k] sw $t4, 0($s1) # list[k] = temp addi $t1, $t1, 1 # ++j add $t9,
$zero, $t5 # t9 is min = k # END SWAP j innerLoop incrementJ: addi $t1, $t1, 1 # ++j j
innerLoop breakInnerLoop: addi $t5, $t5, 1 # ++k j outerLoop breakOuterLoop: #Prints the
result string li $v0, 4 la $a0, result syscall #Prints the string entered by the user la $a0, buffer li
$v0, 4 syscall exitProgram: li $v0, 10 # system call to syscall # terminate program

Weitere ähnliche Inhalte

Ähnlich wie IN MIPS ASSEMBLY LANUAGE- how do you rank a list in descending order-.docx

PyLecture4 -Python Basics2-
PyLecture4 -Python Basics2-PyLecture4 -Python Basics2-
PyLecture4 -Python Basics2-Yoshiki Satotani
 
Lists.pptx
Lists.pptxLists.pptx
Lists.pptxYagna15
 
python_avw - Unit-03.pdf
python_avw - Unit-03.pdfpython_avw - Unit-03.pdf
python_avw - Unit-03.pdfAshaWankar1
 
Need help optimizing my code for MIPS- Completely lost on how-what to.pdf
Need help optimizing my code for MIPS- Completely lost on how-what to.pdfNeed help optimizing my code for MIPS- Completely lost on how-what to.pdf
Need help optimizing my code for MIPS- Completely lost on how-what to.pdfactexerode
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaDaniel Cukier
 
Class 5: If, while & lists
Class 5: If, while & listsClass 5: If, while & lists
Class 5: If, while & listsMarc Gouw
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfforladies
 
The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196Mahmoud Samir Fayed
 
The basics and design of lua table
The basics and design of lua tableThe basics and design of lua table
The basics and design of lua tableShuai Yuan
 
STRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdfSTRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdfomprakashmeena48
 
Petitparser at the Deep into Smalltalk School 2011
Petitparser at the Deep into Smalltalk School 2011Petitparser at the Deep into Smalltalk School 2011
Petitparser at the Deep into Smalltalk School 2011Tudor Girba
 
Groovy every day
Groovy every dayGroovy every day
Groovy every dayPaul Woods
 
Metasepi team meeting #17: Invariant captured by ATS's API
Metasepi team meeting #17: Invariant captured by ATS's APIMetasepi team meeting #17: Invariant captured by ATS's API
Metasepi team meeting #17: Invariant captured by ATS's APIKiwamu Okabe
 
ALF 5 - Parser Top-Down (2018)
ALF 5 - Parser Top-Down (2018)ALF 5 - Parser Top-Down (2018)
ALF 5 - Parser Top-Down (2018)Alexandru Radovici
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAPsapdocs. info
 
1582627
15826271582627
1582627tabish
 

Ähnlich wie IN MIPS ASSEMBLY LANUAGE- how do you rank a list in descending order-.docx (20)

PyLecture4 -Python Basics2-
PyLecture4 -Python Basics2-PyLecture4 -Python Basics2-
PyLecture4 -Python Basics2-
 
Lists.pptx
Lists.pptxLists.pptx
Lists.pptx
 
Sixth session
Sixth sessionSixth session
Sixth session
 
python_avw - Unit-03.pdf
python_avw - Unit-03.pdfpython_avw - Unit-03.pdf
python_avw - Unit-03.pdf
 
LEX & YACC TOOL
LEX & YACC TOOLLEX & YACC TOOL
LEX & YACC TOOL
 
Need help optimizing my code for MIPS- Completely lost on how-what to.pdf
Need help optimizing my code for MIPS- Completely lost on how-what to.pdfNeed help optimizing my code for MIPS- Completely lost on how-what to.pdf
Need help optimizing my code for MIPS- Completely lost on how-what to.pdf
 
Practical File Grade 12.pdf
Practical File Grade 12.pdfPractical File Grade 12.pdf
Practical File Grade 12.pdf
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
 
Class 5: If, while & lists
Class 5: If, while & listsClass 5: If, while & lists
Class 5: If, while & lists
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
 
The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180
 
The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196
 
The basics and design of lua table
The basics and design of lua tableThe basics and design of lua table
The basics and design of lua table
 
STRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdfSTRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdf
 
Petitparser at the Deep into Smalltalk School 2011
Petitparser at the Deep into Smalltalk School 2011Petitparser at the Deep into Smalltalk School 2011
Petitparser at the Deep into Smalltalk School 2011
 
Groovy every day
Groovy every dayGroovy every day
Groovy every day
 
Metasepi team meeting #17: Invariant captured by ATS's API
Metasepi team meeting #17: Invariant captured by ATS's APIMetasepi team meeting #17: Invariant captured by ATS's API
Metasepi team meeting #17: Invariant captured by ATS's API
 
ALF 5 - Parser Top-Down (2018)
ALF 5 - Parser Top-Down (2018)ALF 5 - Parser Top-Down (2018)
ALF 5 - Parser Top-Down (2018)
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
 
1582627
15826271582627
1582627
 

Mehr von mckerliejonelle

What was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docxWhat was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docxmckerliejonelle
 
What subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docxWhat subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docxmckerliejonelle
 
what type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docxwhat type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docxmckerliejonelle
 
What skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docxWhat skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docxmckerliejonelle
 
What pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docxWhat pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docxmckerliejonelle
 
What percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docxWhat percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docxmckerliejonelle
 
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docxWhat makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docxmckerliejonelle
 
What motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docxWhat motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docxmckerliejonelle
 
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docxWHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docxmckerliejonelle
 
What is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docxWhat is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docxmckerliejonelle
 
What is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docxWhat is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docxmckerliejonelle
 
What is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docxWhat is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docxmckerliejonelle
 
What is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docxWhat is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docxmckerliejonelle
 
What is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docxWhat is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docxmckerliejonelle
 
What is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docxWhat is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docxmckerliejonelle
 
What is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docxWhat is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docxmckerliejonelle
 
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docxWhat is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docxmckerliejonelle
 
What is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docxWhat is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docxmckerliejonelle
 
What is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docxWhat is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docxmckerliejonelle
 
What is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docxWhat is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docxmckerliejonelle
 

Mehr von mckerliejonelle (20)

What was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docxWhat was ABC Inc's net capital spending in the year 2022- given their.docx
What was ABC Inc's net capital spending in the year 2022- given their.docx
 
What subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docxWhat subatomic partichis ate located in the nuicleas of an atom- nesif.docx
What subatomic partichis ate located in the nuicleas of an atom- nesif.docx
 
what type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docxwhat type of decision making style do well in environments where there.docx
what type of decision making style do well in environments where there.docx
 
What skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docxWhat skills have you gained that would be applied to a computer techno.docx
What skills have you gained that would be applied to a computer techno.docx
 
What pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docxWhat pattern of inheritance does variant have with the RCH gene at the.docx
What pattern of inheritance does variant have with the RCH gene at the.docx
 
What percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docxWhat percentage of genetic divergence is used to define separate speci.docx
What percentage of genetic divergence is used to define separate speci.docx
 
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docxWhat makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
What makes Y-C+I+G+NX an identity- Each symbol identifies a variable-.docx
 
What motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docxWhat motivates radical environmentalist groups like the Earth Liberati.docx
What motivates radical environmentalist groups like the Earth Liberati.docx
 
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docxWHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
WHAT IS YOUR CULTURAL INTELLIGENCE- Instructlons- To what extent does.docx
 
What is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docxWhat is true about the relative concentration of H+ and OH- in water-.docx
What is true about the relative concentration of H+ and OH- in water-.docx
 
What is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docxWhat is the result (in binary) of adding the unsigned char binary numb.docx
What is the result (in binary) of adding the unsigned char binary numb.docx
 
What is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docxWhat is the resolution of a digital-to-analog converter (DAC)- It is t.docx
What is the resolution of a digital-to-analog converter (DAC)- It is t.docx
 
What is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docxWhat is the primary reason that Earth is cold at the poles and hot at.docx
What is the primary reason that Earth is cold at the poles and hot at.docx
 
What is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docxWhat is the main differentiating factor of an Advanced Alternative Pay.docx
What is the main differentiating factor of an Advanced Alternative Pay.docx
 
What is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docxWhat is the main difterence between Al- ML- and OL- Select ones a- ML.docx
What is the main difterence between Al- ML- and OL- Select ones a- ML.docx
 
What is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docxWhat is the function of helper T cells in cell mediated immunity- Kill.docx
What is the function of helper T cells in cell mediated immunity- Kill.docx
 
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docxWhat is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
What is the general FUNCTION of this tissue tvoe- -Pseberbunef that pe.docx
 
What is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docxWhat is the effect of cholesterol on membrane fluidity at physiologic.docx
What is the effect of cholesterol on membrane fluidity at physiologic.docx
 
What is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docxWhat is the default IP Prefix for a Class A- -16 124 130 18.docx
What is the default IP Prefix for a Class A- -16 124 130 18.docx
 
What is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docxWhat is the biggest animal in the world- What is the only active volca.docx
What is the biggest animal in the world- What is the only active volca.docx
 

Kürzlich hochgeladen

psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 

Kürzlich hochgeladen (20)

psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 

IN MIPS ASSEMBLY LANUAGE- how do you rank a list in descending order-.docx

  • 1. IN MIPS ASSEMBLY LANUAGE, how do you rank a list in descending order. For example, the user inputs the following string: "Thank you Chegg for helping me with my homework.". Here is the list of the vowels: A/a : 1 E/e : 4 I/i : 1 O/o : 3 U/u : 1 How do I translate this list in descending order using MIPS ASSEMBLY LANGUAGE! Thank you! Solution .data prompt: .asciiz " Enter an string of characters: " result: .asciiz " Here is the string you entered: " buffer: .space 80 length: .word 80 before: .asciiz "Before sort: " space: .asciiz " " after: .asciiz " After Sort " newLine: .asciiz " " .text .globl main main: #Prints the prompt string li $v0, 4 la $a0, prompt syscall #reads string from user and saves in $a0 li $v0, 8 la $a0, buffer li $a1, 80 syscall #Prints the result string li $v0, 4 la $a0, result syscall #Prints the string entered by the user la $a0, buffer li $v0, 4 syscall li $t5, 0 # t5 is k = 0 la $t7, length lw $t7, 0($t7) # t7 = length addi $t8, $t7, -1 # t8 = length - 1 la $t6, 0($a0) # t6 = address of the array outerLoop: slt $t0, $t5, $t8 # if k < length - 1 t0 = 1 beq $t0, $zero, breakOuterLoop # k >= (length - 1) add $t9, $zero, $t5 # t9 is min = k addi $t1, $t5, 1 # t1 is j = k + 1 innerLoop: slt $t0, $t1, $t7 # if j < length t0 = 1 beq $t0, $zero, breakInnerLoop add $s3, $t9, $t9 # s3 = 2 * min add $s3, $s3, $s3 # s3 = 4 * min add $s3, $a0, $s3 # s3 is address of list[min] lw $t2, 0($s3) # t2 is list[min] add $s0, $t1, $t1 # s0 = 2 * j add $s0, $s0, $s0 # s0 = 4 * j add $s0, $a0, $s0 # s0 is address of list[j] lw $t3, 0($s0) # t3 is list[j] slt $t0, $t3, $t2 # if list[j] < list[min] t0 = 1 beq $t0, $zero, secondIF # skip min = j & ++j and jump to secondIF add $t9, $zero, $t1 # min = j j secondIF secondIF: beq $t9, $t5, incrementJ # if min != k swap, else goto incrementJ # BEGIN SWAP : add $s0, $t9, $t9 # s0 = 2 * min add $s0, $s0, $s0 # s0 = 4 * min add $s0, $s0, $a0 # s0
  • 2. = address of list[min] lw $t4, 0($s0) # t4 is temp = list[min] add $s1, $t5, $t5 # s1 = 2 * k add $s1, $s1, $s1 # s1 = 4 * k add $s1, $a0, $s1 # s1 = address of list[k] lw $s3, 0($s1) # s3 = list[k] sw $s3, 0($s0) # list[min] = list[k] sw $t4, 0($s1) # list[k] = temp addi $t1, $t1, 1 # ++j add $t9, $zero, $t5 # t9 is min = k # END SWAP j innerLoop incrementJ: addi $t1, $t1, 1 # ++j j innerLoop breakInnerLoop: addi $t5, $t5, 1 # ++k j outerLoop breakOuterLoop: #Prints the result string li $v0, 4 la $a0, result syscall #Prints the string entered by the user la $a0, buffer li $v0, 4 syscall exitProgram: li $v0, 10 # system call to syscall # terminate program