SlideShare a Scribd company logo
1 of 3
Download to read offline
Write a Pep/8 Assembly program that reads in and stores two integers from the user and prints
out their sum in the form: Total = Submit: Pep/8 formatted program in a text file
Solution
Answer:
Assembly Language Program :
.zero 1
.LC0:
.string "Enter two integers: "
.LC1:
.string "Total"
.LC2:
.string " = "
main:
push rbp
mov rbp, rsp
sub rsp, 16
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
lea rax, [rbp-8]
mov rsi, rax
mov edi, OFFSET FLAT:std::cin
call std::basic_istream >::operator>>(int&)
mov rdx, rax
lea rax, [rbp-12]
mov rsi, rax
mov rdi, rdx
call std::basic_istream >::operator>>(int&)
mov edx, DWORD PTR [rbp-8]
mov eax, DWORD PTR [rbp-12]
add eax, edx
mov DWORD PTR [rbp-4], eax
mov esi, OFFSET FLAT:.LC1
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
mov esi, OFFSET FLAT:.LC2
mov rdi, rax
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
mov rdx, rax
mov eax, DWORD PTR [rbp-4]
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 .L5
cmp DWORD PTR [rbp-8], 65535
jne .L5
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
.L5:
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 Write a Pep8 Assembly program that reads in and stores two integers .pdf

PHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & PinbaPHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & Pinba
Patrick Allaert
 
Write a program in MIPS that reads in a Roman form number from th.pdf
Write a program in MIPS that reads in a Roman form number from th.pdfWrite a program in MIPS that reads in a Roman form number from th.pdf
Write a program in MIPS that reads in a Roman form number from th.pdf
santanadenisesarin13
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
Romain Francois
 

Similar to Write a Pep8 Assembly program that reads in and stores two integers .pdf (20)

Assembler Programming
Assembler ProgrammingAssembler Programming
Assembler Programming
 
Debugging TV Frame 0x13
Debugging TV Frame 0x13Debugging TV Frame 0x13
Debugging TV Frame 0x13
 
Alp 05
Alp 05Alp 05
Alp 05
 
Rcpp11
Rcpp11Rcpp11
Rcpp11
 
Assembler
AssemblerAssembler
Assembler
 
Chapter3.ppt
Chapter3.pptChapter3.ppt
Chapter3.ppt
 
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
 
nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
 
eBPF Tooling and Debugging Infrastructure
eBPF Tooling and Debugging InfrastructureeBPF Tooling and Debugging Infrastructure
eBPF Tooling and Debugging Infrastructure
 
Virtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsVirtual Machine for Regular Expressions
Virtual Machine for Regular Expressions
 
PHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & PinbaPHP applications/environments monitoring: APM & Pinba
PHP applications/environments monitoring: APM & Pinba
 
Write a program in MIPS that reads in a Roman form number from th.pdf
Write a program in MIPS that reads in a Roman form number from th.pdfWrite a program in MIPS that reads in a Roman form number from th.pdf
Write a program in MIPS that reads in a Roman form number from th.pdf
 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008
 
Implementation - Sample Runs
Implementation - Sample RunsImplementation - Sample Runs
Implementation - Sample Runs
 
ARM instruction set
ARM instruction  setARM instruction  set
ARM instruction set
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
 
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06Lect-06
 
L10 assembly-language-programming-of-atmega328 p
L10 assembly-language-programming-of-atmega328 pL10 assembly-language-programming-of-atmega328 p
L10 assembly-language-programming-of-atmega328 p
 
C Programming ppt for beginners . Introduction
C Programming ppt for beginners . IntroductionC Programming ppt for beginners . Introduction
C Programming ppt for beginners . Introduction
 

More from rushabhshah600

art F You decide to cross the reciprocal translocation strain to a pu.pdf
art F You decide to cross the reciprocal translocation strain to a pu.pdfart F You decide to cross the reciprocal translocation strain to a pu.pdf
art F You decide to cross the reciprocal translocation strain to a pu.pdf
rushabhshah600
 
Ecosystem ecologyWhy are rain forests wet and deserts dry Compare.pdf
Ecosystem ecologyWhy are rain forests wet and deserts dry Compare.pdfEcosystem ecologyWhy are rain forests wet and deserts dry Compare.pdf
Ecosystem ecologyWhy are rain forests wet and deserts dry Compare.pdf
rushabhshah600
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
rushabhshah600
 
