Computers and Technology
Computers and Technology, 02.05.2021 04:00, sara12340

Write a MIPS assembly language program that prompts for a user to enter a series of floating point numbers and calls read_float to read in numbers and store them in an array only if the same number is not stored in the array yet. Then the program should display the array content on the console window. Consult the green sheet and the chapter 3 for assembly instructions for floating point numbers. Here is one instruction that you might use:
c. eq. s $f2, $f4
bc1t Label1
Here if the value in the register $f2 is equals to the value in $f4, it jumps to the Label1. If it should jump when the value in the register $f2 is NOT equals to the value in $f4, then it should be:
c. eq. 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 store in $f0
8 read_string $v0 = 8; user types string at keybd; addr of beginning of string is store in $a0; len in $a1

C program will ask a user to enter numbers and store them in an array
only if the same number is not in the array yet.
Then it prints out the result array content.
You need to write MIPS assembly code based on the following C code.

void main( )
{
int arraysize = 10;
float array[arraysize];
int i, j, alreadyStored;
float num;
i = 0;
while (i < arraysize)
{
printf("Enter a number:\n");
//read an integer from a user input and store it in num1
scanf("%f", &num);
//check if the number is already stored in the array
alreadyStored = 0;
for (j = 0; j < i; j++)
{
if (array[j] == num)
{
alreadyStored = 1;
}
}
//Only if the same number is not in the array yet
if (alreadyStored == 0)
{
array[i] = num;
i++;
}
}
printf("The array contains the following:\n");
i = 0;
while (i < arraysize)
{
printf("%f\n", array[i]);
i++;
}
return;
}
Here are sample outputs (user input is in bold): -- note that you might get some rounding errors
Enter a number:
3
Enter a number:
54.4
Enter a number:
2
Enter a number:
5
Enter a number:
2
Enter a number:
-4
Enter a number:
5
Enter a number:
76
Enter a number:
-23
Enter a number:
43.53
Enter a number:
-43.53
Enter a number:
43.53
Enter a number:
65.43
The array contains the following:
3.00000000
54.40000153
2.00000000
5.00000000
-4.00000000
76.00000000
-23.00000000
43.52999878
-43.52999878
65.43000031

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 12:40, Courtneymorris19
The most complicated four letter word
Answers: 1
image
Computers and Technology, 22.06.2019 19:20, mayaparness
Write a program that prompts the user to input a string. the program then uses the function substr to remove all the vowels from the string. for example, if str = "there", then after removing all the vowels, str = "thr". after removing all the vowels, output the string. your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel.
Answers: 2
image
Computers and Technology, 25.06.2019 09:50, tatilynnsoto17
Part a: data processing given a data file, find the max, min, and average values of columns. also, create an addition column that is based on the other columns. there will be no error checking required for this lab. you are provided with a data file named (surprise! ) data. txt. data is arranged in columns where each item of data is twelve columns wide (so it is easy to extract data items using slicing): name height(m) weight(kg) joe 1.82 72.57 mary 1.60 63.50 dion 1.90 90.71 kayla 1.72 66.31 jose 1.78 70.23 sofia 1.63 65.12 erik 1.98 92.21 sara 1.57 65.77 your task is read the file data. txt and calculate the max, min, and average of the height and weight columns and to add an additional column that has the bmi calculated based on each height and weight. your output will look like this (and needs to be formatted like this). to match the testing on mimir here is the format string: "{: < 12s}{: < 12.2f}{: < 12.2f}{: < 12.2f}"
Answers: 3
image
Computers and Technology, 25.06.2019 15:30, wowihavefun
If a 120 v appliance requires 15 a to operate, what is the resistance of the appliance?
Answers: 1
Do you know the correct answer?
Write a MIPS assembly language program that prompts for a user to enter a series of floating point n...

Questions in other subjects:

Konu
Mathematics, 01.12.2020 02:10
Konu
Mathematics, 01.12.2020 02:10
Konu
History, 01.12.2020 02:10
Konu
Computers and Technology, 01.12.2020 02:10