SlideShare a Scribd company logo
1 of 1
Mips assembly language
Generate the quadruples for the program code fragment and include details. Please see the
attached photo below.
Solution
; roots.asm segment .text global _roots _roots: enter 0,0 xor EAX,EAX fld qword[EBP+8] ; a
fadd ST0 ; 2a fld qword[EBP+8] ; a,2a fld qword[EBP+24] ; c,a,2a fmulp ST1 ; ac,2a fadd ST0 ;
2ac,2a fadd st0 ; 4ac,2a fchs ; -4ac,2a fld qword[EBP+16] ; b,-4ac,2a fld qword[EBP+16] ; b,b,-
4ac,2a fmulp ST1 ; b*b,-4ac,2a faddp ST1 ; b*b-4ac,2a ftst ; cmp (b*b-4ac),0 fstsw AX ; result
of test in AX sahf ; store AH in flag reg jb no_real_roots ; jb tests the carry flag fsqrt ; sqrt(b*b-
4ac),2a fld qword[EBP+16] ; b,sqrt(b*b-4ac),2a fchs ; -b,sqrt(b*b-4ac),2a fadd ST1 ; -
b+sqrt(b*b-4ac),sqrt(b*b-4ac),2a fdiv ST2 ; -b+sqrt(b*b-4ac)/2a,sqrt(b*b-4ac),2a mov
EAX,dword[EBP+32] ; EAX = -b+sqrt(b*b-4ac)/2a fstp qword[EAX] ; Store and pop fld
qword[EBP+16] ; b,sqrt(b*b-4ac),2a fchs ; -b,sqrt(b*b-4ac),2a fsubp ST1 ; -b-sqrt(b*b-4ac),2a
fdivrp ST1 ; -b-sqrt(b*b-4ac)/2a mov EAX,dword[EBP+36] ; EAX = -b-sqrt(b*b-4ac)/2a fstp
qword[EAX] ; Store and pop mov EAX,1 ; 1 means real roots jmp short done no_real_roots: sub
EAX,EAX ; 0 means no real roots done: leave ret

More Related Content

More from scroghamtressie

Name four services that might allow you to control a VM in an IaaS env.docx
Name four services that might allow you to control a VM in an IaaS env.docxName four services that might allow you to control a VM in an IaaS env.docx
Name four services that might allow you to control a VM in an IaaS env.docxscroghamtressie
 
mus101 What musical techniques did Vivaldi use in La Primavera to depi.docx
mus101 What musical techniques did Vivaldi use in La Primavera to depi.docxmus101 What musical techniques did Vivaldi use in La Primavera to depi.docx
mus101 What musical techniques did Vivaldi use in La Primavera to depi.docxscroghamtressie
 
Must every revolution end in tyranny (as suggested by Ignazio Silone)-.docx
Must every revolution end in tyranny (as suggested by Ignazio Silone)-.docxMust every revolution end in tyranny (as suggested by Ignazio Silone)-.docx
Must every revolution end in tyranny (as suggested by Ignazio Silone)-.docxscroghamtressie
 
Multiple Choice Question The information in the following table is fro.docx
Multiple Choice Question The information in the following table is fro.docxMultiple Choice Question The information in the following table is fro.docx
Multiple Choice Question The information in the following table is fro.docxscroghamtressie
 
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docx
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docxMicrosoft Visual C# 2012- An introduction to object-oriented programmi.docx
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docxscroghamtressie
 
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docxMerge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docxscroghamtressie
 
Match the words in the left column to the appropriate blanks in the se.docx
Match the words in the left column to the appropriate blanks in the se.docxMatch the words in the left column to the appropriate blanks in the se.docx
Match the words in the left column to the appropriate blanks in the se.docxscroghamtressie
 
Nathanson Corporation was organized on May 1- 2014- The following even.docx
Nathanson Corporation was organized on May 1- 2014- The following even.docxNathanson Corporation was organized on May 1- 2014- The following even.docx
Nathanson Corporation was organized on May 1- 2014- The following even.docxscroghamtressie
 
Match the following aqueous solutions with the appropriate letter from (4).docx
Match the following aqueous solutions with the appropriate letter from (4).docxMatch the following aqueous solutions with the appropriate letter from (4).docx
Match the following aqueous solutions with the appropriate letter from (4).docxscroghamtressie
 

More from scroghamtressie (9)

