Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help plz, with explanbations thank you example 4.35 8 2) Modify program 4.35 on page 176 of the text to input a single one-digit integer

Help plz, with explanbations thank youimage text in transcribed example 4.35

8image text in transcribed

2) Modify program 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 ASCll 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 "I 4". If the input was "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 integer value. Look at the way a "mask" is used to convert an integer into a character for the output in Program 4.35. Apply a similar technique for the input. Second, 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 ASClII 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 which represent the high-order digit into the right three positions of a word in order to output digit. the bits I strongly recommend that you use the Pep/8 simulator to test your solution. 2) Modify program 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 ASCll 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 "I 4". If the input was "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 integer value. Look at the way a "mask" is used to convert an integer into a character for the output in Program 4.35. Apply a similar technique for the input. Second, 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 ASClII 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 which represent the high-order digit into the right three positions of a word in order to output digit. the bits I strongly recommend that you use the Pep/8 simulator to test your solution

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

Students also viewed these Databases questions

Question

What is the principle of thermodynamics? Explain with examples

Answered: 1 week ago