Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assignment Description: Write a MIPS assembly language program that prompts for

ID: 3569434 • Letter: A

Question

Assignment Description:

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. Then the program should display the array content on the console window. Then it should remove any duplicates of numbers, by keeping the first occurrence of each number and making the rest to 0.0, except 0.0 itself. Then it prints out the result array content again. Please see the following C program to see how it should work.

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 equal to the value in $f4, it jumps to the Label1. If it should jump when the value in the register $f2 is NOT equal 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 9 numbers and store them in an array. It prints the content out. Then it removes any duplicate of each number by keeping the first occurrence of it and making the rest to 0.0, (except 0.0 itself). It prints the result array content again. You need to write MIPS assembly code based on the following C code.

-------------------------------------------

void main( )

{

    int arraysize = 9;

    float array[arraysize];

    int i = 0, j = 0;

    float num;

    while (i < arraysize)

    {

        printf("Enter a number: ");

        //read a number from a user input and store it in num

        scanf("%f", &num);

        array[i] = num;

        i++;

    }

    printf("The original array contains the following: ");

    i = 0;

    while (i < arraysize)

      {

        printf("%f ", array[i]);

        i++;

      }

    //remove duplicates

    for (j = 0; j < arraysize; j++)

     {

      if (array[j] != 0.0)

        {

          for (i = j+1; i < arraysize; i++)

           {

            if (array[j] == array[i])

              {

                  array[i] = 0.0;

              }

           }

         }

     }

   

    printf(" The result array contains the following: ");

    i = 0;

    while (i < arraysize)

      {

        printf("%f ", 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.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

The original array contains the following:
3.20000005
6.42999983
-3.23000002
4.30000019
4.30000019
-3.24000001
-5.40000010
3.20000005
3.20000005

The result array contains the following:
3.20000005
6.42999983
-3.23000002
4.30000019
0.00000000
-3.24000001
-5.40000010
0.00000000
0.00000000

--------------------------------------------

What to turn in::

-Submit your assignment11.s file to the file submission site through the Blackboard by the assignment deadline. Make sure that your name and email address are correct in the header block.

Grading Criteria:

____/ 4    Documentation (header and comments)

____/ 1     Indentation (easy to read)

____/ 1      Spacing (easy to read)

____/ 4      Required procedures -- just main for this assignment, and defining required loops

____/ 2     Does it assemble?

____/ 8     Produces correct results?

Total points: 20

Explanation / Answer

only 300 points?..

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote