Question: Please explain these problem to me. Thank you! Modify the program in Figure 4.35 on page 176 of the text to input a single one-digit

Please explain these problem to me. Thank you!  Please explain these problem to me. Thank you! Modify the program

Modify the program in Figure 4.35 on page 176 of the text to input a single one-digit integer and output twice that value. The input will be one ASCII character representing a one-digit unsigned integer in base-8. Your program should output the result as two ASCII characters representing a two-digit integer, also in base-8. For example: If the input was '6', the output would be "14". If the input was '3', the output would be "06" (always print the 8's digit, even if it is zero). First, you must input a 1-digit number as an ASCII character and convert it into the internal representation of the appropriate value. Look at the way a "mask" is used to convert an integer into a character for the output in Figure 4.35. Apply a similar technique (removing extra bits instead of adding them) for the input. Next, the number must be doubled: Use addition or shift the bits left. Finally, the result of your calculation must be output as two ASCII characters representing digits. Remember that three bits of base-2 are equal to 1 digit of base-8. Therefore, you need to isolate the rightmost three bits of the result (again, use a mask) and output that value as an ASCII digit, then isolate the next three bits of the sum and do the same thing. You will need to use an arithmetic shift instruction to get the bits which represent the high-order digit into the right three positions of a word in order to output that digit. I strongly recommend that you use the Pep/8 simulator to test your solution. Give your answer in the second form presented for the program in Figure 4.35: the one where instructions are represented in hex (base 16). Include appropriate comments, similar to those given in the text program. An assembled listing from the Pep/8 simulator is also acceptable! Modify the program in Figure 4.35 on page 176 of the text to input a single one-digit integer and output twice that value. The input will be one ASCII character representing a one-digit unsigned integer in base-8. Your program should output the result as two ASCII characters representing a two-digit integer, also in base-8. For example: If the input was '6', the output would be "14". If the input was '3', the output would be "06" (always print the 8's digit, even if it is zero). First, you must input a 1-digit number as an ASCII character and convert it into the internal representation of the appropriate value. Look at the way a "mask" is used to convert an integer into a character for the output in Figure 4.35. Apply a similar technique (removing extra bits instead of adding them) for the input. Next, the number must be doubled: Use addition or shift the bits left. Finally, the result of your calculation must be output as two ASCII characters representing digits. Remember that three bits of base-2 are equal to 1 digit of base-8. Therefore, you need to isolate the rightmost three bits of the result (again, use a mask) and output that value as an ASCII digit, then isolate the next three bits of the sum and do the same thing. You will need to use an arithmetic shift instruction to get the bits which represent the high-order digit into the right three positions of a word in order to output that digit. I strongly recommend that you use the Pep/8 simulator to test your solution. Give your answer in the second form presented for the program in Figure 4.35: the one where instructions are represented in hex (base 16). Include appropriate comments, similar to those given in the text program. An assembled listing from the Pep/8 simulator is also acceptable

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!