Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help with explanations plz example 4.35 8 2) Modify program 4.35 on page 176 of the text to input a single one-digit integer and output

Help with explanations plz

image text in transcribed

example 4.35

image text in transcribed

8

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

What is focal length? Explain with a diagram and give an example.

Answered: 1 week ago

Question

What is physics and how does it apply in daily life?

Answered: 1 week ago

Question

4. What will the team agreement contain?

Answered: 1 week ago

Question

What were the issues and solutions proposed by each team?

Answered: 1 week ago