convert the c++ code to MIPS assembly language ---------------------------------
ID: 3704035 • Letter: C
Question
convert the c++ code to MIPS assembly language
--------------------------------------------------------------------------------
#include <iostream>
using namespace std;
int replace(int,int,int,int[]);
int main() {
int a[5]; //declare an array
a[0]=2; //array int
a[1]=3;
a[2]=4;
a[3]=4;
a[4]=5;
cout << a[0] << endl; //show initial values
replace(4,10,5,a); //replace all instances of "4" in the
// array with "10"
//array length is 5, and passing array a
for(int i=0;i<5;i++)
cout << a[i] << " "; //show new values
cout<<endl;
}
int replace (int existing, int newitem, int size, int a[])
{
int i;
for (i=0; i < size; i++)
{
if (a[i]==existing)
a[i] = newitem;
}
return 0;
}
Explanation / Answer
//C++ Code in MIPS language
//As code is large ,i have pasted in file and attaching it to drive please check it.
https://drive.google.com/file/d/1bVrDBqFJfu1xSjH2nmrk9DCRkvMbT0fb/view?usp=sharing.
If you face any problem in accessing file ,please comment ,i will review the file.
PS:If you want C++ code to convert into MIPS assembly language,please use https://godbolt.org/
PS:If you like the answer,please like or upvote.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.