the Text book asks you to input a number, and it will then sum the numbers from 1 to that number. The Prompt asks you to input a number, not necessarily an integer. The program will abort if a floating point number is entered. Your project, is to “fix” the program and allow for a floating point number to be entered. The program will NOT run, so your task is to convert the floating point number to an integer. If a floating point number is entered, truncate the number and use that integer to run the program. Also, you must inform the user that they entered a floating point and it was truncated, output to the user, the floating point they entered and the integer you used.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

the Text book asks you to input a number, and it will then sum the numbers from 1 to that number. The Prompt asks you to input a number, not necessarily an integer. The program will abort if a floating point number is entered.

Your project, is to “fix” the program and allow for a floating point number to be entered. The program will NOT run, so your task is to convert the floating point number to an integer.

If a floating point number is entered, truncate the number and use that integer to run the program. Also, you must inform the user that they entered a floating point and it was truncated, output to the user, the floating point they entered and the integer you used.

Note: You must only use Shift, rotate to manipulate the bits, no conversion instructions.

The following are some pointers as to what needs to be done.

  1. The program reads an integer, that must be changed to read a floating point.
  2. You will need to move that number into a floating point register and then that number must be copied into an integer register.
  3. You will need to extract the exponent from the integer register and stored in another register.
  4. You will need to insert the Implied bit. I would suggest, zero out the exponent part by shifting left 9 then shifting right 9. Then add 8388608 (2^23) to the number.
  5. You will need to extract the fractional portion of the of the number. You will need the exponent to determine the shift. You only need to test to see that this is NOT EQUAL to 0 (if it is we have an integer)
  6. Extract the Integer. You may want to “Rotate” the bits to the left.

You may want to use the following Assembler instructions in your code:

srl, add, sll, rol, sub, srlv and sllv

PLEASE DO NOT USE CONVERSION INSTRUCTIONS.

### MIPS Assembly Language Program: Summing Integers from 1 to N

This program in MIPS assembly language computes the sum of integers from 1 to a user-inputted number \( N \). Here's a breakdown of the program components and flow:

#### Data Section

- **prompt**: Asks the user to input a value for \( N \).
- **result**: Displays a message indicating the sum of integers from 1 to \( N \).
- **bye**: A farewell message displayed at the end of the program.

#### Text Section

The text section contains the main logic of the program.

1. **Prompting the User:**
   - Uses syscall for printing the prompt message asking for \( N \).
   - Reads the user input into register `$v0`.

2. **Checking Input:**
   - If \( N \) is less than or equal to zero, the program branches to the end.
   - Sets register `$t0` to zero for holding the sum.

3. **Loop for Calculation:**
   - Adds the current \( N \) to the sum stored in `$t0`.
   - Decreases \( N \) by 1.
   - Continues the loop until \( N \) becomes zero.

4. **Displaying Result:**
   - Prints the message about the sum.
   - Displays the sum from `$t0`.

5. **End Routine:**
   - Prints the farewell message.
   - Program terminates and returns control to the system.

This program illustrates loop control structures, basic I/O operations, and arithmetic operations in MIPS assembly language.
Transcribed Image Text:### MIPS Assembly Language Program: Summing Integers from 1 to N This program in MIPS assembly language computes the sum of integers from 1 to a user-inputted number \( N \). Here's a breakdown of the program components and flow: #### Data Section - **prompt**: Asks the user to input a value for \( N \). - **result**: Displays a message indicating the sum of integers from 1 to \( N \). - **bye**: A farewell message displayed at the end of the program. #### Text Section The text section contains the main logic of the program. 1. **Prompting the User:** - Uses syscall for printing the prompt message asking for \( N \). - Reads the user input into register `$v0`. 2. **Checking Input:** - If \( N \) is less than or equal to zero, the program branches to the end. - Sets register `$t0` to zero for holding the sum. 3. **Loop for Calculation:** - Adds the current \( N \) to the sum stored in `$t0`. - Decreases \( N \) by 1. - Continues the loop until \( N \) becomes zero. 4. **Displaying Result:** - Prints the message about the sum. - Displays the sum from `$t0`. 5. **End Routine:** - Prints the farewell message. - Program terminates and returns control to the system. This program illustrates loop control structures, basic I/O operations, and arithmetic operations in MIPS assembly language.
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY