SlideShare a Scribd company logo
1 of 4
Download to read offline
Translate the following C/C++ code into MIPS Assembly Code:
void chico(int *X, int Y, int Z)
{
*X = Y/4 - Z*10 + *X*8;
}
int main()
{
int J, K, L, M;
cin >> J, K, L;
chico ( &J, K, L);
M = J - (K + L);
cout << M;
return 0;
}
Solution
Program:
#include
using namespace std;
void chico(int *X, int Y, int Z)
{
*X = Y/4 - Z*10 + *X*8;
}
int main()
{
int J, K, L, M;
cin >> J,K,L;
chico ( &J, K, L);
M = J - (K + L);
cout<<"value"<< M;
return 0;
}
The above code returns the following Mips code :
chico(int*, int, int):
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
mov DWORD PTR [rbp-12], esi
mov DWORD PTR [rbp-16], edx
mov eax, DWORD PTR [rbp-12]
lea edx, [rax+3]
test eax, eax
cmovs eax, edx
sar eax, 2
mov ecx, eax
mov edx, DWORD PTR [rbp-16]
mov eax, edx
sal eax, 2
add eax, edx
add eax, eax
neg eax
lea edx, [rcx+rax]
mov rax, QWORD PTR [rbp-8]
mov eax, DWORD PTR [rax]
sal eax, 3
add edx, eax
mov rax, QWORD PTR [rbp-8]
mov DWORD PTR [rax], edx
nop
pop rbp
ret
.LC0:
.string "value"
main:
push rbp
mov rbp, rsp
sub rsp, 16
lea rax, [rbp-16]
mov rsi, rax
mov edi, OFFSET FLAT:std::cin
call std::basic_istream >::operator>>(int&)
mov edx, DWORD PTR [rbp-8]
mov ecx, DWORD PTR [rbp-4]
lea rax, [rbp-16]
mov esi, ecx
mov rdi, rax
call chico(int*, int, int)
mov eax, DWORD PTR [rbp-16]
mov ecx, DWORD PTR [rbp-4]
mov edx, DWORD PTR [rbp-8]
add edx, ecx
sub eax, edx
mov DWORD PTR [rbp-12], eax
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
mov rdx, rax
mov eax, DWORD PTR [rbp-12]
mov esi, eax
mov rdi, rdx
call std::basic_ostream >::operator<<(int)
mov eax, 0
leave
ret
__static_initialization_and_destruction_0(int, int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
cmp DWORD PTR [rbp-4], 1
jne .L6
cmp DWORD PTR [rbp-8], 65535
jne .L6
mov edi, OFFSET FLAT:std::__ioinit
call std::ios_base::Init::Init()
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:std::__ioinit
mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
call __cxa_atexit
.L6:
nop
leave
ret
push rbp
mov rbp, rsp
mov esi, 65535
mov edi, 1
call __static_initialization_and_destruction_0(int, int)
pop rbp
ret
The above includes all the code that is written even for braces represented above.

More Related Content

Similar to Translate the following CC++ code into MIPS Assembly Codevoid ch.pdf

Write a Pep8 Assembly program that reads in and stores two integers .pdf
Write a Pep8 Assembly program that reads in and stores two integers .pdfWrite a Pep8 Assembly program that reads in and stores two integers .pdf
Write a Pep8 Assembly program that reads in and stores two integers .pdfrushabhshah600
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Romain Francois
 
C++ and Assembly: Debugging and Reverse Engineering
C++ and Assembly: Debugging and Reverse EngineeringC++ and Assembly: Debugging and Reverse Engineering
C++ and Assembly: Debugging and Reverse Engineeringcorehard_by
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate CompilersFunctional Thursday
 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011Deepak Singh
 
Extend R with Rcpp!!!
Extend R with Rcpp!!!Extend R with Rcpp!!!
Extend R with Rcpp!!!mickey24
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Romain Francois
 
Automatically Describing Program Structure and Behavior (PhD Defense)
Automatically Describing Program Structure and Behavior (PhD Defense)Automatically Describing Program Structure and Behavior (PhD Defense)
Automatically Describing Program Structure and Behavior (PhD Defense)Ray Buse
 
Write an MPI program that implements a shell-sort like parallel algo.pdf
Write an MPI program that implements a shell-sort like parallel algo.pdfWrite an MPI program that implements a shell-sort like parallel algo.pdf
Write an MPI program that implements a shell-sort like parallel algo.pdfbharatchawla141
 
Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1Tom Paulus
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64FFRI, Inc.
 
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading SkillsReverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading SkillsAsuka Nakajima
 
HHVM on AArch64 - BUD17-400K1
HHVM on AArch64 - BUD17-400K1HHVM on AArch64 - BUD17-400K1
HHVM on AArch64 - BUD17-400K1Linaro
 
r2con 2017 r2cLEMENCy
r2con 2017 r2cLEMENCyr2con 2017 r2cLEMENCy
r2con 2017 r2cLEMENCyRay Song
 
Abstracting Vector Architectures in Library Generators: Case Study Convolutio...
Abstracting Vector Architectures in Library Generators: Case Study Convolutio...Abstracting Vector Architectures in Library Generators: Case Study Convolutio...
Abstracting Vector Architectures in Library Generators: Case Study Convolutio...ETH Zurich
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperDeepak Singh
 

Similar to Translate the following CC++ code into MIPS Assembly Codevoid ch.pdf (20)

Write a Pep8 Assembly program that reads in and stores two integers .pdf
Write a Pep8 Assembly program that reads in and stores two integers .pdfWrite a Pep8 Assembly program that reads in and stores two integers .pdf
Write a Pep8 Assembly program that reads in and stores two integers .pdf
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
 
C++ and Assembly: Debugging and Reverse Engineering
C++ and Assembly: Debugging and Reverse EngineeringC++ and Assembly: Debugging and Reverse Engineering
C++ and Assembly: Debugging and Reverse Engineering
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011
 
Rcpp11 useR2014
Rcpp11 useR2014Rcpp11 useR2014
Rcpp11 useR2014
 
Extend R with Rcpp!!!
Extend R with Rcpp!!!Extend R with Rcpp!!!
Extend R with Rcpp!!!
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
 
R/C++ talk at earl 2014
R/C++ talk at earl 2014R/C++ talk at earl 2014
R/C++ talk at earl 2014
 
Automatically Describing Program Structure and Behavior (PhD Defense)
Automatically Describing Program Structure and Behavior (PhD Defense)Automatically Describing Program Structure and Behavior (PhD Defense)
Automatically Describing Program Structure and Behavior (PhD Defense)
 
Write an MPI program that implements a shell-sort like parallel algo.pdf
Write an MPI program that implements a shell-sort like parallel algo.pdfWrite an MPI program that implements a shell-sort like parallel algo.pdf
Write an MPI program that implements a shell-sort like parallel algo.pdf
 
Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1Getting Started with Raspberry Pi - DCC 2013.1
Getting Started with Raspberry Pi - DCC 2013.1
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64
 
Rcpp11
Rcpp11Rcpp11
Rcpp11
 
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading SkillsReverse Engineering Dojo: Enhancing Assembly Reading Skills
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
 
HHVM on AArch64 - BUD17-400K1
HHVM on AArch64 - BUD17-400K1HHVM on AArch64 - BUD17-400K1
HHVM on AArch64 - BUD17-400K1
 
r2con 2017 r2cLEMENCy
r2con 2017 r2cLEMENCyr2con 2017 r2cLEMENCy
r2con 2017 r2cLEMENCy
 
Managing console
Managing consoleManaging console
Managing console
 
Abstracting Vector Architectures in Library Generators: Case Study Convolutio...
Abstracting Vector Architectures in Library Generators: Case Study Convolutio...Abstracting Vector Architectures in Library Generators: Case Study Convolutio...
Abstracting Vector Architectures in Library Generators: Case Study Convolutio...
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
 

More from fcsondhiindia

LUS (a) Prepare the jounal entry to recerd the proceeds of the note. .pdf
LUS (a) Prepare the jounal entry to recerd the proceeds of the note. .pdfLUS (a) Prepare the jounal entry to recerd the proceeds of the note. .pdf
LUS (a) Prepare the jounal entry to recerd the proceeds of the note. .pdffcsondhiindia
 
JAVAneed help with public IteratorItem iterator()import java.u.pdf
JAVAneed help with public IteratorItem iterator()import java.u.pdfJAVAneed help with public IteratorItem iterator()import java.u.pdf
JAVAneed help with public IteratorItem iterator()import java.u.pdffcsondhiindia
 
Let A be an n n matrix. Which of the following are TRUE I. If A i.pdf
Let A be an n n matrix. Which of the following are TRUE I. If A i.pdfLet A be an n n matrix. Which of the following are TRUE I. If A i.pdf
Let A be an n n matrix. Which of the following are TRUE I. If A i.pdffcsondhiindia
 
How does PERT technique compare with estimating or forecasting techn.pdf
How does PERT technique compare with estimating or forecasting techn.pdfHow does PERT technique compare with estimating or forecasting techn.pdf
How does PERT technique compare with estimating or forecasting techn.pdffcsondhiindia
 
in 4 paragraphs explain Profit Sharing in the US between Management .pdf
in 4 paragraphs explain Profit Sharing in the US between Management .pdfin 4 paragraphs explain Profit Sharing in the US between Management .pdf
in 4 paragraphs explain Profit Sharing in the US between Management .pdffcsondhiindia
 
I have the source code for three separate java programs (TestVending.pdf
I have the source code for three separate java programs (TestVending.pdfI have the source code for three separate java programs (TestVending.pdf
I have the source code for three separate java programs (TestVending.pdffcsondhiindia
 
How is the urinary system is involved in regulating the pH in bodily.pdf
How is the urinary system is involved in regulating the pH in bodily.pdfHow is the urinary system is involved in regulating the pH in bodily.pdf
How is the urinary system is involved in regulating the pH in bodily.pdffcsondhiindia
 
Find a polynomial that describes the shaded area. SolutionArea.pdf
Find a polynomial that describes the shaded area.  SolutionArea.pdfFind a polynomial that describes the shaded area.  SolutionArea.pdf
Find a polynomial that describes the shaded area. SolutionArea.pdffcsondhiindia
 
Explain the common interest logic and the economic logic of .pdf
Explain the common interest logic and the economic logic of .pdfExplain the common interest logic and the economic logic of .pdf
Explain the common interest logic and the economic logic of .pdffcsondhiindia
 
Does privacy always guarantee integrity. Justify your answerSolu.pdf
Does privacy always guarantee integrity. Justify your answerSolu.pdfDoes privacy always guarantee integrity. Justify your answerSolu.pdf
Does privacy always guarantee integrity. Justify your answerSolu.pdffcsondhiindia
 
Distinguish between the GAAP and IFRS standards for internal .pdf
Distinguish between the GAAP and IFRS standards for internal .pdfDistinguish between the GAAP and IFRS standards for internal .pdf
Distinguish between the GAAP and IFRS standards for internal .pdffcsondhiindia
 
Describe how pH inhibit microbe growth.SolutionMost of the pat.pdf
Describe how pH inhibit microbe growth.SolutionMost of the pat.pdfDescribe how pH inhibit microbe growth.SolutionMost of the pat.pdf
Describe how pH inhibit microbe growth.SolutionMost of the pat.pdffcsondhiindia
 
Write the C code to create a data structure named window that con.pdf
Write the C code to create a data structure named window that con.pdfWrite the C code to create a data structure named window that con.pdf
Write the C code to create a data structure named window that con.pdffcsondhiindia
 
Write 4 to 5 paragraphs aboutthe Dyn cyber attack that occurred in.pdf
Write 4 to 5 paragraphs aboutthe Dyn cyber attack that occurred in.pdfWrite 4 to 5 paragraphs aboutthe Dyn cyber attack that occurred in.pdf
Write 4 to 5 paragraphs aboutthe Dyn cyber attack that occurred in.pdffcsondhiindia
 
Who are the people directly involved in the collective bargaining pr.pdf
Who are the people directly involved in the collective bargaining pr.pdfWho are the people directly involved in the collective bargaining pr.pdf
Who are the people directly involved in the collective bargaining pr.pdffcsondhiindia
 
Contracts or agreements can sometimes create financial contingencies.pdf
Contracts or agreements can sometimes create financial contingencies.pdfContracts or agreements can sometimes create financial contingencies.pdf
Contracts or agreements can sometimes create financial contingencies.pdffcsondhiindia
 
Which of the following is an equation of the line that passes through.pdf
Which of the following is an equation of the line that passes through.pdfWhich of the following is an equation of the line that passes through.pdf
Which of the following is an equation of the line that passes through.pdffcsondhiindia
 
When more than one structural arrangement of elements is possible fo.pdf
When more than one structural arrangement of elements is possible fo.pdfWhen more than one structural arrangement of elements is possible fo.pdf
When more than one structural arrangement of elements is possible fo.pdffcsondhiindia
 
Click to add title 2. Explain the concept of African Diaspora and dis.pdf
Click to add title 2. Explain the concept of African Diaspora and dis.pdfClick to add title 2. Explain the concept of African Diaspora and dis.pdf
Click to add title 2. Explain the concept of African Diaspora and dis.pdffcsondhiindia
 
Based on the following data, what is the quick ratio, rounded to one.pdf
Based on the following data, what is the quick ratio, rounded to one.pdfBased on the following data, what is the quick ratio, rounded to one.pdf
Based on the following data, what is the quick ratio, rounded to one.pdffcsondhiindia
 

More from fcsondhiindia (20)

LUS (a) Prepare the jounal entry to recerd the proceeds of the note. .pdf
LUS (a) Prepare the jounal entry to recerd the proceeds of the note. .pdfLUS (a) Prepare the jounal entry to recerd the proceeds of the note. .pdf
LUS (a) Prepare the jounal entry to recerd the proceeds of the note. .pdf
 
JAVAneed help with public IteratorItem iterator()import java.u.pdf
JAVAneed help with public IteratorItem iterator()import java.u.pdfJAVAneed help with public IteratorItem iterator()import java.u.pdf
JAVAneed help with public IteratorItem iterator()import java.u.pdf
 
Let A be an n n matrix. Which of the following are TRUE I. If A i.pdf
Let A be an n n matrix. Which of the following are TRUE I. If A i.pdfLet A be an n n matrix. Which of the following are TRUE I. If A i.pdf
Let A be an n n matrix. Which of the following are TRUE I. If A i.pdf
 
How does PERT technique compare with estimating or forecasting techn.pdf
How does PERT technique compare with estimating or forecasting techn.pdfHow does PERT technique compare with estimating or forecasting techn.pdf
How does PERT technique compare with estimating or forecasting techn.pdf
 
in 4 paragraphs explain Profit Sharing in the US between Management .pdf
in 4 paragraphs explain Profit Sharing in the US between Management .pdfin 4 paragraphs explain Profit Sharing in the US between Management .pdf
in 4 paragraphs explain Profit Sharing in the US between Management .pdf
 
I have the source code for three separate java programs (TestVending.pdf
I have the source code for three separate java programs (TestVending.pdfI have the source code for three separate java programs (TestVending.pdf
I have the source code for three separate java programs (TestVending.pdf
 
How is the urinary system is involved in regulating the pH in bodily.pdf
How is the urinary system is involved in regulating the pH in bodily.pdfHow is the urinary system is involved in regulating the pH in bodily.pdf
How is the urinary system is involved in regulating the pH in bodily.pdf
 
Find a polynomial that describes the shaded area. SolutionArea.pdf
Find a polynomial that describes the shaded area.  SolutionArea.pdfFind a polynomial that describes the shaded area.  SolutionArea.pdf
Find a polynomial that describes the shaded area. SolutionArea.pdf
 
Explain the common interest logic and the economic logic of .pdf
Explain the common interest logic and the economic logic of .pdfExplain the common interest logic and the economic logic of .pdf
Explain the common interest logic and the economic logic of .pdf
 
Does privacy always guarantee integrity. Justify your answerSolu.pdf
Does privacy always guarantee integrity. Justify your answerSolu.pdfDoes privacy always guarantee integrity. Justify your answerSolu.pdf
Does privacy always guarantee integrity. Justify your answerSolu.pdf
 
Distinguish between the GAAP and IFRS standards for internal .pdf
Distinguish between the GAAP and IFRS standards for internal .pdfDistinguish between the GAAP and IFRS standards for internal .pdf
Distinguish between the GAAP and IFRS standards for internal .pdf
 
Describe how pH inhibit microbe growth.SolutionMost of the pat.pdf
Describe how pH inhibit microbe growth.SolutionMost of the pat.pdfDescribe how pH inhibit microbe growth.SolutionMost of the pat.pdf
Describe how pH inhibit microbe growth.SolutionMost of the pat.pdf
 
Write the C code to create a data structure named window that con.pdf
Write the C code to create a data structure named window that con.pdfWrite the C code to create a data structure named window that con.pdf
Write the C code to create a data structure named window that con.pdf
 
Write 4 to 5 paragraphs aboutthe Dyn cyber attack that occurred in.pdf
Write 4 to 5 paragraphs aboutthe Dyn cyber attack that occurred in.pdfWrite 4 to 5 paragraphs aboutthe Dyn cyber attack that occurred in.pdf
Write 4 to 5 paragraphs aboutthe Dyn cyber attack that occurred in.pdf
 
Who are the people directly involved in the collective bargaining pr.pdf
Who are the people directly involved in the collective bargaining pr.pdfWho are the people directly involved in the collective bargaining pr.pdf
Who are the people directly involved in the collective bargaining pr.pdf
 
Contracts or agreements can sometimes create financial contingencies.pdf
Contracts or agreements can sometimes create financial contingencies.pdfContracts or agreements can sometimes create financial contingencies.pdf
Contracts or agreements can sometimes create financial contingencies.pdf
 
Which of the following is an equation of the line that passes through.pdf
Which of the following is an equation of the line that passes through.pdfWhich of the following is an equation of the line that passes through.pdf
Which of the following is an equation of the line that passes through.pdf
 
When more than one structural arrangement of elements is possible fo.pdf
When more than one structural arrangement of elements is possible fo.pdfWhen more than one structural arrangement of elements is possible fo.pdf
When more than one structural arrangement of elements is possible fo.pdf
 
Click to add title 2. Explain the concept of African Diaspora and dis.pdf
Click to add title 2. Explain the concept of African Diaspora and dis.pdfClick to add title 2. Explain the concept of African Diaspora and dis.pdf
Click to add title 2. Explain the concept of African Diaspora and dis.pdf
 
Based on the following data, what is the quick ratio, rounded to one.pdf
Based on the following data, what is the quick ratio, rounded to one.pdfBased on the following data, what is the quick ratio, rounded to one.pdf
Based on the following data, what is the quick ratio, rounded to one.pdf
 

Recently uploaded

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 

Recently uploaded (20)

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 

Translate the following CC++ code into MIPS Assembly Codevoid ch.pdf

  • 1. Translate the following C/C++ code into MIPS Assembly Code: void chico(int *X, int Y, int Z) { *X = Y/4 - Z*10 + *X*8; } int main() { int J, K, L, M; cin >> J, K, L; chico ( &J, K, L); M = J - (K + L); cout << M; return 0; } Solution Program: #include using namespace std; void chico(int *X, int Y, int Z) { *X = Y/4 - Z*10 + *X*8; } int main() { int J, K, L, M; cin >> J,K,L; chico ( &J, K, L); M = J - (K + L); cout<<"value"<< M; return 0; } The above code returns the following Mips code : chico(int*, int, int):
  • 2. push rbp mov rbp, rsp mov QWORD PTR [rbp-8], rdi mov DWORD PTR [rbp-12], esi mov DWORD PTR [rbp-16], edx mov eax, DWORD PTR [rbp-12] lea edx, [rax+3] test eax, eax cmovs eax, edx sar eax, 2 mov ecx, eax mov edx, DWORD PTR [rbp-16] mov eax, edx sal eax, 2 add eax, edx add eax, eax neg eax lea edx, [rcx+rax] mov rax, QWORD PTR [rbp-8] mov eax, DWORD PTR [rax] sal eax, 3 add edx, eax mov rax, QWORD PTR [rbp-8] mov DWORD PTR [rax], edx nop pop rbp ret .LC0: .string "value" main: push rbp mov rbp, rsp sub rsp, 16 lea rax, [rbp-16] mov rsi, rax mov edi, OFFSET FLAT:std::cin
  • 3. call std::basic_istream >::operator>>(int&) mov edx, DWORD PTR [rbp-8] mov ecx, DWORD PTR [rbp-4] lea rax, [rbp-16] mov esi, ecx mov rdi, rax call chico(int*, int, int) mov eax, DWORD PTR [rbp-16] mov ecx, DWORD PTR [rbp-4] mov edx, DWORD PTR [rbp-8] add edx, ecx sub eax, edx mov DWORD PTR [rbp-12], eax mov esi, OFFSET FLAT:.LC0 mov edi, OFFSET FLAT:std::cout call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) mov rdx, rax mov eax, DWORD PTR [rbp-12] mov esi, eax mov rdi, rdx call std::basic_ostream >::operator<<(int) mov eax, 0 leave ret __static_initialization_and_destruction_0(int, int): push rbp mov rbp, rsp sub rsp, 16 mov DWORD PTR [rbp-4], edi mov DWORD PTR [rbp-8], esi cmp DWORD PTR [rbp-4], 1 jne .L6 cmp DWORD PTR [rbp-8], 65535 jne .L6 mov edi, OFFSET FLAT:std::__ioinit call std::ios_base::Init::Init()
  • 4. mov edx, OFFSET FLAT:__dso_handle mov esi, OFFSET FLAT:std::__ioinit mov edi, OFFSET FLAT:std::ios_base::Init::~Init() call __cxa_atexit .L6: nop leave ret push rbp mov rbp, rsp mov esi, 65535 mov edi, 1 call __static_initialization_and_destruction_0(int, int) pop rbp ret The above includes all the code that is written even for braces represented above.