Distinguish between cell fate and cell commitment. How can one assay.pdf
Distinguish between cell fate and cell commitment. How can one assay.pdfDistinguish between cell fate and cell commitment. How can one assay.pdf
Distinguish between cell fate and cell commitment. How can one assay.pdf
rushabhshah600
 
Differentiate the processes of oogenesis and spermatogenesis. Are th.pdf
Differentiate the processes of oogenesis and spermatogenesis. Are th.pdfDifferentiate the processes of oogenesis and spermatogenesis. Are th.pdf
Differentiate the processes of oogenesis and spermatogenesis. Are th.pdf
rushabhshah600
 
City GUIWrite a Java GUI program which reads data about US cities..pdf
City GUIWrite a Java GUI program which reads data about US cities..pdfCity GUIWrite a Java GUI program which reads data about US cities..pdf
City GUIWrite a Java GUI program which reads data about US cities..pdf
rushabhshah600
 
Briefly describe the contributions to the quality movement made by e.pdf
Briefly describe the contributions to the quality movement made by e.pdfBriefly describe the contributions to the quality movement made by e.pdf
Briefly describe the contributions to the quality movement made by e.pdf
rushabhshah600
 
Background Angiosperms (flowering plants) are the largest Phylum in .pdf
Background  Angiosperms (flowering plants) are the largest Phylum in .pdfBackground  Angiosperms (flowering plants) are the largest Phylum in .pdf
Background Angiosperms (flowering plants) are the largest Phylum in .pdf
rushabhshah600
 

More from rushabhshah600 (20)

Give an expression for the pattern inventory of 2-colorings of the ed.pdf
Give an expression for the pattern inventory of 2-colorings of the ed.pdfGive an expression for the pattern inventory of 2-colorings of the ed.pdf
Give an expression for the pattern inventory of 2-colorings of the ed.pdf
 
For the 4 arguments below, proceed as followsBREAK DOWN THE ARGU.pdf
For the 4 arguments below, proceed as followsBREAK DOWN THE ARGU.pdfFor the 4 arguments below, proceed as followsBREAK DOWN THE ARGU.pdf
For the 4 arguments below, proceed as followsBREAK DOWN THE ARGU.pdf
 
External respiration includes all of these processes EXCEPT _____. r.pdf
External respiration includes all of these processes EXCEPT _____.  r.pdfExternal respiration includes all of these processes EXCEPT _____.  r.pdf
External respiration includes all of these processes EXCEPT _____. r.pdf
 
art F You decide to cross the reciprocal translocation strain to a pu.pdf
art F You decide to cross the reciprocal translocation strain to a pu.pdfart F You decide to cross the reciprocal translocation strain to a pu.pdf
art F You decide to cross the reciprocal translocation strain to a pu.pdf
 
Ecosystem ecologyWhy are rain forests wet and deserts dry Compare.pdf
Ecosystem ecologyWhy are rain forests wet and deserts dry Compare.pdfEcosystem ecologyWhy are rain forests wet and deserts dry Compare.pdf
Ecosystem ecologyWhy are rain forests wet and deserts dry Compare.pdf
 
b) Analyze your network IP packets headers and contents.Solu.pdf
b) Analyze your network IP packets headers and contents.Solu.pdfb) Analyze your network IP packets headers and contents.Solu.pdf
b) Analyze your network IP packets headers and contents.Solu.pdf
 
A type A man is the son of a type O father and type A mother. If he .pdf
A type A man is the son of a type O father and type A mother. If he .pdfA type A man is the son of a type O father and type A mother. If he .pdf
A type A man is the son of a type O father and type A mother. If he .pdf
 
A One-Way Analysis of Variance is a way to test the equality of thre.pdf
A One-Way Analysis of Variance is a way to test the equality of thre.pdfA One-Way Analysis of Variance is a way to test the equality of thre.pdf
A One-Way Analysis of Variance is a way to test the equality of thre.pdf
 
5 000-0 SolutionEquity multiplier = Total Assets Equityor, .pdf
5 000-0 SolutionEquity multiplier = Total Assets  Equityor, .pdf5 000-0 SolutionEquity multiplier = Total Assets  Equityor, .pdf
5 000-0 SolutionEquity multiplier = Total Assets Equityor, .pdf
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
4 (4 points). How would you describe the difference in cell structur.pdf
4 (4 points). How would you describe the difference in cell structur.pdf4 (4 points). How would you describe the difference in cell structur.pdf
4 (4 points). How would you describe the difference in cell structur.pdf
 
