Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CS61 Homework 3

READING: Chapter 2 (complete)

Read ahead for Week 3: Chapter 3, sections 3.1 through 3.3

HOMEWORK SET (11 questions): Complete the following exercises.

MUST work on top of the copy of the Google doc that is provided and be submitted as a PDF file

MUST be created electronically

● Use any word processor for the text; create any diagrams in a drawing canvas or as separate PNG or jpg images embedded in your document; save/print the final document to PDF.

MUST have your name and username (NetID) at the top.

Students are allowed (and encouraged!) to work on lecture homework together. However, each student must turn in their assignments individually. Please don't copy/turn in someone else's work.

Grading:

For the most part, grading is binary - each question will be awarded 0 or 1 point. If you show even a little work so we can see that you have some idea of what you were doing, you will get the point, otherwise, you will not get the point even if your answer is correct. If we see that any answer is copied from any outside source, you get 0 for the entire homework. All homework will be weighted equally (even if, for example, some will be graded out of 20, some out of 5, etc.); collectively, they will count for 10% of the total course grade.

Question 1: (2.26 textbook page 52)

You wish to express −64 as a 2’s complement number.

a. How many bits do you need (the minimum number)? Why?

b. With this number of bits, what is the largest positive number you can represent? (Please answer both decimal and binary) Why?

c. With this number of bits, what is the largest unsigned number you can represent? (Please answer both decimal and binary)Why?

Question 2 (2.30 textbook page 52)

Compute the following. Write your results in binary. Show your work.

a. 01010111 AND 11010111

b. 101 AND 110

c. 11100000 AND 10110100

d. 00011111 AND 10110100

e. (0011 AND 0110) AND 1101 f. 0011 AND (0110 AND 1101)

Question 3 (2.33 textbook page 53)

Compute the following. Write your results in binary. Show your work.

a. 01010111 OR 11010111

b. 101 OR 110

c. 11100000 OR 10110100

d. 00011111 OR 10110100

e. (0101 OR 1100) OR 1101

f. 0101 OR (1100 OR 1101)

Question 4 (2.34 textbook page 53)

Compute the following:

a. NOT(1011) OR NOT(1100)

b. NOT(1000 AND (1100 OR 0101))

c. NOT(NOT(1101))

d. (0110 OR 0000) AND 1111

Question 5 (2.35 textbook page 53)

In Example 2.11 (page 43), what are the masks used for?

Suppose we have eight machines that we want to monitor with respect to their availability. We can keep track of them with an eight-bit BUSYNESS bit vector, where a bit is 1 if the unit is free and O if the unit is busy. The bits are labeled, from right to left, from 0 to 7.

The BUSYNESS bit vector 11000010 corresponds to the situation where only units 7, 6, and 1 are free and therefore available for work assignment.

Suppose work is assigned to unit 7. We update our BUSYNESS bit vector by performing the logical AND, where our two sources are the current bit vector 11000010 and the bit mask 01111111. The purpose of the bit mask is to clear bit 7 of the BUSYNESS bit vector, while leaving alone the values corresponding to all the other units. The result is the bit vector 01000010, indicating that unit 7 is now busy.

Suppose unit 5 finishes its task and becomes idle. We can update the BUSYNESS bit vector by performing the logical OR of it with the bit mask 00100000. The result is 01100010, indicating that unit 5 is now available.

Question 6 (2.36 textbook page 53)

Refer to Example 2.11 for the following questions.

a. What mask value and what operation would one use to indicate that machine 2 is busy?

b. What mask value and what operation would one use to indicate that machines 2 and 6 are no longer busy? (Note: This can be done with only one operation.)

c. What mask value and what operation would one use to indicate that all machines are busy?

d. What mask value and what operation would one use to indicate that all machines are idle?

e. Using the operations discussed in this chapter, develop a procedure to isolate the status bit of machine 2 as the sign bit. For example, if the BUSYNESS pattern is 01011100, then the output of this procedure is 10000000. If the BUSYNESS pattern is 01110011, then the output is 00000000. In general, if the BUSYNESS pattern is:

b7   b6   b5   b4   b3   b2   b1   b0

the output is:

b2   0   0   0   0   0   0   0

Hint: What happens when you ADD a bit pattern to itself?

Question 7 (2.39 textbook page 54)

Write the IEEE floating point representation of the following decimal numbers. (write your answer in both binary and 8-bit hexadecimal and show how to get the sign, biased exponent, and mantissa, otherwise, you will be deducted points)

a. 3.75

b. −55 64/23

c. 3.1415927 (just go to 3 binary places of precision, i.e. to the nearest ⅛)

d. 64,000

Question 8 (2.40 textbook page 54)

Write the decimal equivalents for these IEEE floating point numbers. (show how to get the sign, biased exponent, and mantissa otherwise, you will be deducted points)

a. 0 10000000 00000000000000000000000

b. 1 10000011 00010000000000000000000

c. 0 11111111 00000000000000000000000

d. 1 10000000 10010000000000000000000

Question 9 (2.43 textbook page 54)

Translate the following ASCII codes into strings of characters by interpreting each group of eight bits as an ASCII character. (Show your work)

a. x48656c6c6f21

b. x68454c4c4f21

c. x436f6d70757465727321

d. x4c432d32

Question 10 (2.47 textbook page 55)

Convert the following hexadecimal representations of 2’s complement binary numbers to decimal numbers. (Show your work)

a. xF0

b. x7FF

c. x16

d. x8000

Question 11 (2.50 textbook page 55)

Perform the following logical operations. Express your answers in hexadecimal notation otherwise, you will be deducted points. (Show your work)

a. x5478ANDxFDEA

b. xABCDORx1234

c. NOT((NOT(xDEFA)) AND (NOT(xFFFF)))

d. x00FFXORx325C