SlideShare ist ein Scribd-Unternehmen logo
1 von 2
Convert the following C code to MIPS
. for (i=0; i < n; i++) {
A[i] = A[i] + i;
}
Solution
main()
{
int A[10],i,n;
for (i=0; i < n; i++)
{
A[i] = A[i] + i;
}
}
code in mips i have so far:
main:
@ args = 0, pretend = 0, frame = 48
@ frame_needed = 1, uses_anonymous_args = 0
@ link register save eliminated.
push {r7}
sub sp, sp, #52
add r7, sp, #0
mov r3, #0
str r3, [r7, #44]
b .L2
.L3:
ldr r3, [r7, #44]
lsl r3, r3, #2
add r1, r7, #48
adds r3, r1, r3
ldr r2, [r3, #-48]
ldr r3, [r7, #44]
adds r2, r2, r3
ldr r3, [r7, #44]
lsl r3, r3, #2
add r1, r7, #48
adds r3, r1, r3
str r2, [r3, #-48]
ldr r3, [r7, #44]
add r3, r3, #1
str r3, [r7, #44]
.L2:
ldr r2, [r7, #44]
ldr r3, [r7, #40]
cmp r2, r3
ite ge
movge r3, #0
movlt r3, #1
uxtb r3, r3
cmp r3, #0
bne .L3
mov r3, #0
mov r0, r3
add r7, r7, #52
mov sp, r7
pop {r7}
bx lr

Weitere ähnliche Inhalte

Ähnlich wie Convert C for loop to MIPS assembly

C from hello world to 010101
C from hello world to 010101C from hello world to 010101
C from hello world to 010101Bellaj Badr
 
r2con 2017 r2cLEMENCy
r2con 2017 r2cLEMENCyr2con 2017 r2cLEMENCy
r2con 2017 r2cLEMENCyRay Song
 
Chapter 2 instructions language of the computer
Chapter 2 instructions language of the computerChapter 2 instructions language of the computer
Chapter 2 instructions language of the computerBATMUNHMUNHZAYA
 
04 Functional Programming in Python
04 Functional Programming in Python04 Functional Programming in Python
04 Functional Programming in PythonEbad ullah Qureshi
 
Start from the sample code on the pdf Change struct to clas.pdf
Start from the sample code on the pdf  Change struct to clas.pdfStart from the sample code on the pdf  Change struct to clas.pdf
Start from the sample code on the pdf Change struct to clas.pdfbabitasingh698417
 
Introduction to computer architecture .pptx
Introduction to computer architecture .pptxIntroduction to computer architecture .pptx
Introduction to computer architecture .pptxFatma Sayed Ibrahim
 
MIPS_Programming.pdf
MIPS_Programming.pdfMIPS_Programming.pdf
MIPS_Programming.pdfXxUnnathxX
 
Georgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software securityGeorgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software securityDefconRussia
 
Tema2_ArchitectureMIPS.pptx
Tema2_ArchitectureMIPS.pptxTema2_ArchitectureMIPS.pptx
Tema2_ArchitectureMIPS.pptxgopikahari7
 
Cluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in CCluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in CSteffen Wenz
 
Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use CasesFabrizio Farinacci
 
Lesson 24. Phantom errors
Lesson 24. Phantom errorsLesson 24. Phantom errors
Lesson 24. Phantom errorsPVS-Studio
 
computer science sample papers 2
computer science sample papers 2computer science sample papers 2
computer science sample papers 2Swarup Kumar Boro
 

Ähnlich wie Convert C for loop to MIPS assembly (20)

C from hello world to 010101
C from hello world to 010101C from hello world to 010101
C from hello world to 010101
 
Bp150522
Bp150522Bp150522
Bp150522
 
r2con 2017 r2cLEMENCy
r2con 2017 r2cLEMENCyr2con 2017 r2cLEMENCy
r2con 2017 r2cLEMENCy
 
Csdfsadf
CsdfsadfCsdfsadf
Csdfsadf
 
C
CC
C
 
C
CC
C
 
Chapter 2 instructions language of the computer
Chapter 2 instructions language of the computerChapter 2 instructions language of the computer
Chapter 2 instructions language of the computer
 
04 Functional Programming in Python
04 Functional Programming in Python04 Functional Programming in Python
04 Functional Programming in Python
 
Start from the sample code on the pdf Change struct to clas.pdf
Start from the sample code on the pdf  Change struct to clas.pdfStart from the sample code on the pdf  Change struct to clas.pdf
Start from the sample code on the pdf Change struct to clas.pdf
 
Introduction to computer architecture .pptx
Introduction to computer architecture .pptxIntroduction to computer architecture .pptx
Introduction to computer architecture .pptx
 
20BCE1734.pdf
20BCE1734.pdf20BCE1734.pdf
20BCE1734.pdf
 
MIPS_Programming.pdf
MIPS_Programming.pdfMIPS_Programming.pdf
MIPS_Programming.pdf
 
Georgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software securityGeorgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software security
 
Tema2_ArchitectureMIPS.pptx
Tema2_ArchitectureMIPS.pptxTema2_ArchitectureMIPS.pptx
Tema2_ArchitectureMIPS.pptx
 
Cluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in CCluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in C
 
Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use Cases
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
 
Lesson 24. Phantom errors
Lesson 24. Phantom errorsLesson 24. Phantom errors
Lesson 24. Phantom errors
 
computer science sample papers 2
computer science sample papers 2computer science sample papers 2
computer science sample papers 2
 
C Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.comC Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.com
 

Mehr von mrichard5

A rigid- well-insulated gas cylinder contains N0 moles of an ideal gas.docx
A rigid- well-insulated gas cylinder contains N0 moles of an ideal gas.docxA rigid- well-insulated gas cylinder contains N0 moles of an ideal gas.docx
A rigid- well-insulated gas cylinder contains N0 moles of an ideal gas.docxmrichard5
 
A soil is shaken with water and then allowed to stand- After standing-.docx
A soil is shaken with water and then allowed to stand- After standing-.docxA soil is shaken with water and then allowed to stand- After standing-.docx
A soil is shaken with water and then allowed to stand- After standing-.docxmrichard5
 
a societal right- None of the above- a group right- Both A and B- an i.docx
a societal right- None of the above- a group right- Both A and B- an i.docxa societal right- None of the above- a group right- Both A and B- an i.docx
a societal right- None of the above- a group right- Both A and B- an i.docxmrichard5
 
A simple camera telephoto lens consists of two How far behind the conc.docx
A simple camera telephoto lens consists of two How far behind the conc.docxA simple camera telephoto lens consists of two How far behind the conc.docx
A simple camera telephoto lens consists of two How far behind the conc.docxmrichard5
 
A priniciple purpose of a representation letter from management is to-.docx
A priniciple purpose of a representation letter from management is to-.docxA priniciple purpose of a representation letter from management is to-.docx
A priniciple purpose of a representation letter from management is to-.docxmrichard5
 
A process or task in Linux is represented by a Answer data structure-S.docx
A process or task in Linux is represented by a Answer data structure-S.docxA process or task in Linux is represented by a Answer data structure-S.docx
A process or task in Linux is represented by a Answer data structure-S.docxmrichard5
 
Crystal clear water sports has 14-000 shares of $1 par value common st.docx
Crystal clear water sports has 14-000 shares of $1 par value common st.docxCrystal clear water sports has 14-000 shares of $1 par value common st.docx
Crystal clear water sports has 14-000 shares of $1 par value common st.docxmrichard5
 
Critical thinking question- what structural features (hint- there are.docx
Critical thinking question- what structural features (hint- there are.docxCritical thinking question- what structural features (hint- there are.docx
Critical thinking question- what structural features (hint- there are.docxmrichard5
 
Create an array of size 10 Assign values to the array Print the arra.docx
Create an array of size 10  Assign values to the array  Print the arra.docxCreate an array of size 10  Assign values to the array  Print the arra.docx
Create an array of size 10 Assign values to the array Print the arra.docxmrichard5
 
Create a text file that contains ten person objects where each object.docx
Create a text file that contains ten person objects where each object.docxCreate a text file that contains ten person objects where each object.docx
Create a text file that contains ten person objects where each object.docxmrichard5
 
Create a polynomial function that meets the following conditions- Expl.docx
Create a polynomial function that meets the following conditions- Expl.docxCreate a polynomial function that meets the following conditions- Expl.docx
Create a polynomial function that meets the following conditions- Expl.docxmrichard5
 
Create a method assuming we have a listed list- use linear search in j.docx
Create a method assuming we have a listed list- use linear search in j.docxCreate a method assuming we have a listed list- use linear search in j.docx
Create a method assuming we have a listed list- use linear search in j.docxmrichard5
 
Create a JAVA Program that traverses through an array recursively- rat.docx
Create a JAVA Program that traverses through an array recursively- rat.docxCreate a JAVA Program that traverses through an array recursively- rat.docx
Create a JAVA Program that traverses through an array recursively- rat.docxmrichard5
 
Create a Java Applet that uses two integer (int) variables x and y to.docx
Create a Java Applet that uses two integer (int) variables x and y to.docxCreate a Java Applet that uses two integer (int) variables x and y to.docx
Create a Java Applet that uses two integer (int) variables x and y to.docxmrichard5
 
Create a function called findChar that will return the index of where.docx
Create a function called findChar that will return the index of where.docxCreate a function called findChar that will return the index of where.docx
Create a function called findChar that will return the index of where.docxmrichard5
 
Could someone help me with this Linux system program- Using C language.docx
Could someone help me with this Linux system program- Using C language.docxCould someone help me with this Linux system program- Using C language.docx
Could someone help me with this Linux system program- Using C language.docxmrichard5
 
Contrast the argument that terrorist acts are easy to predict with the.docx
Contrast the argument that terrorist acts are easy to predict with the.docxContrast the argument that terrorist acts are easy to predict with the.docx
Contrast the argument that terrorist acts are easy to predict with the.docxmrichard5
 
contemporary financial management What are the differences between the.docx
contemporary financial management What are the differences between the.docxcontemporary financial management What are the differences between the.docx
contemporary financial management What are the differences between the.docxmrichard5
 
Constants Part A By measurement you determine that sound waves are spr.docx
Constants Part A By measurement you determine that sound waves are spr.docxConstants Part A By measurement you determine that sound waves are spr.docx
Constants Part A By measurement you determine that sound waves are spr.docxmrichard5
 

Mehr von mrichard5 (19)

A rigid- well-insulated gas cylinder contains N0 moles of an ideal gas.docx
A rigid- well-insulated gas cylinder contains N0 moles of an ideal gas.docxA rigid- well-insulated gas cylinder contains N0 moles of an ideal gas.docx
A rigid- well-insulated gas cylinder contains N0 moles of an ideal gas.docx
 
A soil is shaken with water and then allowed to stand- After standing-.docx
A soil is shaken with water and then allowed to stand- After standing-.docxA soil is shaken with water and then allowed to stand- After standing-.docx
A soil is shaken with water and then allowed to stand- After standing-.docx
 
a societal right- None of the above- a group right- Both A and B- an i.docx
a societal right- None of the above- a group right- Both A and B- an i.docxa societal right- None of the above- a group right- Both A and B- an i.docx
a societal right- None of the above- a group right- Both A and B- an i.docx
 
A simple camera telephoto lens consists of two How far behind the conc.docx
A simple camera telephoto lens consists of two How far behind the conc.docxA simple camera telephoto lens consists of two How far behind the conc.docx
A simple camera telephoto lens consists of two How far behind the conc.docx
 
A priniciple purpose of a representation letter from management is to-.docx
A priniciple purpose of a representation letter from management is to-.docxA priniciple purpose of a representation letter from management is to-.docx
A priniciple purpose of a representation letter from management is to-.docx
 
A process or task in Linux is represented by a Answer data structure-S.docx
A process or task in Linux is represented by a Answer data structure-S.docxA process or task in Linux is represented by a Answer data structure-S.docx
A process or task in Linux is represented by a Answer data structure-S.docx
 
Crystal clear water sports has 14-000 shares of $1 par value common st.docx
Crystal clear water sports has 14-000 shares of $1 par value common st.docxCrystal clear water sports has 14-000 shares of $1 par value common st.docx
Crystal clear water sports has 14-000 shares of $1 par value common st.docx
 
Critical thinking question- what structural features (hint- there are.docx
Critical thinking question- what structural features (hint- there are.docxCritical thinking question- what structural features (hint- there are.docx
Critical thinking question- what structural features (hint- there are.docx
 
Create an array of size 10 Assign values to the array Print the arra.docx
Create an array of size 10  Assign values to the array  Print the arra.docxCreate an array of size 10  Assign values to the array  Print the arra.docx
Create an array of size 10 Assign values to the array Print the arra.docx
 
Create a text file that contains ten person objects where each object.docx
Create a text file that contains ten person objects where each object.docxCreate a text file that contains ten person objects where each object.docx
Create a text file that contains ten person objects where each object.docx
 
Create a polynomial function that meets the following conditions- Expl.docx
Create a polynomial function that meets the following conditions- Expl.docxCreate a polynomial function that meets the following conditions- Expl.docx
Create a polynomial function that meets the following conditions- Expl.docx
 
Create a method assuming we have a listed list- use linear search in j.docx
Create a method assuming we have a listed list- use linear search in j.docxCreate a method assuming we have a listed list- use linear search in j.docx
Create a method assuming we have a listed list- use linear search in j.docx
 
Create a JAVA Program that traverses through an array recursively- rat.docx
Create a JAVA Program that traverses through an array recursively- rat.docxCreate a JAVA Program that traverses through an array recursively- rat.docx
Create a JAVA Program that traverses through an array recursively- rat.docx
 
Create a Java Applet that uses two integer (int) variables x and y to.docx
Create a Java Applet that uses two integer (int) variables x and y to.docxCreate a Java Applet that uses two integer (int) variables x and y to.docx
Create a Java Applet that uses two integer (int) variables x and y to.docx
 
Create a function called findChar that will return the index of where.docx
Create a function called findChar that will return the index of where.docxCreate a function called findChar that will return the index of where.docx
Create a function called findChar that will return the index of where.docx
 
Could someone help me with this Linux system program- Using C language.docx
Could someone help me with this Linux system program- Using C language.docxCould someone help me with this Linux system program- Using C language.docx
Could someone help me with this Linux system program- Using C language.docx
 
Contrast the argument that terrorist acts are easy to predict with the.docx
Contrast the argument that terrorist acts are easy to predict with the.docxContrast the argument that terrorist acts are easy to predict with the.docx
Contrast the argument that terrorist acts are easy to predict with the.docx
 
contemporary financial management What are the differences between the.docx
contemporary financial management What are the differences between the.docxcontemporary financial management What are the differences between the.docx
contemporary financial management What are the differences between the.docx
 
Constants Part A By measurement you determine that sound waves are spr.docx
Constants Part A By measurement you determine that sound waves are spr.docxConstants Part A By measurement you determine that sound waves are spr.docx
Constants Part A By measurement you determine that sound waves are spr.docx
 

Kürzlich hochgeladen

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
 
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
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
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
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
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
 
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.pdfAdmir Softic
 
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
 
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
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
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
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 

Kürzlich hochgeladen (20)

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
 
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...
 
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
 
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"
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
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...
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
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
 
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
 
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
 
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
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
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
 
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 ...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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
 

Convert C for loop to MIPS assembly

  • 1. Convert the following C code to MIPS . for (i=0; i < n; i++) { A[i] = A[i] + i; } Solution main() { int A[10],i,n; for (i=0; i < n; i++) { A[i] = A[i] + i; } } code in mips i have so far: main: @ args = 0, pretend = 0, frame = 48 @ frame_needed = 1, uses_anonymous_args = 0 @ link register save eliminated. push {r7} sub sp, sp, #52 add r7, sp, #0 mov r3, #0
  • 2. str r3, [r7, #44] b .L2 .L3: ldr r3, [r7, #44] lsl r3, r3, #2 add r1, r7, #48 adds r3, r1, r3 ldr r2, [r3, #-48] ldr r3, [r7, #44] adds r2, r2, r3 ldr r3, [r7, #44] lsl r3, r3, #2 add r1, r7, #48 adds r3, r1, r3 str r2, [r3, #-48] ldr r3, [r7, #44] add r3, r3, #1 str r3, [r7, #44] .L2: ldr r2, [r7, #44] ldr r3, [r7, #40] cmp r2, r3 ite ge movge r3, #0 movlt r3, #1 uxtb r3, r3 cmp r3, #0 bne .L3 mov r3, #0 mov r0, r3 add r7, r7, #52 mov sp, r7 pop {r7} bx lr