subject

Assignment Description:

An array of integers can be assigned to a memory address in the .data section of a MIPS assembly language program as show below. Here the length of the array is stored first, and then the elements of the array numbers next. You are given the following C program that will ask a user to enter one integer and it will filter all integers in the array into the ones that are less than or equals to the entered integer and the ones that are greater. Implement a MIPS assembly language program to perform the functionality of the following C program and print the updated array content, by listing each integer in it.
For instance, if a user enters 5, then the output will be the following:
-42
3
-6
-18
-27
-28
11
45
12
24
35
14

i. e., the number that are less than 5,
(-42, 3, -6, -18, -27, -28) are swapped so that they are located towards the beginning of the array,
and the number that are greater than 5,
(11, 45, 12, 24, 35, 14) are located towards the end of the array.
If your program causes an infinite loop, press Control and 'C' keys at the same time to stop it. Name your source code file assignment5.s.

.data
numbers_len: .word 12
numbers: .word -42, 11, 24, 3, -6, 14, -18, 45, 12, -27, 35, -28

The following shows how it looks like in a C program:

void main()
{
int numbers[12] = {-42, 11, 24, 3, -6, 14, -18, 45, 12, -27, 35, -28};

int num1, num2;
int i = -1;
int j;

printf("Enter an integer:\n");

//read an integer from a user input and store it in num1
scanf("%d", &num1);

for (j = 0; j < 12; j = j+1)
{
if (numbers[j] <= num1)
{
i = i + 1;
num2 = numbers[i];
numbers[i] = numbers[j];
numbers[j] = num2;
}
}

for (j = 0; j < 12; j = j+1)
{
printf("%d\n", numbers[j]);
}

return;
}

The following is a sample output (user input is in bold):

Enter an integer:
5
-42
3
-6
-18
-27
-28
11
45
12
24
35
14



The following is another sample output:



Enter an integer:
-20
-42
-27
-28
3
-6
14
-18
45
12
11
35
24

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:30
This graph compares the total cost of attending educational institutions in texas. the graph demonstrates that the cost at private and public technical schools greatly varies.
Answers: 2
question
Computers and Technology, 23.06.2019 00:00
Donna and her team of five have invented a new gadget for the science exhibition in their college. which intellectual property right will protect their invention?
Answers: 1
question
Computers and Technology, 23.06.2019 03:30
Hashtags serve to identify the topic of a given tweet true false
Answers: 2
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 3
You know the right answer?
Assignment Description:

An array of integers can be assigned to a memory address in the...
Questions
question
Mathematics, 30.06.2019 05:00
Questions on the website: 13722362