Computer Organization and ASSEMBLY LANGUAGE
-
Upload
florence-weaver -
Category
Documents
-
view
17 -
download
1
description
Transcript of Computer Organization and ASSEMBLY LANGUAGE
COMPUTER ORGANIZATION AND ASSEMBLY LANGUAGE
Lecture 7 & 8Floating Point Representation
Binary Coded DecimalCourse Instructor: Engr. Aisha Danish
Real Numbers
Numbers with fractions Could be done in pure binary
1001.1010 = 24 + 20 +2-1 + 2-3 =9.625 Where is the binary point? Fixed?
Very limited Moving?
How do you show where it is?
Floating point
In computing, floating point describes a method of representing an approximation of a real number in a way that can support a wide range of values
The numbers are, in general, represented approximately to a fixed number of significant digits (the significand) and scaled using an exponent
The term floating point refers to the fact that a number's radix point (decimal point, or, more commonly in computers, binary point) can "float"; that is, it can be placed anywhere relative to the significant digits of the number
Floating point can be thought of as a computer realization of scientific notation
How floating-point numbers work?
The idea is to compose a number of two main parts: A significand that contains the number’s digits. Negative significands represent negative numbers. An exponent that says where the decimal (or binary)
point is placed relative to the beginning of the significand.
Negative exponents represent numbers that are very small (i.e. close to zero).
Such a format satisfies all the requirements: It can represent numbers at widely different
magnitudes (limited by the length of the exponent) It provides the same relative accuracy at all
magnitudes (limited by the length of the significand)
Floating Point
A typical 32-bit floating-point format The leftmost bit stores the sign of the number The exponent value is stored in the next 8 bits The representation used is known as a biased representation A fixed value, called the bias, is subtracted from the field to get the true
exponent value Typically, the bias equals 2^(k-1)-1where k is the number of bits in the
binary exponent. In this case, the 8-bit field yields the numbers 0 through 255
With a bias of 127(2^7-1), the true exponent values are in the range -127 to +128
In this example, the base is assumed to be 2
Floating Point Examples
Signs for Floating Point
Mantissa/Significand is stored in 2s compliment
Exponent is in excess or biased notation e.g. Excess (bias) 128 means 8 bit exponent field Pure value range 0-255 Subtract 127 to get correct value Range -127 to +128
Normalization
A normalized number is one in which the most significant digit of the significand is nonzero
For base 2 representation, 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
i.e. exponent is adjusted so that leading bit (MSB) of mantissa is 1
Since it is always 1 there is no need to store it (Scientific notation where numbers are normalized to give
a single digit before the decimal point e.g. 3.123 x 103)
IEEE 754
Developed to facilitate the portability of programs from one processor to another and to encourage the development of sophisticated, numerically oriented programs
The standard has been widely adopted and is used on virtually all contemporary processors and arithmetic coprocessors
32 and 64 bit standards 8 and 11 bit exponent respectively
IEEE 754 Formats
Required Reading
Stallings Chapter 9 IEEE 754 on IEEE Web site
The 8421 BCD Code
BCD stands for Binary-Coded Decimal.
A BCD number is a four-bit binary group that represents one of the ten decimal digits 0 through 9.
Example:Decimal number 4926 4 9 2 6
8421 BCD coded number 0100 1001 0010 0110
Convert the BCD coded number 1000 0111 0001 into decimal.
QUIZ
Decimal Number 8 7 1
BCD Coded Number 1000 0111 0001
Convert the decimal number 350 to its BCD equivalent.
Decimal Number 3 5 0
BCD Coded Number 0011 0101 0000
QUIZ
Binary Coded Decimal (BCD) Would it be easy for you if you can
replace a decimal number with an individual binary code? Such as 00011001 = 1910
The 8421 code is a type of BCD to do that.
BCD code provides an excellent interface to binary systems: Keypad inputs Digital readouts
Binary Coded Decimal
Decimal Digit 0 1 2 3 4 5 6 7 8 9
BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
ex1: dec-to-BCD
(a) 35
(b) 98
(c) 170
(d) 2469
ex2: BCD-to-dec
(a) 10000110
(b) 001101010001
(c) 1001010001110000
Note: 1010, 1011, 1100, 1101, 1110, and 1111 are INVALID CODE!
BCD Addition
BCD is a numerical code and can be used in arithmetic operations. Here is how to add two BCD numbers: Add the two BCD numbers, using the rules for
basic binary addition. If a 4-bit sum is equal to or less than 9, it is a
valid BCD number. If a 4-bit sum > 9, or if a carry out of the 4-bit
group is generated it is an invalid result. Add 6 (0110) to a 4-bit sum in order to skip the six the invalid states and return the code to 8421. If a carry results when 6 is added, simply add the carry to the next 4-bit group.
BCD Addition
Add the following numbers
(a) 0011+0100(b) 00100011 + 00010101(c) 10000110 + 00010011(d) 010001010000 + 010000010111(e) 1001 + 0100(f) 1001 + 1001(g) 00010110 + 00010101(h) 01100111 + 01010011