Create a program that allows a user to select a number base

Q For this assignment you will create a program that allows a user to select a number base (in the range of 2 to 16, inclusive), enter digits for the number base, validate each digit as it is entered, and display the resulting value in base 2, 8, 10 and 16.

 

Requirements

Create a program that:

 Has six user-defined procedures (UDPs):

 o IsLegal – this UDP shall:

 Accept an ASCII value in one register.

 Accept a number base value in another register.

 Determines whether the ASCII value is valid for the base.

 Use the AsciiToDigit procedure

 Return 1 if the value is valid.

 Return 0 if the value is not valid.

 o AsciiToDigit – this UDP shall:

 Accept an ASCII character value in a register.

 Returns the numeric value related to the ASCII character value. For example, if

 ‘A’ (41h) or ‘a’ (61h) is passed in, then this procedure would return 10d.

 Return -1 if the ASCII character is not valid.

 o DigitToAscii – this UDP shall:

 Accept a numeric value in a register.

 Returns the ASCII character value related to the numeric value. For example, if

 15d is passed in, then this procedure would return ‘F’ or ‘f’ (you must choose one

 case for letters).

 Return -1 if the numeric value is not valid.

 o WriteInteger – this UDP shall:

 Accept a number in the EAX register.

 Accept a number base value in the BL register.

 Display the number in its base. For example, if 5 and 2 were passed in, this UDP

 would display 101.

 Use the DigitToAscii procedure.

 Not display leading zeroes.

 o ReadInteger – this UDP shall:

 Accept a number base in the BL register.

 Read characters from the keyboard one character at a time until the user presses

 the Enter key.

  The valid characters are ‘0’ – ‘9’, ‘a’ – ‘f’ and ‘A’ – ‘F’.

 Validate each character, as it is entered, to ensure it is a valid character for the

 number base. For example, entry of ‘G’ for base 7 is invalid, but ‘6’ would be

 valid.

   If a character is valid, display it on the screen.

   If a character is invalid, then do not display it.

  Maintain a running final value as each character is entered.

   For example, if a user chose base 7 and entered the digits 2, 6, 7, A and1:

  o The 7 and A would be ignored leaving 2617.

  o Your running value would consist of calculating the decimal

  value of (2 * 72) + (6 * 71) + (1 * 70) = 141.

 Not use an array.

 Return the result in the EAX register.

 Return 0 if no valid characters were entered.

 o DisplayIntegers – this UDP shall:

 Accept a number in the EAX register.

 Use the WriteInteger procedure to display number in its Base 2, Base 8, Base 10

 and Base 16 equivalents.

 Performs the following tasks in the main procedure:

 o Prompts the user for a number base value.

 o Uses the ReadInteger procedure to get the base value from the user.

 If the ReadInteger procedure call results in 0 then you will exit the program.

 If the ReadInteger procedure call results in a value outside of the range of 2-16,

 then display an error message and prompt the user again.

 o Prompts the user for a number.

 o Uses the ReadInteger procedure to get the number from the user.

 o Uses the WriteInteger procedure to display the user-entered number in its Base 2, Base 8,

 Base 10 and Base 16 equivalents.

 o Allows the user to enter another base/number combination.

 Is formatted and commented as required by the CS370 Coding and Documentation Standards.

 Does not use the .IF, .REPEAT, or .WHILE directives of MASM.

 

Allowed Irvine Procedure Calls:

 Crlf

 ReadChar

 WriteChar

 WriteString

 

Sample Program Input and Output:

Enter base value (2 thru 16 or 0 to exit): 5

Enter a number in your chosen base: 1234

Base 2: 11000010

Base 8: 302

Base 10: 194

Base 16: C2

Enter base value (2 thru 16 or 0 to exit): 7

Enter a number in your chosen base: 1234

Base 2: 111010010

Base 8: 722

Base 10: 466

Base 16: 1D2

Enter base value (2 thru 16 or 0 to exit): 10

Enter a number in your chosen base: 1234

Base 2: 10011010010

Base 8: 2322

Base 10: 1234

Base 16: 4D2

Enter base value (2 thru 16 or 0 to exit): 16

Enter a number in your chosen base: 123abc

Base 2: 100100011101010111100

Base 8: 4435274

Base 10: 1194684

Base 16: 123ABC

Enter base value (2 thru 16 or 0 to exit): 0

Press any key to continue . .

 

 

Calculate Your Essay Price
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more