Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMPUTER ORGANIZATION ARITHMETIC YASSER MOHAMMAD.

Similar presentations


Presentation on theme: "COMPUTER ORGANIZATION ARITHMETIC YASSER MOHAMMAD."— Presentation transcript:

1 COMPUTER ORGANIZATION ARITHMETIC YASSER MOHAMMAD

2 ADDITION  What is an overflow?  When can an overflow happen?  Add, addi, sub  exception on overflow  Addu and addiu  no exception ever  C compilers ALWAYS use u version. Why?

3 QUIZ  How to do arithmetic on bytes and half-words?

4 TESTING FOR OVERFLOW  Unsigned Numbers

5 MULTIPLICATION (1)

6 MULTIPLICATION (2)

7 SIGNED MULTIPLICATION  Run 31 iterations  Correct sign  Sign extend

8 PARALLEL MULTIPLICATION MIPS has mult and multu Results are stored in Hi and Lo To read the result use mflo

9 DIVISION MIPS has div and divu Remainder  Hi Qoutient  Lo Read using mflo and mfhi

10 MIPS ARITHMETICS REVISITED

11 FLOATING POINT REPRESENTATION

12 IEEE 754 b=127

13 IEEE 754 ENCODING

14 IEEE 754 EXAMPLE  Representing -0.75  Sign bit  Convert to binary  Shift fraction (mantisa) as needed adjusting the exponent  Find the exponent by adding the bias

15 QUIZ  Convert the following number to decimal:  1 1000011 0100000000000000000000

16 FLOATING POINT ADDITION  Match exponents  Add significands (mantissa)  Normalize the sum (1.xxxxx*….)  Round the number if necessary

17 EXAMPLE  0.5-7/16  Convert to binary  Find normalized forms  Match exponents  Add significands (mantissa)  Normalize the sum (1.xxxxx*….)  Round the number if necessary

18 MIPS FLOATING POINT REGISTERS

19 FLOATING POINT OPERATIONS

20 EXAMPLE float f2c (float fahr) { return ((5.0/9.0) *(fahr – 32.0)); //$F0 } f2c: lwc1 $f16,const5($gp) # $f16 = 5.0 (5.0 in memory) lwc1 $f18,const9($gp) # $f18 = 9.0 (9.0 in memory) div.s $f16, $f16, $f18 # $f16 = 5.0 / 9.0 lwc1 $f18, const32($gp)# $f18 = 32.0 sub.s $f18, $f12, $f18 # $f18 = fahr – 32.0 mul.s $f0, $f16, $f18 # $f0 = (5/9)*(fahr – 32.0) jr $ra # return $F12


Download ppt "COMPUTER ORGANIZATION ARITHMETIC YASSER MOHAMMAD."

Similar presentations


Ads by Google