1

A C++ program to be converted to mips assembly language

#include<iostream>

  using namespace std;
       void redressement(int tab1[], int tab2[], int N){

       int i=0
       while(i<N){
       if(tab1[i]<0) tab2[i]=0;
       else tab2[i]=tab1[i];
       i++;
         }
         }
       void affiche(int tab[], int N){
       int i = 0 ;
       for(i=0; i<N ; i++) cout<<tab[i]<< " ";
       }

      int main(void)
     {
      int tab1[6] = { 20, 40, -6, 90, 2, 10 };
      int tab2[6];
      redressement(tab1,tab2,6);
      affiche(tab2,6);

     return EXIT_SUCCESS;
}
edi9999
  • 19,701
  • 13
  • 88
  • 127
KENNY
  • 11
  • 2
  • Do you have a cross compiler for mips? Related: http://stackoverflow.com/questions/12982857/c-c-to-mips-assembly – Karl Nov 26 '14 at 11:44
  • i'm using MARS, i need the code asap , PLEASE !!! – KENNY Nov 26 '14 at 11:46
  • There is no easy way using MARS. As it sais "MIPS Assembler and Runtime Simulator". It does not support C++. You need a crosscompiler. – Karl Nov 26 '14 at 11:48
  • Your question can currently be summarized as _"Can you do my homework for me?"_, which isn't suitable for StackOverflow. You need to make an effort at solving this yourself. If you run into a more specific problem that you can formulate into a question, then ask about that. – Michael Nov 26 '14 at 11:58
  • Some more tips on what options to use for the GCC: https://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html – Karl Nov 26 '14 at 12:03
  • First step, convert the program to the equivalent C program. This will get you closer to something you can convert to assembly. – D'Nabre Nov 26 '14 at 18:52
  • Duplicate of un-answered [Tweak mips-gcc output to work with MARS](https://stackoverflow.com/q/13052444). Related: an answer on [Is there a way to use gcc to convert C to MIPS?](https://stackoverflow.com/a/63386888) – Peter Cordes Aug 19 '20 at 07:08

0 Answers0