Distinguish between cell fate and cell commitment. How can one assay.pdf
Distinguish between cell fate and cell commitment. How can one assay.pdfDistinguish between cell fate and cell commitment. How can one assay.pdf
Distinguish between cell fate and cell commitment. How can one assay.pdf
 
Differentiate the processes of oogenesis and spermatogenesis. Are th.pdf
Differentiate the processes of oogenesis and spermatogenesis. Are th.pdfDifferentiate the processes of oogenesis and spermatogenesis. Are th.pdf
Differentiate the processes of oogenesis and spermatogenesis. Are th.pdf
 
Define induction and give an example of deductive reasoningSolu.pdf
Define induction and give an example of deductive reasoningSolu.pdfDefine induction and give an example of deductive reasoningSolu.pdf
Define induction and give an example of deductive reasoningSolu.pdf
 
A report says that the between-subjects factor of participants sal.pdf
A report says that the between-subjects factor of participants sal.pdfA report says that the between-subjects factor of participants sal.pdf
A report says that the between-subjects factor of participants sal.pdf
 
City GUIWrite a Java GUI program which reads data about US cities..pdf
City GUIWrite a Java GUI program which reads data about US cities..pdfCity GUIWrite a Java GUI program which reads data about US cities..pdf
City GUIWrite a Java GUI program which reads data about US cities..pdf
 
What is the role of sulfur chemoautotrophs in the sulfur cycle Deco.pdf
What is the role of sulfur chemoautotrophs in the sulfur cycle  Deco.pdfWhat is the role of sulfur chemoautotrophs in the sulfur cycle  Deco.pdf
What is the role of sulfur chemoautotrophs in the sulfur cycle Deco.pdf
 
What is the PDU at Layer 4 calledA. DataB. SegmentC. Packet.pdf
What is the PDU at Layer 4 calledA. DataB. SegmentC. Packet.pdfWhat is the PDU at Layer 4 calledA. DataB. SegmentC. Packet.pdf
What is the PDU at Layer 4 calledA. DataB. SegmentC. Packet.pdf
 
Briefly describe the contributions to the quality movement made by e.pdf
Briefly describe the contributions to the quality movement made by e.pdfBriefly describe the contributions to the quality movement made by e.pdf
Briefly describe the contributions to the quality movement made by e.pdf
 
Background Angiosperms (flowering plants) are the largest Phylum in .pdf
Background  Angiosperms (flowering plants) are the largest Phylum in .pdfBackground  Angiosperms (flowering plants) are the largest Phylum in .pdf
Background Angiosperms (flowering plants) are the largest Phylum in .pdf
 

Recently uploaded

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
 

Recently uploaded (20)

FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
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
 
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...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
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
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 

Write a Pep8 Assembly program that reads in and stores two integers .pdf

  • 1. Write a Pep/8 Assembly program that reads in and stores two integers from the user and prints out their sum in the form: Total = Submit: Pep/8 formatted program in a text file Solution Answer: Assembly Language Program : .zero 1 .LC0: .string "Enter two integers: " .LC1: .string "Total" .LC2: .string " = " main: push rbp mov rbp, rsp sub rsp, 16 mov esi, OFFSET FLAT:.LC0 mov edi, OFFSET FLAT:std::cout call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) lea rax, [rbp-8] mov rsi, rax mov edi, OFFSET FLAT:std::cin call std::basic_istream >::operator>>(int&) mov rdx, rax lea rax, [rbp-12] mov rsi, rax mov rdi, rdx call std::basic_istream >::operator>>(int&) mov edx, DWORD PTR [rbp-8] mov eax, DWORD PTR [rbp-12] add eax, edx mov DWORD PTR [rbp-4], eax mov esi, OFFSET FLAT:.LC1 mov edi, OFFSET FLAT:std::cout
  • 2. call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) mov esi, OFFSET FLAT:.LC2 mov rdi, rax call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) mov rdx, rax mov eax, DWORD PTR [rbp-4] 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 .L5 cmp DWORD PTR [rbp-8], 65535 jne .L5 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 .L5: nop leave ret push rbp mov rbp, rsp mov esi, 65535 mov edi, 1