Write a MIPS assembly language program that prompts for a userto enter how many floating point numbers to enter, then prompts toenter a series of floating point numbers and reads in numbers andstore them in an array, then prints the original content of thearray.
Based on this C program
Sample output
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 prints the original content of the array. Then it should check if the array contains any duplicate numbers in it, and if so, set them to zero (0.0) except the their last occurrence towards the end of the array. Then it should print the result array content. 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 $12, $14 bc1t Label1 Here if the value in the register $12 is less than the value in $14, it jumps to the Label1. If it should jump when the value in the register Sf2 is NOT less than the value in $14, then it should be: c.It.s $12, $f4 bc1f Label1 To load a single precision floating point number (instead of lw for an integer), you might use: I.s $f12, 0(Sto) To store a single precision floating point number (instead of sw for an integer), you might use: S.s $112, 0($to) 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 $110, $f12 The following shows the syscall numbers needed for this assignment. System Call Number System Call Operation System Call Description print_float print_string read_float read_string $v0 = 2, Sf12 = float number to be printed $v0 = 4, $a0 = address of beginning of ASCIIZ string $v0 = 6; user types a float number at keyboard; value is stored in $fo $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.C program will ask a user how many floating numbers will be void main() int arraysize = 25; float array(arraysize]; int i, j, howMany; float num; 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 lland stores them into the array i = 0; while (i < arraysize && i < howMany) printf(“Enter a number: n”); Ilread 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(“%fn”, array[i]); i++; if (howMany > arraysize) howMany = arraysize; l/check each element in the array from the end //to see if there is another number that is same. //In that case, set it to 0. for (i = howMany-1; i >= 0; i–) for (j = -1; j >= 0; j–) if ((array[i] – array[i]) <0.0001 && (array[i] – array[i]) >-0.0001) array[i] = 0.0; //Print the result array content, //it should not contain a same number twice other than zero. printf(“The result array contains the following:n”); i = 0; while (i < arraysize && i< howMany) printf(“%fn”, array[i]); i++; return; 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: 4.3 Enter a number: -3.24 Enter a number: -5.4 Enter a number: 3.2 Enter a number: 3.2 Enter a number: 5.1 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 The result array contains the following: 0.000000 6.430000 -3.230000 0.000000 4.300000 -3.240000 -5.400000 0.000000 3.200000 5.100000 6.500000 0.000000 8.800000 9.900000 Show transcribed image text 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 prints the original content of the array. Then it should check if the array contains any duplicate numbers in it, and if so, set them to zero (0.0) except the their last occurrence towards the end of the array. Then it should print the result array content. 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 $12, $14 bc1t Label1 Here if the value in the register $12 is less than the value in $14, it jumps to the Label1. If it should jump when the value in the register Sf2 is NOT less than the value in $14, then it should be: c.It.s $12, $f4 bc1f Label1 To load a single precision floating point number (instead of lw for an integer), you might use: I.s $f12, 0(Sto) To store a single precision floating point number (instead of sw for an integer), you might use: S.s $112, 0($to) 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 $110, $f12 The following shows the syscall numbers needed for this assignment. System Call Number System Call Operation System Call Description print_float print_string read_float read_string $v0 = 2, Sf12 = float number to be printed $v0 = 4, $a0 = address of beginning of ASCIIZ string $v0 = 6; user types a float number at keyboard; value is stored in $fo $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.C program will ask a user how many floating numbers will be void main() int arraysize = 25; float array(arraysize]; int i, j, howMany; float num; 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 lland stores them into the array i = 0; while (i
Expert Answer
Answer to Write a MIPS assembly language program that prompts for a user to enter how many floating point numbers to enter, then p…