Answered You can hire a professional tutor to get the answer.

QUESTION

Introduction 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

Introduction 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 and 1:

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.

 Uses the AsciiToDigit procedure.

 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

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.

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

Allowed Irvine Procedure Calls:

 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

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question