subject
Computers and Technology, 27.04.2021 15:10 invocx

Write a MIPS assembly language program that prompts for a user to enter how many floating point numbers to enter, then prompts to enter a series of floating point numbers and reads in numbers and store them in an array, then asks a user how many small numbers to print, and computes and prints them. Consult the green sheet and the chapter 3 for assembly instructions for floating point numbers. Here is one instruction that you might use:
c. lt. s $f2, $f4
bc1t Label1
Here if the value in the register $f2 is less than the value in $f4, it jumps to the Label1. If it should jump when the value in the register $f2 is NOT less than the value in $f4, then it should be:
c. lt. s $f2, $f4
bc1f Label1
To load a single precision floating point number (instead of lw for an integer), you might use:
l. s $f12, 0($t0)
To store a single precision floating point number (instead of sw for an integer), you might use:
s. s $f12, 0($t0)
To assign a constant floating point number (instead of li for an integer), you might use:
li. s $f12, 123.45
To copy a floating point number from one register to another (instead of move for an integer), you might use:
mov. s $f10, $f12
The following shows the syscall numbers needed for this assignment.
System Call System Call System Call
Number Operation Description
2 print_float $v0 = 2, $f12 = float number to be printed
4 print_string $v0 = 4, $a0 = address of beginning of ASCIIZ string
6 read_float $v0 = 6; user types a float number at keyboard; value is stored in $f0
8 read_string $v0 = 8; user types a string at keybd; addr of beginning of string is stored in $a0; len in $a1

C program will ask a user how many floating numbers will be entered,
then read floating point numbers and store them in an array.
Then it asks a user how many smallest numbers to print, then print that many smallest numbers.

void main( )
{
int arraysize = 25;
float array[arraysize];
int i, j, howMany, howManySmall;
float num, temp;
printf("Specify how many numbers should be stored in the array (at most 25):\n");
scanf("%d", &howMany);
//The following loop reads in floating point numbers
//and stores them into the array
i = 0;
while (i < arraysize && i < howMany)
{
printf("Enter a number:\n");
//read an integer from a user input and store it in num
scanf("%f", &num);
array[i] = num;
i++;
}
//Print out each number in the array
printf("The original array contains the following:\n");
i = 0;
while (i < arraysize && i < howMany)
{
printf("%f\n", array[i]);
i++;
}
printf("Specify how many small numbers to print:\n");
scanf("%d", &howManySmall);
int minIndex;
for (i = 0; i < howManySmall && i < arraysize-1 && i < howMany; i++)
{
minIndex = i;
for (j = i+1; j < arraysize && j < howMany; j++)
{
if (array[j] < array[minIndex])
{
minIndex = j;
}
}
temp = array[i];
array[i] = array[minIndex];
array[minIndex] = temp;
printf("The smallest #%d : %f\n", (i+1), array[i]);
}
return;
Here are sample outputs (user input is in bold): -note that you might get some rounding errors
Specify how many numbers should be stored in the array (at most 25):
14
Enter a number:
3.2
Enter a number:
6.43
Enter a number:
3.23
Enter a number:
4.3
Enter a number:
3.24
Enter a number
3.2
Enter a number:
6.5
Enter a number:
8.8
Enter a number:
8.8
Enter a number:
9.9
The original array contains the following:
3.200000
6.430000
3.230000
4.300000
4.300000
-3.240000
-5.400000
3.200000
3.200000
5.100000
6.500000
8.800000
8.800000
9.900000
Specify how many small numbers to print:
The smallest #1 :-5.400000
The smallest #2:-3240000
The smallest #3--3 .230000
The smallest #4 : 3.200000

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 08:30
Based on your knowledge of a good network, describe what you think is a perfect network would be. what kind of information and resources could users share on this network. what would the network administrator do? what kind of communication would be used?
Answers: 1
question
Computers and Technology, 23.06.2019 23:40
4. what is the reason for including the following code snippet in the header file animal.h? #ifndef animal_h #define animal_h class animal { public: animal(); animal(double new_area_hunt); void birth(); void hunt(double new_area_hunt); void death(); double get_area_hunt() const; private: double area_hunt; }; #endif
Answers: 3
question
Computers and Technology, 24.06.2019 01:30
How can you make your column headings stand out?
Answers: 1
question
Computers and Technology, 24.06.2019 13:20
3. ranga ramasesh is the operations manager for a firm that is trying to decide which one of four countries it should research for possible outsourcing providers. the first step is to select a country based on cultural risk factors, which are critical to eventual business success with the provider. ranga has reviewed outsourcing provider directories and found that the four countries in the table that follows have an ample number of providers from which they can choose. to aid in the country selection step, he has enlisted the aid of a cultural expert, john wang, who has provided ratings of the various criteria in the table. the resulting ratings are on a 1 to 10 scale, where 1 is a low risk and 10 is a high risk. john has also determined six criteria weightins: trust, with a weight of 0.3; quality, with 0.2; religious, with 0.1; individualism, with 0.2; time, with 0.1; and uncertainity, with 0.1. using the factor-rating method, which country should ranga select? why? (2 points)
Answers: 3
You know the right answer?
Write a MIPS assembly language program that prompts for a user to enter how many floating point numb...
Questions
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
French, 10.09.2020 14:01
question
French, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
English, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Geography, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
Questions on the website: 13722363