SlideShare a Scribd company logo
1 of 2
Download to read offline
How would you write this in MARIE assembly language?
int count = 0;
int number = 30;
int otherNum = 10;
while ( count <= number)
count += 3;
output = count/otherNum;
Solution
Answer:
.zero 1
main:
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], 0
mov DWORD PTR [rbp-8], 30
mov DWORD PTR [rbp-12], 10
.L3:
mov eax, DWORD PTR [rbp-4]
cmp eax, DWORD PTR [rbp-8]
jg .L2
add DWORD PTR [rbp-4], 3
jmp .L3
.L2:
mov eax, DWORD PTR [rbp-4]
cdq
idiv DWORD PTR [rbp-12]
mov DWORD PTR [rbp-16], eax
mov eax, 0
pop rbp
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 .L7
cmp DWORD PTR [rbp-8], 65535
jne .L7
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
.L7:
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

More Related Content

Similar to How would you write this in MARIE assembly languageint count = 0;.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 .pdf
rushabhshah600
 
Fix assembly Code new peoblem on call printf gt .pdf
Fix assembly Code new peoblem on call printf gt  .pdfFix assembly Code new peoblem on call printf gt  .pdf
Fix assembly Code new peoblem on call printf gt .pdf
rchopra4
 
1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf
1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf
1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf
aromanets
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
logesh waran
 

Similar to How would you write this in MARIE assembly languageint count = 0;.pdf (20)

OptimizingARM
OptimizingARMOptimizingARM
OptimizingARM
 
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
 
Unit vi
Unit viUnit vi
Unit vi
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
 
커널코드분석 20140621(head.s restart)
커널코드분석 20140621(head.s restart)커널코드분석 20140621(head.s restart)
커널코드분석 20140621(head.s restart)
 
Arm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptArm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.ppt
 
ARM instruction set
ARM instruction  setARM instruction  set
ARM instruction set
 
Function Call Optimization
Function Call OptimizationFunction Call Optimization
Function Call Optimization
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
 
Module 2 PPT of ES.pptx
Module 2 PPT of ES.pptxModule 2 PPT of ES.pptx
Module 2 PPT of ES.pptx
 
Linear programming wi̇th R
Linear programming wi̇th RLinear programming wi̇th R
Linear programming wi̇th R
 
Fix assembly Code new peoblem on call printf gt .pdf
Fix assembly Code new peoblem on call printf gt  .pdfFix assembly Code new peoblem on call printf gt  .pdf
Fix assembly Code new peoblem on call printf gt .pdf
 
ARM AAE - Intrustion Sets
ARM AAE - Intrustion SetsARM AAE - Intrustion Sets
ARM AAE - Intrustion Sets
 
R/C++ talk at earl 2014
R/C++ talk at earl 2014R/C++ talk at earl 2014
R/C++ talk at earl 2014
 
1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf
1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf
1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf
 
Predication
PredicationPredication
Predication
 
UNIT 2 ERTS.ppt
UNIT 2 ERTS.pptUNIT 2 ERTS.ppt
UNIT 2 ERTS.ppt
 
optimization c code on blackfin
optimization c code on blackfinoptimization c code on blackfin
optimization c code on blackfin
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
 
Protecting C++
Protecting C++Protecting C++
Protecting C++
 

More from bermanbeancolungak45

Write a program that randomly generates a maze in javaSolution.pdf
Write a program that randomly generates a maze in javaSolution.pdfWrite a program that randomly generates a maze in javaSolution.pdf
Write a program that randomly generates a maze in javaSolution.pdf
bermanbeancolungak45
 
why is the idea of a standard network protocol such as the OSI refer.pdf
why is the idea of a standard network protocol such as the OSI refer.pdfwhy is the idea of a standard network protocol such as the OSI refer.pdf
why is the idea of a standard network protocol such as the OSI refer.pdf
bermanbeancolungak45
 
What is the purpose of database administration2. What is the purp.pdf
What is the purpose of database administration2. What is the purp.pdfWhat is the purpose of database administration2. What is the purp.pdf
What is the purpose of database administration2. What is the purp.pdf
bermanbeancolungak45
 
what is code to draw sun and earth and the moon in java OpenGLS.pdf
what is code to draw sun and earth and the moon in java OpenGLS.pdfwhat is code to draw sun and earth and the moon in java OpenGLS.pdf
what is code to draw sun and earth and the moon in java OpenGLS.pdf
bermanbeancolungak45
 
