Please answer fully and in MIPS assembly language Implement

Please answer fully and in MIPS assembly language.

Implement a MIPS assembly program that processes two integer arrays of size 20: Raw and Fresh. The Raw array is initialized with the values {2, 17, 28, 20, 6, 51, 20, 48, 12, 54, 3, 31, 15, 22, 46, 72, 41, 39, 30, 55}. The values for Fresh array will be read in (add proper prompt for reading data.) All elements of Fresh will be stored in memory. The program will output (i.e. display) the sum of two largest integers and the sum of two smallest integers of Raw and store the sum of two largest integers and the sum of two smallest integers of Fresh in memory locations right after where the last element of Fresh is stored. Test the program once and enter the Fresh array\'s data of your choice. Write an efficient algorithm to perform the following tasks: Create an array A of size 20, where all the array elements are initialized to 4. For every element in the array, if its index i is even, perform A[i] = A [i] - i; If its index i is odd, perform A[i] = A[i] + 2 * i. Swap the elements A[i] and A[19 - i], such that, i.e. A[0] with A[19], A[1] with A[18], A[2] with A[17], ... Print out the resulting array. Count how many cycles needed to execute your program and write it down in readme.txt

Solution

problem -2:

initializing an array data like this :

2-

#include <stdio.h>

void oneWay(void);

void anotherWay(void);

int main(void) {

   printf(\"\ oneWay:\ \");

   oneWay();

   printf(\"\ antherWay:\ \");

   anotherWay();

}

/*Array initialized with aggregate */

void oneWay(void) {

   int vect[10] = {1,2,3,4,5,6,7,8,9,0};

   int i;

   for (i=0; i<10; i++){

       printf(\"i = %2d vect[i] = %2d\ \", i, vect[i]);

   }

}

/*Array initialized with loop */

void anotherWay(void) {

   int vect[10];

   int i;

   for (i=0; i<10; i++)

        vect[i] = i+1;

   for (i=0; i<10; i++)

        printf(\"i = %2d vect[i] = %2d\ \", i, vect[i]);

}

/* The output of this program is

   oneWay:

   i = 0 vect[i] = 1

   i = 1 vect[i] = 2

   i = 2 vect[i] = 3

   i = 3 vect[i] = 4

   i = 4 vect[i] = 5

   i = 5 vect[i] = 6

   i = 6 vect[i] = 7

   i = 7 vect[i] = 8

   i = 8 vect[i] = 9

   i = 9 vect[i] = 0

   antherWay:

   i = 0 vect[i] = 1

   i = 1 vect[i] = 2

   i = 2 vect[i] = 3

   i = 3 vect[i] = 4

   i = 4 vect[i] = 5

   i = 5 vect[i] = 6

   i = 6 vect[i] = 7

   i = 7 vect[i] = 8

   i = 8 vect[i] = 9

   i = 9 vect[i] = 10

#include <stdio.h>

void intSwap(int *x, int *y);

int getIntArray(int a[], int nmax, int sentinel);

void printIntArray(int a[], int n);

void reverseIntArray(int a[], int n);

int main(void) {

   int x[10];

   int hmny;

   hmny = getIntArray(x, 10, 0);

   printf(\"The array was: \ \");

   printIntArray(x,hmny);

   reverseIntArray(x,hmny);

   printf(\"after reverse it is:\ \");

   printIntArray(x,hmny);

}

void intSwap(int *x, int *y)

/* It swaps the content of x and y */

{

   int temp = *x;

   *x = *y;

   *y = temp;

}

/* n is the number of elements in the array a.

* These values are printed out, five per line. */

void printIntArray(int a[], int n){

   int i;

   for (i=0; i<n; ){

     printf(\"\\t%d \", a[i++]);

     if (i%5==0)

       printf(\"\ \");

   }

   printf(\"\ \");

}

/* It reads up to nmax integers and stores then in a; sentinel

* terminates input. */

int getIntArray(int a[], int nmax, int sentinel)

{

   int n = 0;

   int temp;

   do {

     printf(\"Enter integer [%d to terminate] : \", sentinel);

     scanf(\"%d\", &temp);

     if (temp==sentinel) break;

     if (n==nmax)

       printf(\"array is full\ \");

     else

     a[n++] = temp;

   }while (1);

   return n;

}

/* It reverse the order of the first n elements of array */

void reverseIntArray(int a[], int n)

{

   int i;

   for(i=0;i<n/2;i++){

     intSwap(&a[i],&a[n-i-1]);

   }

}

Please answer fully and in MIPS assembly language. Implement a MIPS assembly program that processes two integer arrays of size 20: Raw and Fresh. The Raw array
Please answer fully and in MIPS assembly language. Implement a MIPS assembly program that processes two integer arrays of size 20: Raw and Fresh. The Raw array
Please answer fully and in MIPS assembly language. Implement a MIPS assembly program that processes two integer arrays of size 20: Raw and Fresh. The Raw array
Please answer fully and in MIPS assembly language. Implement a MIPS assembly program that processes two integer arrays of size 20: Raw and Fresh. The Raw array

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site