Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Organization and Assembly Language

Similar presentations


Presentation on theme: "Computer Organization and Assembly Language"— Presentation transcript:

1 Computer Organization and Assembly Language
Prepared by: Muhammad Faisal

2 Prepared by: Muhammad Faisal
Key Objectives Floating Point Processing and Instruction Coding Floating Point Binary Representation Floating Point Unit Prepared by: Muhammad Faisal

3 Floating Point Binary Representation
A floating-point decimal number contains three components: a sign, a significand, and an exponent. In the number × 105, for example, the sign is positive, the significand (mantissa ) is , and the exponent is 5. The term floating point is derived from the fact that there is no fixed number of digits before and after the decimal point; that is, the decimal point can float.  In general, floating-point representations are slower and less accurate than fixed-point representations, but they can handle a larger range of numbers Prepared by: Muhammad Faisal

4 IEEE Binary Floating-Point Representation
x86 processors use three floating-point binary storage formats specified in the Standard for Binary Floating-Point Arithmetic produced by the IEEE organization. Prepared by: Muhammad Faisal

5 Single-precision format
The Sign: If the sign bit is 1, the number is negative; if the bit is 0, the number is positive. Zero is considered positive. The Significand: In the floating-point number represented by the expression m * be, m is called the significand, b is the base; and e is the exponent. Binary floating-point numbers also use weighted positional notation. The floating-point binary value is expressed as Prepared by: Muhammad Faisal

6 Single-precision format
Another way to express the values to the right of the binary point is to list them as a sum of fractions whose denominators are powers of 2. In our sample, the sum is 11/16 (or ): The decimal numerator (11) represents the binary bit pattern If e is the number of significant bits to the right of the binary point, the decimal denominator is 2e. In our example, e = 4, so 2e = 16. The entire continuum of real numbers cannot be represented in any floating-point format having a finite number of bits. Suppose, for example, a simplified floating-point format had 5-bit significands. There would be no way to represent values falling between and binary. Prepared by: Muhammad Faisal

7 Prepared by: Muhammad Faisal
The Exponent Single precision exponents are stored as 8-bit unsigned integers with a bias of 127. The number’s actual exponent must be added to 127. Consider the binary value × 25: After the actual exponent (5) is added to 127, the biased exponent (132) is stored in the number’s representation. The biased exponent is always positive, between 1 and 254. The actual exponent range is from -126 to +127. The range was chosen so the smallest possible exponent’s reciprocal cannot cause an overflow. Prepared by: Muhammad Faisal

8 Normalized Binary Floating-Point Numbers
Most floating-point binary numbers are stored in normalized form so as to maximize the precision of the significand. Given any floating-point binary number, you can normalize it by shifting the binary point until a single “1” appears to the left of the binary point. The exponent expresses the number of positions the binary point is moved left (positive exponent) or right (negative exponent). To reverse the normalizing operation is to denormalize a binary floating-point number. Shift the binary point until the exponent is zero Prepared by: Muhammad Faisal

9 Creating the IEEE Representation
Once the sign bit, exponent, and significand fields are normalized and encoded, it’s easy to generate a complete binary IEEE short real. We can place the sign bit first, the exponent bits next, and the fractional part of the significand last. For example, binary × 20 is represented as follows: Sign bit: 0 Exponent: Fraction: The biased exponent ( ) is the binary representation of decimal 127. Prepared by: Muhammad Faisal

10 Creating the IEEE Representation
All normalized significands have a 1 to the left of the binary point, so there is no need to explicitly encode the bit. The IEEE specification includes several real-number and non-number encodings. • Positive and negative zero • Denormalized finite numbers • Normalized finite numbers • Positive and negative infinity • Non-numeric values (NaN, known as Not a Number) QNaN is a quiet NaN, and SNaN is a signaling NaN. Indefinite numbers Prepared by: Muhammad Faisal

11 Converting Decimal Fractions to Binary Reals
When a decimal fraction can be represented as a sum of fractions in the form (1/2 + 1/4 + 1/ ), it is fairly easy for you to discover the corresponding binary real. Many real numbers, such as 1/10 (0.1) or 1/100 (.01), cannot be represented by a finite number of binary digits Such a fraction can only be approximated by a sum of fractions whose denominators are powers of 2. Using Binary Long Division: When small decimal values are involved, an easy way to convert decimal fractions into binary is to first convert the numerator and denominator to binary and then perform long division Prepared by: Muhammad Faisal

12 Converting Decimal Fractions to Binary Reals
For example, decimal 0.5 is represented as the fraction 5/10. Decimal 5 is binary 0101, and decimal 10 is binary Performing the binary long division, we find that the quotient is 0.1 binary: When 1010 binary is subtracted from the dividend the remainder is zero, and the division stops. Therefore, the decimal fraction 5/10 equals 0.1 binary. Prepared by: Muhammad Faisal

