Assignment 5 Solution

(1) 5 points What decimal value is represented by the IEEE single precision floating point value 0xc2290000 ?

 0xc2290000 can be represented in floating point notation as

 S     E             F
 1  10000100  01010010000000000000000

 exponent e = E-127 = 5
			       
 Decimal value D = - 1.01010010..0 * (2**5)
                              
		 = - 101010.010..0

		 = - 42.25

(2) 6 points Perform the following operations. Assume that the operands and the results are integers represented as 8-bit 2's complement integers. Indicate which ( if any ) of the operations cause overflow.

	10101010	00001111	10001001
      + 11011000      + 10001111      - 01100000 (add 2's complement
						  of 01100000)
      ----------      -----------     -----------
    1<-	10000010     0<-10011110     1<-00101001

     No overflow      No overflow     Overflow

Overflow occurs if the MSB of both added integers are the same
and that of the result is different.

(3) 6 points Perform the following operations. Assume that the operands and the results are integers represented as 8-bit sign magnitude integers. Indicate which (if any) of the operations cause overflow.

	1 0101010	0 0001111	1 0001001
      + 1 1011000     + 1 0001111     - 0 1100000 (X-Y = X+(-Y)
						  Hence make sign
						  bit 1)
      ----------      -----------     -----------
          0000010                         1101001
	  |                               |
	  1                               0
	(Carry)                         (Carry)

	Overflow       No overflow      No overflow

 Overflow occurs only  if there is a carry out of the magnitude
 bits. We need to calculate sum only if both signs are the same.

(4) 5 points Perform the following multiplication. Assume that both operands are 5-bit 2's complement integers and the result is a 10-bit 2's complement integer.

	11010   --->	11111 11010	( -6 ) // Sign extension
     *  11000   --->	11111 11000	( -8 )
     ---------		------------
			00000 00000
			00000 0000
			00000 000
			11110 10
			11101 0
			11010
			1010
			010
			10
			0
			-----------
			00001 10000	( 48 )
			-----------

(5) 6 points What are the values of the variables aa,bb and cc after the following SAL code completes? Give the results in hexadecimal.


.data

aa: .word 0x000000aa bb: .word 0xe00000ff cc: .word 0xcc112233

.text

nand aa,aa,bb xor bb,bb,aa sll cc,cc,3 done

Solution

aa = 0xffffff55 bb = 0x1fffffaa cc = 0x60891198

______________________________________________________________________________