CS F342-11 PDF
CS F342-11 PDF
CS F342-11 PDF
BITS Pilani
Hyderabad Campus
BITS Pilani
Hyderabad Campus
CS F342
Computer Architecture Lecture -11
9/19/2013
3
BITS Pilani, Hyderabad Campus
Algorithm:
Bits of dividend are examined from L to R until the set of bits examined represents a number greater than or equal to the divisor
Until this event occurs, 0s are placed in the quotient When the event occurs, a 1 is placed in the quotient and the divisor is subtracted from the partial dividend This continues in cyclic pattern The process stops when all the bits of dividend are exhausted
More complex than multiplication
Examples:
Needs operations like Shift, subtract, restore Positive numbers: Q = 0111 (Dividend) M = 0011 (Divisor)
Signed division
Example : (7/-3)
MIPS Division
Use HI/LO registers for result
HI: 32-bit remainder LO: 32-bit quotient
Instructions
div rs, rt / divu rs, rt Ex: div $s0,$t0 No overflow or divide-by-0 checking
Software must perform checks if required
Use mfhi, mflo to access result Ex: mfhi $t0 #$t0 <- reminder
14
Floating Point
m x re
m : mantissa r : radix [ can be 2,8,16,10] e : exponent
The number 537.25 is represented in a register with m = 53725 and e = 3 Interpreted as .53725x103 Point is actually fixed between sign bit and body of mantissa Exponent indicates place value (point position)
BITS Pilani, Hyderabad Campus
Exponent representation: Exponent can be represented in Signed magnitude, Signed 2s complement, Signed 1s complement or biased form. Biased representation:
In this representation the sign bit is removed from being a separate entity. Bias is a +ve number that is added to each exponent as the floating point number is formed, so that internally all exponent are +ve.
Consider an exponent that ranges from -50 to 49. Internally, it is represented by two digits (without sign) by adding to it a bias of 50. The exponent register contains the no. e+50, where e is the actual exponent.
Normalization
To simplify operations on floating-point numbers, it is typically required that they have to be normalized. A normalized number is one in which the most significant digit of the significand is nonzero Floating Point numbers are usually normalized i.e. exponent is adjusted so that leading bit (MSB) of mantissa is non zero. Ex: .0001580x102 (Normalized number is : 0.1580x10-1) Ex: 0.000123 (Normalized number is : 0.123x10-3), here ".123" is called a normalized mantissa, "-3" is called the exponent.
Normalization
For binary numbers, a normalized number is therefore one in which the most significant bit of the significand is one. The typical convention is that there is one bit to the left of the radix point. Thus, a normalized nonzero number is one in the form: Because the most significant bit is always one, it is unnecessary to store this bit; rather, it is implicit Zero cannot be normalized
BITS Pilani, Hyderabad Campus
The leftmost bit stores the sign of the number (1:negative, 0:positive)
Single precision
Bias equals, where k: no: of bits in exponent The range of true exponent values are: -126 to 127 The final portion is significand /mantissa