13 Converting Single-Precision Values to Decimal
The following are suggested steps when converting a IEEE single-precision value to decimal: 1. If the MSB is 1, the number is negative; otherwise, it is positive. 2. The next 8 bits represent the exponent. Subtract binary (decimal 127), producing the unbiased exponent. Convert the unbiased exponent to decimal. 3. The next 23 bits represent the significand. Notate a “1.”, followed by the significand bits. Trailing zeros can be ignored. Create a floating-point binary number, using the significand, the sign determined in step 1, and the exponent calculated in step 2. Prepared by: Muhammad Faisal

14 Converting Single-Precision Values to Decimal
4. Denormalize the binary number produced in step 3. (Shift the binary point the number of places equal to the value of the exponent. Shift right if the exponent is positive, or left if the exponent is negative.) 5. From left to right, use weighted positional notation to form the decimal sum of the powers of 2 represented by the floating-point binary number. Class Assignment : Convert IEEE ( ) to Decimal Prepared by: Muhammad Faisal

15 Prepared by: Muhammad Faisal
Floating-Point Unit The Intel 8086 processor was designed to handle only integer arithmetic. This turned out to be a problem for graphics and calculation-intensive software using floating-point calculations. Programs such as AutoCad (by Autodesk) demanded a more powerful way to perform floating-point math. Intel sold a separate floating-point coprocessor chip named the 8087, and upgraded it along with each processor generation. With the advent of the Intel486, floating-point hardware was integrated into the main CPU and called the FPU. Prepared by: Muhammad Faisal

16 Prepared by: Muhammad Faisal
FPU Register Stack The FPU does not use the general-purpose registers (EAX, EBX, etc.). It has its own set of registers called a register stack. FPU instructions evaluate mathematical expressions in postfix format, in much the same way as Hewlett-Packard calculators. Infix expression: (5 * 6) + 4. Requires Parentheses Postfix equivalent: is 5 6 * 4 +. Does not Requires Parentheses Prepared by: Muhammad Faisal

17 Prepared by: Muhammad Faisal
FPU Register Stack Expression Stack: A stack holds intermediate values during the evaluation of postfix expressions. The stack entries are labeled ST(0) and ST(1), with ST(0) indicating where the stack pointer would normally be pointing. Prepared by: Muhammad Faisal

18 Evaluating the postfix expression 5 6 * 4 – .
Prepared by: Muhammad Faisal

19 Prepared by: Muhammad Faisal
FPU Data Registers The FPU has eight individually addressable 80-bit data registers named R0 through R7 called Data Stack. If loading a value into the stack would result in overwriting existing data in the register stack, a floating-point exception is generated. Prepared by: Muhammad Faisal

20 Prepared by: Muhammad Faisal
FPU Data Registers A three-bit field named TOP in the FPU status word identifies the register number that is currently the top of the stack. In Fig., for example, TOP equals binary 011, identifying R3 as the top of the stack. This stack location is also known as ST(0) (or simply ST) when writing floating-point instructions. The last register is ST(7). A push operation (also called load) decrements TOP by 1 and copies an operand into the register identified as ST(0). A pop operation (also called store) copies the data at ST(0) into an operand, then adds 1 to TOP. Prepared by: Muhammad Faisal

21 Prepared by: Muhammad Faisal
FPU Data Registers Floating-point values in registers use the IEEE 10-byte extended real format (also known as temporary real). When the FPU stores the result of an arithmetic operation in memory, it translates the result into one of the following formats: integer, long integer, single precision (short real), double precision (long real), or packed binary-coded decimal (BCD). The FPU has six special-purpose registers. Opcode register: stores the opcode of the last noncontrol instruction executed. • Control register: controls the precision and rounding method used by the FPU when performing calculations. Prepared by: Muhammad Faisal

22 Prepared by: Muhammad Faisal
FPU Data Registers • Status register: contains the top-of-stack pointer, condition codes, and warnings about exceptions. • Tag register: indicates the contents of each register in the FPU data-register stack. It uses two bits per register to indicate whether the register contains a valid number, zero, or a special value or is empty. • Last instruction pointer register: stores a pointer to the last noncontrol instruction executed. • Last data (operand) pointer register: stores a pointer to a data operand, if any, used by the last instruction executed. The special-purpose registers are used by operating systems to preserve state information when switching between tasks. Prepared by: Muhammad Faisal

23 Prepared by: Muhammad Faisal
Thank You Prepared by: Muhammad Faisal


Download ppt "Computer Organization and Assembly Language"

Similar presentations


Ads by Google