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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 05:00, 105001964
Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. after the loop terminates, it prints out, on a line by itself and separated by spaces, the sum of all the even integers read, the sum of all the odd integers read, a count of the number of even integers read, and a count of the number of odd integers read, all separated by at least one space. declare any variables that are needed. assume the availability of a variable, stdin, that references a scanner object associated with standard input. that is, stdin = new scanner(system. in); is given.
Answers: 3
image
Computers and Technology, 22.06.2019 07:50, OnlyaBurden
In this lab, you complete a prewritten c++ program for a carpenter who creates personalized house signs. the program is supposed to compute the price of any sign a customer orders, based on the following facts: the charge for all signs is a minimum of $35.00. the first five letters or numbers are included in the minimum charge; there is a $4 charge for each additional character. if the sign is made of oak, add $20.00. no charge is added for pine. black or white characters are included in the minimum charge; there is an additional $15 charge for gold-leaf lettering. instructions ensure the file named housesign. cppis open in the code editor. you need to declare variables for the following, and initialize them where specified: a variable for the cost of the sign initialized to 0.00 (charge). a variable for the number of characters initialized to 8 (numchars). a variable for the color of the characters initialized to "gold" (color). a variable for the wood type initialized to "oak" (woodtype). write the rest of the program using assignment statements and ifstatements as appropriate. the output statements are written for you. execute the program by clicking the run button. your output should be: the charge for this sign is $82. this is the code, // housesign. cpp - this program calculates prices for custom made signs. #include #include using namespace std; int main() { // this is the work done in the housekeeping() function // declare and initialize variables here // charge for this sign // color of characters in sign // number of characters in sign // type of wood // this is the work done in the detailloop() function // write assignment and if statements here // this is the work done in the endofjob() function // output charge for this sign cout < < "the charge for this sign is $" < < charge < < endl; return(0); }
Answers: 1
image
Computers and Technology, 22.06.2019 11:10, 17795
Look at the far left lane in the picture. explain what the red car is doing and what it needs to do to travel safely.
Answers: 2
image
Computers and Technology, 22.06.2019 23:30, Molly05
In my email i got a message it says a quick message and in message details on who its from its says nicole and under nicole is 50e0bf08e5b671@ualwgypg91wa5wl. uzo9kbud3qjwddygd5.vng -
Answers: 1
You know the right answer?
Assignment Description:

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

Questions in other subjects:

Konu
English, 04.07.2021 22:10
Konu
English, 04.07.2021 22:10