Answered step by step
Verified Expert Solution
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 characters.
If the first character in your buffer is the New Line character
:
A Go to step
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
a The error message should look like this: "Error: followed by the invalid user
input
B If it is a new line, continue to
Add the decimal number to your accumulator.
Go to step
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 Multiply your accumulator by
then add the new digit. You convert an ASCII character to a decimal digit by subtracting the character
as we saw in class. Your program must make sure that what was entered was an actual digit,
between and inclusive. You are done with this process when you encounter a new line character.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started