SlideShare uma empresa Scribd logo
1 de 1
Baixar para ler offline
Q2. Translate the following C-code snippets to ARMv8 assembly code in two steps. Step-1
translate C code into goto/flattened C; and Step-2 translate the resulted goto/flattened C from
Step-1 to ARM64/ARMv8 assembly code. You must follow these two steps. You must add
comment to each line of assembly code to explain what it does. Hint: how to translate from C to
goto/flattened C, see Princeton University Spring 2020 lecture slides from this link:
https://www.cs.princeton.edu/courses/archive/spring20/cos217/lectures/14_Assembly2.pdf 1)
Branch and If statement. In Step-2 when you translate goto/flattened C to assembly code, you can
assume that C variables a and b have been placed in registers w0 and w1, respectively. inta,b;a=
20;ifab=a+2;a=a2;>=1){} 2) Branch and If-else statement. In Step-2 when you translate
goto/flattened C to assembly code, you can assume that C variables a and b have been placed in
registers w0 and w1, respectively. int a,b; if (a=10 b=a3 else b=a+33) Simple while-loop: sum of all
odd numbers that are less than 50 . In Step-2 when you translate goto/flattened C to assembly
code, you can assume that C variables sum, n, and i have been placed in registers w0,w1, and w2
, respectively. int sum =0,n=50; int i=1; while (i<n){ sum +=1; } i+2; 4) Simple for-loop: sum of
positive numbers that are less than or equal 100. In Step-2 when you translate goto/flattened C to
assembly code, you can assume that C variables sum, n, and i have been placed in registers w0,
w1, and w2, respectively. int sum =0,n=100; int i; for (i=1;i<=n;i++){ sum +=1;

Mais conteúdo relacionado

Semelhante a Q2 Translate the following Ccode snippets to ARMv8 assembl.pdf

C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
AashutoshChhedavi
 

Semelhante a Q2 Translate the following Ccode snippets to ARMv8 assembl.pdf (20)

2.Overview of C language.pptx
2.Overview of C language.pptx2.Overview of C language.pptx
2.Overview of C language.pptx
 
unit 4-II.ppt
unit 4-II.pptunit 4-II.ppt
unit 4-II.ppt
 
ECET 330 Massive Success--snaptutorial.com
ECET 330 Massive Success--snaptutorial.comECET 330 Massive Success--snaptutorial.com
ECET 330 Massive Success--snaptutorial.com
 
Ecet 330 Success Begins / snaptutorial.com
Ecet 330 Success Begins / snaptutorial.comEcet 330 Success Begins / snaptutorial.com
Ecet 330 Success Begins / snaptutorial.com
 
Ecet 330 Enthusiastic Study / snaptutorial.com
Ecet 330 Enthusiastic Study / snaptutorial.comEcet 330 Enthusiastic Study / snaptutorial.com
Ecet 330 Enthusiastic Study / snaptutorial.com
 
ECET 330 Technology levels--snaptutorial.com
ECET 330 Technology levels--snaptutorial.comECET 330 Technology levels--snaptutorial.com
ECET 330 Technology levels--snaptutorial.com
 
Chap-02-01.ppt
Chap-02-01.pptChap-02-01.ppt
Chap-02-01.ppt
 
Chap-02-1.ppt
Chap-02-1.pptChap-02-1.ppt
Chap-02-1.ppt
 
Chap-02-1.ppt
Chap-02-1.pptChap-02-1.ppt
Chap-02-1.ppt
 
Chap-02-1.ppt
Chap-02-1.pptChap-02-1.ppt
Chap-02-1.ppt
 
Chap-02-1.ppt
Chap-02-1.pptChap-02-1.ppt
Chap-02-1.ppt
 
Chap-02-1.ppt
Chap-02-1.pptChap-02-1.ppt
Chap-02-1.ppt
 
Chap 02-1
Chap 02-1Chap 02-1
Chap 02-1
 
C programming-1.pptx
C programming-1.pptxC programming-1.pptx
C programming-1.pptx
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Complete c programming presentation
Complete c programming presentationComplete c programming presentation
Complete c programming presentation
 
Handout#07
Handout#07Handout#07
Handout#07
 
Tutorial-Auto-Code-Generation-for-F2803x-Target.pdf
Tutorial-Auto-Code-Generation-for-F2803x-Target.pdfTutorial-Auto-Code-Generation-for-F2803x-Target.pdf
Tutorial-Auto-Code-Generation-for-F2803x-Target.pdf
 
Electronic devices and circuits.pptx
Electronic devices and circuits.pptxElectronic devices and circuits.pptx
Electronic devices and circuits.pptx
 
C test
C testC test
C test
 

Mais de adyardrpradeep

Q2 ClothsforYou plc is a medium sized UK listed interneton.pdf
Q2 ClothsforYou plc is a medium sized UK listed interneton.pdfQ2 ClothsforYou plc is a medium sized UK listed interneton.pdf
Q2 ClothsforYou plc is a medium sized UK listed interneton.pdf
adyardrpradeep
 

Mais de adyardrpradeep (20)

Q1 Which of the following is NOT considered ossification co.pdf
Q1 Which of the following is NOT considered ossification co.pdfQ1 Which of the following is NOT considered ossification co.pdf
Q1 Which of the following is NOT considered ossification co.pdf
 
Q1 Your goal is to build a model to predict how people will.pdf
Q1 Your goal is to build a model to predict how people will.pdfQ1 Your goal is to build a model to predict how people will.pdf
Q1 Your goal is to build a model to predict how people will.pdf
 
Q24 Conduct a risk analysis and management process for the.pdf
Q24 Conduct a risk analysis and management process for the.pdfQ24 Conduct a risk analysis and management process for the.pdf
Q24 Conduct a risk analysis and management process for the.pdf
 
Q2 Design the pseudocode to print a binary tree At the vis.pdf
Q2 Design the pseudocode to print a binary tree At the vis.pdfQ2 Design the pseudocode to print a binary tree At the vis.pdf
Q2 Design the pseudocode to print a binary tree At the vis.pdf
 
Q2 Let X denote the amount of time for which a book onehou.pdf
Q2 Let X denote the amount of time for which a book onehou.pdfQ2 Let X denote the amount of time for which a book onehou.pdf
Q2 Let X denote the amount of time for which a book onehou.pdf
 
Q2 Given the total cost function Ca+bY with agt00ltb.pdf
Q2 Given the total cost function Ca+bY with agt00ltb.pdfQ2 Given the total cost function Ca+bY with agt00ltb.pdf
Q2 Given the total cost function Ca+bY with agt00ltb.pdf
 
Q2 A sample space S consists of five simple events with the.pdf
Q2 A sample space S consists of five simple events with the.pdfQ2 A sample space S consists of five simple events with the.pdf
Q2 A sample space S consists of five simple events with the.pdf
 
Q2 ClothsforYou plc is a medium sized UK listed interneton.pdf
Q2 ClothsforYou plc is a medium sized UK listed interneton.pdfQ2 ClothsforYou plc is a medium sized UK listed interneton.pdf
Q2 ClothsforYou plc is a medium sized UK listed interneton.pdf
 
Q1 Shale is a sedimentary rock a protolith of slate whic.pdf
Q1 Shale is a sedimentary rock a protolith of slate whic.pdfQ1 Shale is a sedimentary rock a protolith of slate whic.pdf
Q1 Shale is a sedimentary rock a protolith of slate whic.pdf
 
Q2 Mention whether the following instructions are right or.pdf
Q2  Mention whether the following instructions are right or.pdfQ2  Mention whether the following instructions are right or.pdf
Q2 Mention whether the following instructions are right or.pdf
 
Q2 5 marks An educational researcher believes that the me.pdf
Q2 5 marks An educational researcher believes that the me.pdfQ2 5 marks An educational researcher believes that the me.pdf
Q2 5 marks An educational researcher believes that the me.pdf
 
Q1 We read many accounts this week of what emerging indepen.pdf
Q1 We read many accounts this week of what emerging indepen.pdfQ1 We read many accounts this week of what emerging indepen.pdf
Q1 We read many accounts this week of what emerging indepen.pdf
 
Q1Unaudited information about significant events and uncer.pdf
Q1Unaudited information about significant events and uncer.pdfQ1Unaudited information about significant events and uncer.pdf
Q1Unaudited information about significant events and uncer.pdf
 
Q1413 What is the structure in coordinates J25 and J10 .pdf
Q1413 What is the structure in coordinates J25 and J10 .pdfQ1413 What is the structure in coordinates J25 and J10 .pdf
Q1413 What is the structure in coordinates J25 and J10 .pdf
 
q10 Euromarket investment and fund raising A USbased mult.pdf
q10 Euromarket investment and fund raising A USbased mult.pdfq10 Euromarket investment and fund raising A USbased mult.pdf
q10 Euromarket investment and fund raising A USbased mult.pdf
 
Q10 What is the value of the variable message in the foll.pdf
Q10 What is the value of the variable message in the foll.pdfQ10 What is the value of the variable message in the foll.pdf
Q10 What is the value of the variable message in the foll.pdf
 
Q1 Write a python function that gets a list as an input an.pdf
Q1 Write a python function that gets a list as an input an.pdfQ1 Write a python function that gets a list as an input an.pdf
Q1 Write a python function that gets a list as an input an.pdf
 
Q10 Calculate return on capital when earnings before interes.pdf
Q10 Calculate return on capital when earnings before interes.pdfQ10 Calculate return on capital when earnings before interes.pdf
Q10 Calculate return on capital when earnings before interes.pdf
 
Q1 Write the genotype of an individual who is homozygous re.pdf
Q1 Write the genotype of an individual who is homozygous re.pdfQ1 Write the genotype of an individual who is homozygous re.pdf
Q1 Write the genotype of an individual who is homozygous re.pdf
 
Q1 Which of the following statements is true about perfectl.pdf
Q1 Which of the following statements is true about perfectl.pdfQ1 Which of the following statements is true about perfectl.pdf
Q1 Which of the following statements is true about perfectl.pdf
 

Último

Último (20)

COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
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
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
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
 
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
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
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
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
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
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.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)
 

