SlideShare a Scribd company logo
1 of 1
Download to read offline
Assembly Code Pep/8 Question Write a Pep/8 subroutine that is equivalent to the following C
function int Q2 (int A, int B) {int M, C = 0; M = (A + B)/2; while (M > 0) {C += 3; M--;}
return C;}
Solution
Answer:
MIPS Assembly Language Code :
L0:
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-20], edi
mov DWORD PTR [rbp-24], esi
mov DWORD PTR [rbp-8], 0
mov edx, DWORD PTR [rbp-20]
mov eax, DWORD PTR [rbp-24]
add eax, edx
mov edx, eax
shr edx, 31
add eax, edx
sar eax
mov DWORD PTR [rbp-4], eax
.L3:
cmp DWORD PTR [rbp-4], 0
jle .L2
add DWORD PTR [rbp-8], 3
sub DWORD PTR [rbp-4], 1
jmp .L3
.L2:
mov eax, DWORD PTR [rbp-8]
pop rbp
ret

More Related Content

More from michardsonkhaicarr37

After reading the codes of ethics posted to the USAOnline site please.pdf
After reading the codes of ethics posted to the USAOnline site please.pdfAfter reading the codes of ethics posted to the USAOnline site please.pdf
After reading the codes of ethics posted to the USAOnline site please.pdfmichardsonkhaicarr37
 
A small boy is lost coming down Mount Washington. The leader of the .pdf
A small boy is lost coming down Mount Washington. The leader of the .pdfA small boy is lost coming down Mount Washington. The leader of the .pdf
A small boy is lost coming down Mount Washington. The leader of the .pdfmichardsonkhaicarr37
 
Address how cooperative binding contributes to SSB function during D.pdf
Address how cooperative binding contributes to SSB function during D.pdfAddress how cooperative binding contributes to SSB function during D.pdf
Address how cooperative binding contributes to SSB function during D.pdfmichardsonkhaicarr37
 
A perfect left-sided binary tree is a binary tree where every intern.pdf
A perfect left-sided binary tree is a binary tree where every intern.pdfA perfect left-sided binary tree is a binary tree where every intern.pdf
A perfect left-sided binary tree is a binary tree where every intern.pdfmichardsonkhaicarr37
 
why might bacteria need to alter gene expression when their environm.pdf
why might bacteria need to alter gene expression when their environm.pdfwhy might bacteria need to alter gene expression when their environm.pdf
why might bacteria need to alter gene expression when their environm.pdfmichardsonkhaicarr37
 
Which of the three principles from the Belmont Report were violated .pdf
Which of the three principles from the Belmont Report were violated .pdfWhich of the three principles from the Belmont Report were violated .pdf
Which of the three principles from the Belmont Report were violated .pdfmichardsonkhaicarr37
 
Where is the cell body of the neuron that directly causes SA node ce.pdf
Where is the cell body of the neuron that directly causes SA node ce.pdfWhere is the cell body of the neuron that directly causes SA node ce.pdf
Where is the cell body of the neuron that directly causes SA node ce.pdfmichardsonkhaicarr37
 
Which of the following is FALSE regarding phylogenetic inference met.pdf
Which of the following is FALSE regarding phylogenetic inference met.pdfWhich of the following is FALSE regarding phylogenetic inference met.pdf
Which of the following is FALSE regarding phylogenetic inference met.pdfmichardsonkhaicarr37
 
What is the critical F value for a sample of four observations in th.pdf
What is the critical F value for a sample of four observations in th.pdfWhat is the critical F value for a sample of four observations in th.pdf
What is the critical F value for a sample of four observations in th.pdfmichardsonkhaicarr37
 
what is the main function and sub-functions of a penSolutions.pdf
what is the main function and sub-functions of a penSolutions.pdfwhat is the main function and sub-functions of a penSolutions.pdf
what is the main function and sub-functions of a penSolutions.pdfmichardsonkhaicarr37
 
what are some barriers a company might need to overcome when enterin.pdf
what are some barriers a company might need to overcome when enterin.pdfwhat are some barriers a company might need to overcome when enterin.pdf
what are some barriers a company might need to overcome when enterin.pdfmichardsonkhaicarr37
 
True or False1 The highest abundance of microbial life in soils .pdf
True or False1 The highest abundance of microbial life in soils .pdfTrue or False1 The highest abundance of microbial life in soils .pdf
True or False1 The highest abundance of microbial life in soils .pdfmichardsonkhaicarr37
 
