[Solved] CIS450 Computer Organization and Architecture Homework #1

$25

File Name: CIS450_Computer_Organization_and_Architecture_Homework_#1.zip
File Size: 536.94 KB

SKU: [Solved] CIS450 Computer Organization and Architecture Homework #1 Category: Tag:
5/5 - (1 vote)

(25 points) Problems:

(2.43/2.61) Using only bit-level and logic operations, write C expressions that yield 1 for the described condition, and 0 otherwise. Assume that x is of type int. You may not use any equality (==) or inequality (!=) tests.

  1. Any bit of x equals 1. _______________________________________________
  1. Any bit of x equals 0. _______________________________________________
  2. Any bit in the least significant byte of x equals 1. _________________________
  3. Any bit in the least significant byte of x equals 0. _________________________

Hint: One solution to part (a.) is: !!x (and, yes, you can use this as your solution :-).

  1. (2.81) Write C expressions to generate the bit patterns that follow, where ak represents k repetitions of symbol a. Assume a w-bit data type. Your code may contain references to j and k, representing the values of j and k, but not a parameter representing w.
  1. 1w-k 0k
  2. 0w-k-j 1k 0 j

For example, if we are dealing with chars, an 8-bit data type, and k = 3, then for a. we want an expression that results in 11111000.

  1. (2.50/2.76/2.77) Suppose we are given the task of generating code to multiply integer variable x by various different constant factors K. To be efficient, we want to use only the operations +, -, and <<. For the following values of K, write C expressions to perform the multiplication using at most three operations per expression.
  1. K = 31: ________________________________________________________
  2. K = -7: ________________________________________________________
  3. K = 80: ________________________________________________________
  4. K = 144: ________________________________________________________

Hint: One solution to part (a.) is: (x<<5) x.

  1. (2.55/2.82/2.83) Consider the numbers having a binary representation consisting of an infinite string of the form 0.yyyyyy, where y is a k-bit sequence. For example, the binary representation of 1/3 is 0.0101010101 (that is, y = 01, and k = 2), while the representation of 1/5 is 0.001100110011 (that is, y = 0011, and k = 4).
    1. Give a formula in terms of y and k for the value represented by the infinite string. Hint: Consider the effect of shifting the binary point k positions to the right, and do part b. first
  1. What is the numeric value of the string for the following values of y? Note that the value of k is implied; e.g., for case i., k = 3, etc.
  1. 110 ____________________________________________________ ii. 01001 ____________________________________________________ iii. 010111 ____________________________________________________
  1. Consider a 16-bit twos complement representation for signed integers. Fill in the empty boxes in the following table. Spaces in the binary representation are just added to enhance readability.
Number Decimal Representation Binary Representation
zero 0
0000 0000 0000 0101
twenty five 25
TMax 32767
TMin 1000 0000 0000 0000
TMin + TMin
-TMax
-TMin
1111 1111 1110 0111
negative one -1

Show work. Hint: 215 = 32768, 214 = 16384, .. , 25 = 32, 24 = 16, .. , 21 = 2, 20 = 1

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CIS450 Computer Organization and Architecture Homework #1
$25