What is the resulting bit sequence what is the


? Along with your name, include your student ID# and discussion section at the top of your Assignment.

? There are eight problems; we will go over them in dicussion section after the due date.

? The textbook in this context is: R. Bryant, D. O'Hallaron, Computer Systems: A Programmer's Perspective. (3rd Edition)

Problem 1.

Q1. Give the base 10 integer equivalent of the following. Assume 16 bit hex numbers, 16 bit, twos complement.

a) 0xC87A

b) 0x1BCD

Q2. Write a mask (in hexadecimal) to give the value of the last 9 binary digits of the numbers in Q1 above.

Q3: Using your mask from Q2 above, give the equivalent base 10 values represented by the last 9 binary digits for both hexadecimal values from Q1.

Problem 2.

Assume you trying to reconstruct a sequence of 12 bits (call it 'a') where the middle four bits are missing. What you have is the hexadecimal sequence E_E where "_" represents the missing bits. You also have the octal bit sequence representing bitwise NOT(a)which is "_52_". There are two missing digits in this sequence (represented by the '_').

Q1. What is the complete hexadecimal value of a?

Q2. What is the base 10 equivalent of the complete value of a?

Problem 3.

Suppose you are given a positive integer number ‘x'. Give a single expression (using only bitwise operators, shifts, +, -) to find the value of 4.5 * x.

Problem 4. (similar to Problem 2.88 in the text)

Consider the following two 9-bit floating point representations based on IEEE floating point format.

Format A

? There is 1 sign bit.

? There are k = 5 exponent bits. The exponent bias is 15.

? There are n = 3 fraction bits.

Format B

? There is 1 sign bit.

? There are k = 4 exponent bits. The exponent bias is 7.

? There are n = 4 fraction bits.

In the table below, given the bit patterns in Format A , convert to the closest value in Format B and fill in the bit pattern in the "Bits" column under Format B. If rounding is necessary, you should round toward +∞. For both Format A and Format B, fill in the base 10 equivalent values. The first bit sequence is completed for you.

Format A Format B

Bits Value Bits Value

1 01111 001 -9/8 1 0111 0010 -9/8

1 10110 111

0 01101 100

1 00000 100

0 00000 000

0 11000 101

Problem 5.

Assume you have a 16 bit machine with 65536 bytes of memory. Ints are 2 bytes. Assume that variables are placed in memory contiguously in the order they are coded, starting at memory address 0x500. That means that ints and memory addresses are 16 bits long. Given the following code segment:

int x = 4; int y = 3;

int *px = &x; int *py = &y;

printf("starting x) %d\n", x); printf("starting y) %d\n", y); printf("a) %p\n", px); printf("b) %p\n", py);

py = px;

printf("c) %d\n", *px); printf("d) %x\n", &px); *px = 35; y = 120; printf("e) %d\n", *px); printf("f) %d\n", *py); printf("g) %d\n", x); printf("h) %d\n", y);

Give the output of each printf() assuming the %p format specifier prints out a memory address in hexadecimal.

Problem 6. Assume 8-bit twos complement integer representation for the questions that follow:

Q1: Give the bit sequence for the largest positive number.

Q2: Give the base 10 integer equivalent value for the bit sequence in Q1 above.

Q3: Add: 10110110 + 01110111

What is the resulting bit sequence?

What is the corresponding base 10 value?

Does this computation result in an overflow? Briefly explain.

Q4: Add: 01110111 + 01001111

What is the resulting bit sequence?

What is the corresponding base 10 value?

Does this computation result in an overflow? Briefly explain.

Q5: Add: 10111111 + 11111111

What is the resulting bit sequence?

What is the corresponding base 10 value?

Does this computation result in an overflow? Briefly explain.

Problem 7. (taken from the text Question 2.86 page 137)

Intel processors support "extended precision" floating point format with 80 bits that includes a single "integer bit" representing the hidden or implied leading 1 in the IEEE representation. The integer bit is "1" for normalized values (indicating a 1 immediately to the left of the binary point, and it is "0" for non-normalized values. Using a highly abbreviated (8-bit) version of this format with 1 sign bit, 4 exponent bits, the single integer bit, and 2 fraction bits, give the bit representations for the floating point numbers requested below.

Q1: 0.0

Q2: -1.0

Q3: 1/16

Q4: 1.25

Q5: 2.0

Problem 8.

For each of the following propositions in the context of a C program, indicate if they are true or false. If false, give a counter example. Assume that the variables are declared as follows:

int x, y; // 32 bit integers

unsigned u; // 32 bit unsigned integer

and initialized to some unknown values. We have given the first answer as an example.

TRUE/FALSE Counter Example

01..1 + 1 → 10..0 which
If x > 0 then x + 1 > 0 FALSE
is negative

If x < 0 then x -1 < 0

If x > 0 then x * x > 0

(~u <= 0) == FALSE

If x < 0 then u > x

If x > -y then -x < y

(x << m) >> m == x

u & 0 == 0

If x >= 0 then ~x <= -x - 1

Attachment:- Assignment.rar

Solution Preview :

Prepared by a verified Expert
Programming Languages: What is the resulting bit sequence what is the
Reference No:- TGS01728099

Now Priced at $45 (50% Discount)

Recommended (97%)

Rated (4.9/5)