Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Objective The purpose of this assignment is to illustrate how the . FILL pseudo - op performs the task of translating textual decimal numbers (
Objective
The purpose of this assignment is to illustrate how the FILL pseudoop performs the task of translating textual decimal numbers such as the string into actual numbers ie five thousand three hundred and ninety two, represented of course as a bit two's complement binary value
High Level Description
Prompt the user to enter a signed multidigit decimal number max digits from the keyboard. Convert the string of decimal numeric digits into the corresponding bit two's complement number, stored in Rx ie one of the registers: you will be told which register at the start of the provided starter code
The range of acceptable values is ; the absence of a sign means the number is positive ie the first character entered by the user may be or a numeric digit and nothing else.
Your Tasks
Your program can be broken down into the following tasks: Read in the initial character.
If it is a make the final result negative by setting a "flag" so if the "negative" flag is set, take the s complement of Rx at the end
If it is it can be ignored;
If it is a numeric digit, then the number is not negative, and the input is just the first numeric digit of
the number.
In all three cases, you can then proceed to accept any remaining digits see item
If the initial character is a newline, the program can just terminate without any output.
Any other initial character must be treated as an error see below
Convert the string of numeric digits input by the user into the binary number they represent see examples below To do this, you can follow this algorithm:
Initialize Rx and any other registers as needed to DO NOT do this by LD'ing from memory! There is a much simpler & faster way remember the "TIP" in your lab notes!
Convert each digit from ascii code to binary number as it is typed in and add it to Rx;
as each subsequent digit is entered, multiply Rx by # and repeat
go back to lab & assn to recall how to multiply!
Stop when you detect the newline character
xA or when you reach input digits:
For example, if the user types then Rx will contain # b
If the user then types making the string now read then Rx will contain x # # b
If the user then types making the string read then Rx will contain # x # # b
You must also perform input character validation with this assignment ie reject any nonnumeric input character. That is if the user enters g on detecting the nonnumeric g your program should output an error, discard all input, and start over with the initial prompt see sample output
You must also count the number of characters entered once it gets to you should stop accepting new characters, and issue a newline in this case, do not wait for the user to hit Enter
However, you do not have to detect overflow in this assignment we will only test your code with inputs in the range
Expected Sample output
Output
Prompt
"Input a positive or negative decimal number max digits followed by ENTER
Error Message
"ERROR! invalid input
Example
If the user enters your program should read the and end up with the value bwhich is the two's complement representation of the number # or xCE in the specified register.
If the users enters your program should read the and end up with the value # xC b in the specified register.
WARNING: In the following examples, the final result is shown in R which may NOT be the one you will use. You will store your result in the register specified in the header in your starter code!!
Make sure you get this right, or the grader will not work, and you will get
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