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, 25.06.2019 05:10
Assume that two parallel arrays have been declared and initialized: healthoption an array of type char that contains letter codes for different healthcare options and annual cost an array of type int. the i-th element of annual cost indicates the annual cost of the i-th element of healthoption. in addition, there is an char variable, best2.write the code necessary to assign to best2 the health option with the lower annual cost, considering only the first two healthcare options. thus, if the values of healthoption are 'b', 'q', 'w', 'z' and the values of annualcost are 8430, 9400, 7050, 6400 your code would assign 'b' to best2 because 8430 is less than 9400 and is associated with 'b' in the parallel array. (we ignore 'w' and 'z' because we are considering only the first two options.)
Answers: 1
question
Computers and Technology, 25.06.2019 10:30
What is workflow? how do you create your own workflow?
Answers: 1
question
Computers and Technology, 25.06.2019 13:00
Which professional is an example of a person who belongs to the social elite in the united states
Answers: 1
question
Computers and Technology, 25.06.2019 16:30
Need five questions ! question 1 excel is a tool used to a create a spreadsheet b design a brochure c make a presentation d write a letter question 2 a cell on an excel spreadsheet refers to a a type of document view b a page of the workbook c the rectangular box where a column and row intersect d the data in a worksheet question 3 tanya is entering the amount of money she has earned from babysitting onto an excel spreadsheet, but the autocomplete feature is not working. why? a autocomplete must be turned on before every entry. b autocomplete only works with professional spreadsheets. c autocomplete does not recognize types of currency. d autocomplete only works when the first character is text. question 4 which tab has formatting features to change the font style, color, size, and alignment? a file b home c insert d view question 5 brad uses excel to create a weekly schedule. he wants to keep using the same spreadsheet every year. one of his rows is titled "baseball," but the season has ended until next year. what is the most efficient way to modify the spreadsheet, so brad does not see baseball on his schedule but can easily get it back when the season starts again? a add a new comment with the start date of the next season b hide the row and unhide it when the new season begins c highlight the row in a different color to show the season has ended d start a new spreadsheet
Answers: 1
You know the right answer?
Assignment Description:

An array of integers can be assigned to a memory address in the...
Questions