What factors do you think make them excellent project reports write.pdf
What factors do you think make them excellent project reports write.pdfWhat factors do you think make them excellent project reports write.pdf
What factors do you think make them excellent project reports write.pdf
bermanbeancolungak45
 
What aspects of todays information economy have influenced the imp.pdf
What aspects of todays information economy have influenced the imp.pdfWhat aspects of todays information economy have influenced the imp.pdf
What aspects of todays information economy have influenced the imp.pdf
bermanbeancolungak45
 
This week, we are going to work together as a class to assist the Lon.pdf
This week, we are going to work together as a class to assist the Lon.pdfThis week, we are going to work together as a class to assist the Lon.pdf
This week, we are going to work together as a class to assist the Lon.pdf
bermanbeancolungak45
 
Take a position on this statement The media represent realistic ima.pdf
Take a position on this statement The media represent realistic ima.pdfTake a position on this statement The media represent realistic ima.pdf
Take a position on this statement The media represent realistic ima.pdf
bermanbeancolungak45
 
Relate selected early morphological developments in the ancestors of.pdf
Relate selected early morphological developments in the ancestors of.pdfRelate selected early morphological developments in the ancestors of.pdf
Relate selected early morphological developments in the ancestors of.pdf
bermanbeancolungak45
 
Question VI. In 1976, Hozumi and Tonegawa published an elegant paper.pdf
Question VI. In 1976, Hozumi and Tonegawa published an elegant paper.pdfQuestion VI. In 1976, Hozumi and Tonegawa published an elegant paper.pdf
Question VI. In 1976, Hozumi and Tonegawa published an elegant paper.pdf
bermanbeancolungak45
 
question - Jurassic Park (book and movie) proposed the concept of.pdf
question - Jurassic Park (book and movie) proposed the concept of.pdfquestion - Jurassic Park (book and movie) proposed the concept of.pdf
question - Jurassic Park (book and movie) proposed the concept of.pdf
bermanbeancolungak45
 
Prior to the development of anti-retroviral drugs, HIV infected pati.pdf
Prior to the development of anti-retroviral drugs, HIV infected pati.pdfPrior to the development of anti-retroviral drugs, HIV infected pati.pdf
Prior to the development of anti-retroviral drugs, HIV infected pati.pdf
bermanbeancolungak45
 
Please this is my second time posting. I really need the right answe.pdf
Please this is my second time posting. I really need the right answe.pdfPlease this is my second time posting. I really need the right answe.pdf
Please this is my second time posting. I really need the right answe.pdf
bermanbeancolungak45
 

More from bermanbeancolungak45 (20)

Write a program that randomly generates a maze in javaSolution.pdf
Write a program that randomly generates a maze in javaSolution.pdfWrite a program that randomly generates a maze in javaSolution.pdf
Write a program that randomly generates a maze in javaSolution.pdf
 
why is the idea of a standard network protocol such as the OSI refer.pdf
why is the idea of a standard network protocol such as the OSI refer.pdfwhy is the idea of a standard network protocol such as the OSI refer.pdf
why is the idea of a standard network protocol such as the OSI refer.pdf
 
Which of the following potential problems need not be considered whe.pdf
Which of the following potential problems need not be considered whe.pdfWhich of the following potential problems need not be considered whe.pdf
Which of the following potential problems need not be considered whe.pdf
 
Which of the following is true of mutations They are very common T.pdf
Which of the following is true of mutations  They are very common  T.pdfWhich of the following is true of mutations  They are very common  T.pdf
Which of the following is true of mutations They are very common T.pdf
 
What type of security vulnerability are developers most likely to in.pdf
What type of security vulnerability are developers most likely to in.pdfWhat type of security vulnerability are developers most likely to in.pdf
What type of security vulnerability are developers most likely to in.pdf
 
What is the purpose of database administration2. What is the purp.pdf
What is the purpose of database administration2. What is the purp.pdfWhat is the purpose of database administration2. What is the purp.pdf
What is the purpose of database administration2. What is the purp.pdf
 
what is code to draw sun and earth and the moon in java OpenGLS.pdf
what is code to draw sun and earth and the moon in java OpenGLS.pdfwhat is code to draw sun and earth and the moon in java OpenGLS.pdf
what is code to draw sun and earth and the moon in java OpenGLS.pdf
 
What factors do you think make them excellent project reports write.pdf
What factors do you think make them excellent project reports write.pdfWhat factors do you think make them excellent project reports write.pdf
What factors do you think make them excellent project reports write.pdf
 