Name four services that might allow you to control a VM in an IaaS env.docx
Name four services that might allow you to control a VM in an IaaS env.docxName four services that might allow you to control a VM in an IaaS env.docx
Name four services that might allow you to control a VM in an IaaS env.docx
 
mus101 What musical techniques did Vivaldi use in La Primavera to depi.docx
mus101 What musical techniques did Vivaldi use in La Primavera to depi.docxmus101 What musical techniques did Vivaldi use in La Primavera to depi.docx
mus101 What musical techniques did Vivaldi use in La Primavera to depi.docx
 
Must every revolution end in tyranny (as suggested by Ignazio Silone)-.docx
Must every revolution end in tyranny (as suggested by Ignazio Silone)-.docxMust every revolution end in tyranny (as suggested by Ignazio Silone)-.docx
Must every revolution end in tyranny (as suggested by Ignazio Silone)-.docx
 
Multiple Choice Question The information in the following table is fro.docx
Multiple Choice Question The information in the following table is fro.docxMultiple Choice Question The information in the following table is fro.docx
Multiple Choice Question The information in the following table is fro.docx
 
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docx
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docxMicrosoft Visual C# 2012- An introduction to object-oriented programmi.docx
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docx
 
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docxMerge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
Merge sort in CSolution#include-stdio-h- #define MAX 50 void mergeSort.docx
 
Match the words in the left column to the appropriate blanks in the se.docx
Match the words in the left column to the appropriate blanks in the se.docxMatch the words in the left column to the appropriate blanks in the se.docx
Match the words in the left column to the appropriate blanks in the se.docx
 
Nathanson Corporation was organized on May 1- 2014- The following even.docx
Nathanson Corporation was organized on May 1- 2014- The following even.docxNathanson Corporation was organized on May 1- 2014- The following even.docx
Nathanson Corporation was organized on May 1- 2014- The following even.docx
 
Match the following aqueous solutions with the appropriate letter from (4).docx
Match the following aqueous solutions with the appropriate letter from (4).docxMatch the following aqueous solutions with the appropriate letter from (4).docx
Match the following aqueous solutions with the appropriate letter from (4).docx
 

Recently uploaded

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
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
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
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
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
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
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
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
 
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
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 

Recently uploaded (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
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
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
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
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
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
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
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
 
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
 
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
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 

Mips assembly language Generate the quadruples for the program code fr.docx

  • 1. Mips assembly language Generate the quadruples for the program code fragment and include details. Please see the attached photo below. Solution ; roots.asm segment .text global _roots _roots: enter 0,0 xor EAX,EAX fld qword[EBP+8] ; a fadd ST0 ; 2a fld qword[EBP+8] ; a,2a fld qword[EBP+24] ; c,a,2a fmulp ST1 ; ac,2a fadd ST0 ; 2ac,2a fadd st0 ; 4ac,2a fchs ; -4ac,2a fld qword[EBP+16] ; b,-4ac,2a fld qword[EBP+16] ; b,b,- 4ac,2a fmulp ST1 ; b*b,-4ac,2a faddp ST1 ; b*b-4ac,2a ftst ; cmp (b*b-4ac),0 fstsw AX ; result of test in AX sahf ; store AH in flag reg jb no_real_roots ; jb tests the carry flag fsqrt ; sqrt(b*b- 4ac),2a fld qword[EBP+16] ; b,sqrt(b*b-4ac),2a fchs ; -b,sqrt(b*b-4ac),2a fadd ST1 ; - b+sqrt(b*b-4ac),sqrt(b*b-4ac),2a fdiv ST2 ; -b+sqrt(b*b-4ac)/2a,sqrt(b*b-4ac),2a mov EAX,dword[EBP+32] ; EAX = -b+sqrt(b*b-4ac)/2a fstp qword[EAX] ; Store and pop fld qword[EBP+16] ; b,sqrt(b*b-4ac),2a fchs ; -b,sqrt(b*b-4ac),2a fsubp ST1 ; -b-sqrt(b*b-4ac),2a fdivrp ST1 ; -b-sqrt(b*b-4ac)/2a mov EAX,dword[EBP+36] ; EAX = -b-sqrt(b*b-4ac)/2a fstp qword[EAX] ; Store and pop mov EAX,1 ; 1 means real roots jmp short done no_real_roots: sub EAX,EAX ; 0 means no real roots done: leave ret