This pedigree illustrates a heritable disease named geneticitis.1..pdf
This pedigree illustrates a heritable disease named geneticitis.1..pdfThis pedigree illustrates a heritable disease named geneticitis.1..pdf
This pedigree illustrates a heritable disease named geneticitis.1..pdfmichardsonkhaicarr37
 
The number of key comparisons in a sequential search depends on the .pdf
The number of key comparisons in a sequential search depends on the .pdfThe number of key comparisons in a sequential search depends on the .pdf
The number of key comparisons in a sequential search depends on the .pdfmichardsonkhaicarr37
 
The Pirerras are planning to go to Europe 2 years from now and have .pdf
The Pirerras are planning to go to Europe 2 years from now and have .pdfThe Pirerras are planning to go to Europe 2 years from now and have .pdf
The Pirerras are planning to go to Europe 2 years from now and have .pdfmichardsonkhaicarr37
 
51.Ingestion of material through pinocytosis can be found in (sele.pdf
51.Ingestion of material through pinocytosis can be found in (sele.pdf51.Ingestion of material through pinocytosis can be found in (sele.pdf
51.Ingestion of material through pinocytosis can be found in (sele.pdfmichardsonkhaicarr37
 
The local city youth league needs a database system to help track ch.pdf
The local city youth league needs a database system to help track ch.pdfThe local city youth league needs a database system to help track ch.pdf
The local city youth league needs a database system to help track ch.pdfmichardsonkhaicarr37
 
The idea that, when life originated on Earth, a macromolecule other .pdf
The idea that, when life originated on Earth, a macromolecule other .pdfThe idea that, when life originated on Earth, a macromolecule other .pdf
The idea that, when life originated on Earth, a macromolecule other .pdfmichardsonkhaicarr37
 
The amount of DNA per cell of a particular species is measured in cel.pdf
The amount of DNA per cell of a particular species is measured in cel.pdfThe amount of DNA per cell of a particular species is measured in cel.pdf
The amount of DNA per cell of a particular species is measured in cel.pdfmichardsonkhaicarr37
 
Problem 1 Create flowcharts that would be used to generate pseudocod.pdf
Problem 1 Create flowcharts that would be used to generate pseudocod.pdfProblem 1 Create flowcharts that would be used to generate pseudocod.pdf
Problem 1 Create flowcharts that would be used to generate pseudocod.pdfmichardsonkhaicarr37
 

More from michardsonkhaicarr37 (20)

After reading the codes of ethics posted to the USAOnline site please.pdf
After reading the codes of ethics posted to the USAOnline site please.pdfAfter reading the codes of ethics posted to the USAOnline site please.pdf
After reading the codes of ethics posted to the USAOnline site please.pdf
 
A small boy is lost coming down Mount Washington. The leader of the .pdf
A small boy is lost coming down Mount Washington. The leader of the .pdfA small boy is lost coming down Mount Washington. The leader of the .pdf
A small boy is lost coming down Mount Washington. The leader of the .pdf
 
Address how cooperative binding contributes to SSB function during D.pdf
Address how cooperative binding contributes to SSB function during D.pdfAddress how cooperative binding contributes to SSB function during D.pdf
Address how cooperative binding contributes to SSB function during D.pdf
 
A perfect left-sided binary tree is a binary tree where every intern.pdf
A perfect left-sided binary tree is a binary tree where every intern.pdfA perfect left-sided binary tree is a binary tree where every intern.pdf
A perfect left-sided binary tree is a binary tree where every intern.pdf
 
why might bacteria need to alter gene expression when their environm.pdf
why might bacteria need to alter gene expression when their environm.pdfwhy might bacteria need to alter gene expression when their environm.pdf
why might bacteria need to alter gene expression when their environm.pdf
 
Which of the three principles from the Belmont Report were violated .pdf
Which of the three principles from the Belmont Report were violated .pdfWhich of the three principles from the Belmont Report were violated .pdf
Which of the three principles from the Belmont Report were violated .pdf
 
Where is the cell body of the neuron that directly causes SA node ce.pdf
Where is the cell body of the neuron that directly causes SA node ce.pdfWhere is the cell body of the neuron that directly causes SA node ce.pdf
Where is the cell body of the neuron that directly causes SA node ce.pdf
 
Which of the following is FALSE regarding phylogenetic inference met.pdf
Which of the following is FALSE regarding phylogenetic inference met.pdfWhich of the following is FALSE regarding phylogenetic inference met.pdf
Which of the following is FALSE regarding phylogenetic inference met.pdf
 
What is the critical F value for a sample of four observations in th.pdf
What is the critical F value for a sample of four observations in th.pdfWhat is the critical F value for a sample of four observations in th.pdf
What is the critical F value for a sample of four observations in th.pdf
 
what is the main function and sub-functions of a penSolutions.pdf
what is the main function and sub-functions of a penSolutions.pdfwhat is the main function and sub-functions of a penSolutions.pdf
what is the main function and sub-functions of a penSolutions.pdf
 
what are some barriers a company might need to overcome when enterin.pdf
what are some barriers a company might need to overcome when enterin.pdfwhat are some barriers a company might need to overcome when enterin.pdf
what are some barriers a company might need to overcome when enterin.pdf
 
True or False1 The highest abundance of microbial life in soils .pdf
True or False1 The highest abundance of microbial life in soils .pdfTrue or False1 The highest abundance of microbial life in soils .pdf
True or False1 The highest abundance of microbial life in soils .pdf
 
This pedigree illustrates a heritable disease named geneticitis.1..pdf
This pedigree illustrates a heritable disease named geneticitis.1..pdfThis pedigree illustrates a heritable disease named geneticitis.1..pdf
This pedigree illustrates a heritable disease named geneticitis.1..pdf
 
The number of key comparisons in a sequential search depends on the .pdf
The number of key comparisons in a sequential search depends on the .pdfThe number of key comparisons in a sequential search depends on the .pdf
The number of key comparisons in a sequential search depends on the .pdf
 
The Pirerras are planning to go to Europe 2 years from now and have .pdf
The Pirerras are planning to go to Europe 2 years from now and have .pdfThe Pirerras are planning to go to Europe 2 years from now and have .pdf
The Pirerras are planning to go to Europe 2 years from now and have .pdf
 
51.Ingestion of material through pinocytosis can be found in (sele.pdf
51.Ingestion of material through pinocytosis can be found in (sele.pdf51.Ingestion of material through pinocytosis can be found in (sele.pdf
51.Ingestion of material through pinocytosis can be found in (sele.pdf
 
The local city youth league needs a database system to help track ch.pdf
The local city youth league needs a database system to help track ch.pdfThe local city youth league needs a database system to help track ch.pdf
The local city youth league needs a database system to help track ch.pdf
 
The idea that, when life originated on Earth, a macromolecule other .pdf
The idea that, when life originated on Earth, a macromolecule other .pdfThe idea that, when life originated on Earth, a macromolecule other .pdf
The idea that, when life originated on Earth, a macromolecule other .pdf
 
The amount of DNA per cell of a particular species is measured in cel.pdf
The amount of DNA per cell of a particular species is measured in cel.pdfThe amount of DNA per cell of a particular species is measured in cel.pdf
The amount of DNA per cell of a particular species is measured in cel.pdf
 
Problem 1 Create flowcharts that would be used to generate pseudocod.pdf
Problem 1 Create flowcharts that would be used to generate pseudocod.pdfProblem 1 Create flowcharts that would be used to generate pseudocod.pdf
Problem 1 Create flowcharts that would be used to generate pseudocod.pdf
 

Recently uploaded

Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFVivekanand Anglo Vedic Academy
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfcupulin
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 

Recently uploaded (20)

Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 

Assembly Code Pep8 Question Write a Pep8 subroutine that is equiva.pdf

  • 1. Assembly Code Pep/8 Question Write a Pep/8 subroutine that is equivalent to the following C function int Q2 (int A, int B) {int M, C = 0; M = (A + B)/2; while (M > 0) {C += 3; M--;} return C;} Solution Answer: MIPS Assembly Language Code : L0: push rbp mov rbp, rsp mov DWORD PTR [rbp-20], edi mov DWORD PTR [rbp-24], esi mov DWORD PTR [rbp-8], 0 mov edx, DWORD PTR [rbp-20] mov eax, DWORD PTR [rbp-24] add eax, edx mov edx, eax shr edx, 31 add eax, edx sar eax mov DWORD PTR [rbp-4], eax .L3: cmp DWORD PTR [rbp-4], 0 jle .L2 add DWORD PTR [rbp-8], 3 sub DWORD PTR [rbp-4], 1 jmp .L3 .L2: mov eax, DWORD PTR [rbp-8] pop rbp ret