What aspects of todays information economy have influenced the imp.pdf
What aspects of todays information economy have influenced the imp.pdfWhat aspects of todays information economy have influenced the imp.pdf
What aspects of todays information economy have influenced the imp.pdf
 
This week, we are going to work together as a class to assist the Lon.pdf
This week, we are going to work together as a class to assist the Lon.pdfThis week, we are going to work together as a class to assist the Lon.pdf
This week, we are going to work together as a class to assist the Lon.pdf
 
The phylogenetic species concept looks at environmental adaptations a.pdf
The phylogenetic species concept looks at environmental adaptations a.pdfThe phylogenetic species concept looks at environmental adaptations a.pdf
The phylogenetic species concept looks at environmental adaptations a.pdf
 
The percentage of high school students who drink and drive was 17.5.pdf
The percentage of high school students who drink and drive was 17.5.pdfThe percentage of high school students who drink and drive was 17.5.pdf
The percentage of high school students who drink and drive was 17.5.pdf
 
Take a position on this statement The media represent realistic ima.pdf
Take a position on this statement The media represent realistic ima.pdfTake a position on this statement The media represent realistic ima.pdf
Take a position on this statement The media represent realistic ima.pdf
 
Suppose 60 different survey organizations visit eastern Tennessee to.pdf
Suppose 60 different survey organizations visit eastern Tennessee to.pdfSuppose 60 different survey organizations visit eastern Tennessee to.pdf
Suppose 60 different survey organizations visit eastern Tennessee to.pdf
 
Relate selected early morphological developments in the ancestors of.pdf
Relate selected early morphological developments in the ancestors of.pdfRelate selected early morphological developments in the ancestors of.pdf
Relate selected early morphological developments in the ancestors of.pdf
 
Question VI. In 1976, Hozumi and Tonegawa published an elegant paper.pdf
Question VI. In 1976, Hozumi and Tonegawa published an elegant paper.pdfQuestion VI. In 1976, Hozumi and Tonegawa published an elegant paper.pdf
Question VI. In 1976, Hozumi and Tonegawa published an elegant paper.pdf
 
question - Jurassic Park (book and movie) proposed the concept of.pdf
question - Jurassic Park (book and movie) proposed the concept of.pdfquestion - Jurassic Park (book and movie) proposed the concept of.pdf
question - Jurassic Park (book and movie) proposed the concept of.pdf
 
Python programming question Assume that a file containing a serie.pdf
Python programming question Assume that a file containing a serie.pdfPython programming question Assume that a file containing a serie.pdf
Python programming question Assume that a file containing a serie.pdf
 
Prior to the development of anti-retroviral drugs, HIV infected pati.pdf
Prior to the development of anti-retroviral drugs, HIV infected pati.pdfPrior to the development of anti-retroviral drugs, HIV infected pati.pdf
Prior to the development of anti-retroviral drugs, HIV infected pati.pdf
 
Please this is my second time posting. I really need the right answe.pdf
Please this is my second time posting. I really need the right answe.pdfPlease this is my second time posting. I really need the right answe.pdf
Please this is my second time posting. I really need the right answe.pdf
 

Recently uploaded

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
QucHHunhnh
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
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
QucHHunhnh
 

Recently uploaded (20)

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
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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...
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
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.
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
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
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 

How would you write this in MARIE assembly languageint count = 0;.pdf

  • 1. How would you write this in MARIE assembly language? int count = 0; int number = 30; int otherNum = 10; while ( count <= number) count += 3; output = count/otherNum; Solution Answer: .zero 1 main: push rbp mov rbp, rsp mov DWORD PTR [rbp-4], 0 mov DWORD PTR [rbp-8], 30 mov DWORD PTR [rbp-12], 10 .L3: mov eax, DWORD PTR [rbp-4] cmp eax, DWORD PTR [rbp-8] jg .L2 add DWORD PTR [rbp-4], 3 jmp .L3 .L2: mov eax, DWORD PTR [rbp-4] cdq idiv DWORD PTR [rbp-12] mov DWORD PTR [rbp-16], eax mov eax, 0 pop rbp ret __static_initialization_and_destruction_0(int, int): push rbp mov rbp, rsp
  • 2. sub rsp, 16 mov DWORD PTR [rbp-4], edi mov DWORD PTR [rbp-8], esi cmp DWORD PTR [rbp-4], 1 jne .L7 cmp DWORD PTR [rbp-8], 65535 jne .L7 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 .L7: 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