120 likes | 313 Views
Real Numbers. Real Number Storage. 4-byte IEEE Real Number format. 234.56E+02 234.56 mantissa +02 exponent. Assigning Storage for Large Numbers. Dd (define doubleword) – 4-byte storage; Real number stored as a doubleword is called a short real. Dd 12345.678 Dd +1.5E+02
E N D
Real Number Storage 4-byte IEEE Real Number format 234.56E+02 234.56 mantissa +02 exponent
Assigning Storage for Large Numbers • Dd (define doubleword) – 4-byte storage; Real number stored as a doubleword is called a short real. • Dd 12345.678 • Dd +1.5E+02 • Dd 2.56E+38 ;largest positive exponent • Dd 3.3455E-39 ;largest negative exponent • Dq (Define quadword) -8-byte storage; long real number (double in C,C++ and Visual) • Dq 2.56E+307 ;largest exponent
Floating Point Unit (Coprocessor) • 8 individually addressable 80-bit registers • (ST(0), ST(1), ST(2)…ST(7)) • Arranged in stack format • ST(0) = ST -> top of stack • Control Registers • 3 16-bit registers (control, status, tag) • 2 32-bit registers (instruction pointer, operand pointer)
Instruction Formats • Always begin with the letter F • 2nd letter - B,I – binary coded decimal operand or binary integer operand • If 2nd letter is neither, assume real number format. • FBLD, FILD, FMUL • Can not use CPU registers as operands
Floating Point Operations • Add Add source to destination • Sub Subtract source from destination • Subr Subtract destination from source • Mul Multiply source by destination • Div Divide destination by source • Divr Divide source by destination
Instructions • Classical stack • No explicit operands needed (ST, source; ST(1) destination) • FADD ;ST(1)=ST(1)+ST; pop ST(1) into ST • Register • Uses coprocessor registers as ordinary operands (one must ST)
Evaluating a postfix expression • Well suited for evaluating postfix expressions. • When reading an operand from input, push it on stack • When reading an operator from input, pop the two operands located on the top of the stack, perform the selected operation on the operands, and push the result back on the stack.