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 18:30
Which of the following commands is more recommended while creating a bot?
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
Where can page numbers appear? check all that apply. in the header inside tables in the footer at the bottom of columns at the top of columns
Answers: 1
question
Computers and Technology, 24.06.2019 01:00
The initial tableau of a linear programming problem is given. use the simplex method to solve it. x 1 x 2 x 3 s 1 s 2 z 1 2 4 1 0 0 8 3 4 1 0 1 0 10 minus3 minus12 1 0 0 1 0 the maximum is nothing when x 1equals nothing, x 2equals nothing, x 3equals nothing, s 1equals3, and s 2equals0. (be sure to simplify to lowest terms if necessary.)
Answers: 2
question
Computers and Technology, 24.06.2019 16:00
To fill (copy) a cell across or down, point to the of the cell and drag. top left corner top right corner bottom left corner bottom right corner
Answers: 3
You know the right answer?
Assignment Description:

An array of integers can be assigned to a memory address in the...
Questions
question
English, 16.04.2021 18:10
question
Mathematics, 16.04.2021 18:10
question
Mathematics, 16.04.2021 18:10
Questions on the website: 13722362