Write a MIPS assembly language program which prompts for a user to enter eight floating point numbers and calls read_float to read in numbers and store them in an array.
$30-250 USD
Terminado
Publicado hace más de 8 años
$30-250 USD
Pagado a la entrega
Write a MIPS assembly language program which prompts for a user to enter eight floating point numbers and calls read_float to read in numbers and store them in an array. Then the program should sort the numbers in the array, and display their sorted array content on the console window.
(I have attached a more detailed project overview)
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)
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 that will ask a user to enter an integer 10 times and store them in an array. The it sorts the content and prints it out.
-------------------------------------------
void main( )
{
int arraysize = 10;
float array[arraysize];
int position, i = 0;
float num, key;
while (i < arraysize)
{
printf("Enter a number:\n");
//read an integer from a user input and store it in num1
scanf("%f", &num);
array[i] = num;
i++;
}
//sort the content of the array
for (i = 1; i 0 && array[position-1] > key)
{
array[position] = array[position-1];
position = position-1;
}
array[position] = key;
}
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
Hi,sir.
I was interested when I saw your project.
I can complete your project.
My skills are C, C++, Academic writing,Matlab & Mathematics, Web scraping,Algorithm.
I can help you very kindly.
Best regards.
Thank you.