Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me with this ASAP? I am unabel to upload my code here it keeps throwing me errors. If you could allow me

Can someone help me with this ASAP? I am unabel to upload my code here it keeps throwing me errors. If you could allow me I can post the code I have so far which somewhat right I just need to fix it or if you can finish it that would work too. ThanksNumber Conversion
Write a program in MIPS assembly language using the MARS simulator that does the following:
Initialize an accumulator (variable or register) to zero.
Display a prompt to the user: "Enter a number: "
Use the system call function to read a string into a buffer. Assume the user will enter no more
than 20 characters.
If the first character in your buffer is the New Line character ('??
'):
A. Go to step 9.
If the first character in your buffer is the minus sign, remember that so you can reverse the sign
of the number.
Convert the number to a decimal integer*, one digit at a time. If there are any characters other
than decimal digits:
A. If it is not a New Line, show an error message and go back to step 2.
a. The error message should look like this: "Error: " followed by the invalid user
input
B. If it is a new line, continue to 7.
Add the decimal number to your accumulator.
Go to step 2.
Print the sum of the numbers, the total number of valid numbers entered, and the total number
of errors.
a. The sum output should look like this: "Sum =" followed by the sum.
b. The total number of valid numbers output should look like this: "Count of valid
numbers = "followed by the total count.
c. The total number of errors output should look like this: "Total number of
errors: " followed by the total error count.
Exit the program.
You must validate the input - your program must not crash. The minus sign character is only valid if is
the first character entered, and is considered invalid if the minus sign is the only character entered (at
least one digit must immediately follow the minus sign).
*The process of conversion works like this: Set an accumulator to 0. Multiply your accumulator by 10,
then add the new digit. You convert an ASCII character to a decimal digit by subtracting the character
'0', as we saw in class. Your program must make sure that what was entered was an actual digit,
between 0 and 9, inclusive. You are done with this process when you encounter a new line character.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Outlook 2023

Authors: James Holler

1st Edition

B0BP9P1VWJ, 979-8367217322

More Books

Students also viewed these Databases questions