Q2 Translate the following Ccode snippets to ARMv8 assembl.pdf

  • 1. Q2. Translate the following C-code snippets to ARMv8 assembly code in two steps. Step-1 translate C code into goto/flattened C; and Step-2 translate the resulted goto/flattened C from Step-1 to ARM64/ARMv8 assembly code. You must follow these two steps. You must add comment to each line of assembly code to explain what it does. Hint: how to translate from C to goto/flattened C, see Princeton University Spring 2020 lecture slides from this link: https://www.cs.princeton.edu/courses/archive/spring20/cos217/lectures/14_Assembly2.pdf 1) Branch and If statement. In Step-2 when you translate goto/flattened C to assembly code, you can assume that C variables a and b have been placed in registers w0 and w1, respectively. inta,b;a= 20;ifab=a+2;a=a2;>=1){} 2) Branch and If-else statement. In Step-2 when you translate goto/flattened C to assembly code, you can assume that C variables a and b have been placed in registers w0 and w1, respectively. int a,b; if (a=10 b=a3 else b=a+33) Simple while-loop: sum of all odd numbers that are less than 50 . In Step-2 when you translate goto/flattened C to assembly code, you can assume that C variables sum, n, and i have been placed in registers w0,w1, and w2 , respectively. int sum =0,n=50; int i=1; while (i<n){ sum +=1; } i+2; 4) Simple for-loop: sum of positive numbers that are less than or equal 100. In Step-2 when you translate goto/flattened C to assembly code, you can assume that C variables sum, n, and i have been placed in registers w0, w1, and w2, respectively. int sum =0,n=100; int i; for (i=1;i<=n;i++){ sum +=1;