Problem Set 1

Intro to Computer Architecture Spring, 2018 Due:  February 16 (class time)

You may write your solutions on paper or submit them electronically using handin.  The purpose of the assignment is to demonstrate your knowledge of the algorithms presented in class, so it is essential that you show how your answers are derived.

1.  Convert the following numbers to their 32-bit binary representations.  Assume that 2's complement is used for negative numbers.  Express your answers in hexadecimal.

a.  2018
b.  -4000
c.  8193

2.  What decimal numbers are represented by the following 32-bit values?  (Again, assume that 2's complement is used for negative numbers.)

a.  0000004D
b.  000012B6
c.  FFFFFCBA

3.   Perform the following calculations on 8-bit two’s complement numbers.

a.  00101101
+01101111

b.  11111111
+11111111

c.  00000000
–11111111

d.  11110111
–11110111

4.  Consider the following addition problems for 3-bit binary integers in two’s complement.  Each result is a 3-bit binary integer.  For each sum, state

whether the sign bit of the result is 1
whether the result has a value of 0
whether an overflow occurred

5.  Multiply 0111 and 0011 in binary.  (Don't worry about overflow in this case.)

6.  Write Java statements to do the following:  (Assume x and y are declared as ints.  Bits are numbered 31 to 0 from left to right.)

a.  Set y to the value in bits 18-11 of x.

b.  Set bits 18-11 of x to 0.

c.  Set bits 18-11 of x to 1.

d.  Invert bits 18-11 of x.

e.  Store the value '0110' in bits 19-16 of x.