Question: X86 Assembly . Read the user input number and check for valid input. Prompt the user for a number. Check that the input number is

X86 Assembly

. Read the user input number and check for valid input.

  1. Prompt the user for a number.
  2. Check that the input number is within the range of a signed 8-bit integer..

If the input number is larger or smaller than the signed 8-bit range, print an error message to tell the user the range of values, then loop back and re-prompt.

2. Create an array of characters (a text string) that will be used to store all the bits as characters ('1' or '0'), a space character in the middle of the 8 bits, and the null termination character. See the sample output.

3. Convert the number to binary.

  1. Recall from module 1 that to convert from decimal to binary, you keep dividing by 2 to extract one bit at a time
  2. You must use a loop to extract each bit. Don't copy and paste the division code multiple times.
  3. Since the user input is 8-bit, use 8-bit division to do the extraction.
  4. As you find each bit, convert it to its ASCII character: 0 becomes '0' and 1 becomes '1'
  5. Store each character in the array of characters that you defined in step 2.
  6. Accessing an element of an array is similar as in HLL: arr[0] is the first element, arr[3] is the 4th element, etc. The index value 0,1,2.. can be stored in a 32-bit register: arr[ecx] for example, where ecx can be 0,1,2...

4. Call writeString and print the resulting text string to screen. See the sample output.

5. After printing the text string, loop back to prompt the user for another number.

The loop ends when the user enters 0.

When the loop ends, print a "goodbye" message before ending the program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!