7.ece5436
TRANSCRIPT
ECE 5436/6336���Advanced Microprocessor
Systems
Pauline Markenscoff N320 Engineering Building 1 E-mail: [email protected] Week 9
2
Floating Point Representations
Common Format Components
Each codes a normalized number whose “binary scientific notation” would be ���±1.dd…d x 2exp
Sign bit • 0 for positive and 1 for negative
Exponent field • Actual exponent exp plus a bias • Bias gives an alternative to 2’s complement
Fraction (“mantissa”) field
IEEE Single Precision Format
32-bit format • Sign bit • 8-bit biased exponent (the actual exponent in the
normalized binary “scientific” format plus 127) • 23-bit fraction (the fraction in the scientific format without
the leading 1 bit)
Generated by REAL4 directive
IEEE Double Precision Format
64-bit format • Sign bit • 11-bit biased exponent (the actual exponent in the
normalized binary scientific format plus 1023) • 52-bit fraction (the fraction in the scientific format without
the leading 1 bit) Generated by REAL8 directive
Extended Precision Format
80-bit format • Sign bit • 15-bit biased exponent (the actual exponent in a normalized
binary scientific format plus 16,383) • 64-bit fraction (the fraction in the scientific format
including the leading 1 bit) Generated by REAL10 directive
Floating Point Formats
format total bits exponent bits
fraction bits
approximate maximum
approximate minimum
approximate decimal
precision
single 32 8 23 3.40×1038 1.18×10-38 7 digits
double 64 11 52 1.79×10308 2.23×10-308 15 digits
extended double 80 15 64 1.19×104932 3.37×10-4932 19 digits
• These are for normalized numbers • Binary scientific notation mantissa written starting with 1 and binary
point • Zero cannot be normalized
• +0 represented by a pattern of all 0 bits • Also formats for ± ∞ and NaN ("not a number”)
Assembler Data Declarations
number1 REAL4 78.375 number2 REAL8 -78.375 number3 REAL10 78.375 assembly listing 00000000 429CC000 number1 REAL4 78.375 00000004 number2 REAL8 -78.375
C053980000000000 0000000C number3 REAL10 78.375
40059CC0000000000000
80x86 Floating Point Architecture
Floating Point Unit
FPU is independent of integer unit Eight 80-bit registers, organized as a stack
• ST, the stack top, also called ST(0) • ST(1), the register just below the stack top • ST(2), the register just below ST(1) • ST(3), ST(4), ST(5), ST(6) • ST(7), the register at the bottom of the stack
Several 16-bit control registers, including status word
Load Instructions
fld realMemoryOperand • Loads stack top ST with floating point data value • Values already on the stack are pushed down
fld integerMemoryOperand • Converts integer value to corresponding fp value that is
pushed onto the stack fld st(nbr)
• Pushes a copy of st(nbr) onto the fp stack
More Loads and finit
fld1 • Pushes 1.0 onto floating point stack
fld0 • Pushes 0.0 onto fp stack
fldpi • Pushes π onto fp stack …and others
finit initializes the floating point processor, clearing the stack
Store Instructions
fst realMemoryOperand • Copies stack top ST value to memory
fstp realMemoryOperand • Copies stack top ST value to memory and pops the floating
point stack fist integerMemoryOperand
• Copies stack top ST value to memory, converting to integer fistp integerMemoryOperand
• Same as fist, but also pops the floating point stack
Exchange Instructions
fxch • Exchange values in ST and ST(1)
fxch st(nbr) • Exchange ST and ST(nbr)
Addition Instructions
fadd • adds ST(1) and ST; pushes sum on stack
fadd st, st(nbr) • adds ST(nbr) and ST; sum replaces ST
fadd st(nbr), st • adds ST(nbr) and ST; sum replaces ST(nbr)
faddp st(nbr), st • adds ST(nbr) and ST; sum replaces ST(nbr); old ST
popped from stack
More Addition Instructions
fadd realMemoryOperand • Adds ST and real memory operand; ���
sum replaces ST fiadd integerMemoryOperand
• Adds ST and integer memory operand; ���sum replaces ST
Addition Example
Before Instructions After
10.0 ST fadd st,st(3) 56.0 ST
20.0 ST(1) fadd fpValue 20.0 ST(1)
30.0 ST(2) fiadd intValue 30.0 ST(2)
40.0 ST(3) 40.0 ST(3)
ST(4) ST(4)
ST(5) ST(5)
ST(6) ST(6)
ST(7) ST(7)
Data declarations fpValue REAL4 5.0
intValue DWORD 1
Subtraction Instructions
fsub • pops ST and ST(1); calculates ST(1) - ST; pushes difference onto the stack
fsub st(nbr), st • calculates ST(nbr) - ST; ���
replaces ST(nbr) by the difference fsub st, st(nbr)
• calculates ST - ST(nbr); ���replaces ST by the difference
More Subtraction Instructions
fsub realMemoryOperand • calculates ST - real number from memory; replaces ST by the difference
fisub integerMemoryOperand • calculates ST - integer from memory; ���
replaces ST by the difference fsubp st(nbr), st
• calculates ST(nbr) - ST; ���replaces ST(nbr) by the difference; ���pops ST from the stack
Reversed Subtraction Instructions
fsubr • pops ST and ST(1); calculates ST - ST(1) ; pushes difference onto the stack
fsubr st(nbr), st • calculates ST - ST(nbr); ���
replaces ST(nbr) by the difference fsubr st, st(nbr)
• calculates ST(nbr) - ST; ���replaces ST by the difference
More Reversed Subtraction Instructions
fsubr realMemoryOperand • calculates real number from memory - ST; replaces ST by the difference
fisubr integerMemoryOperand • calculates integer from memory - ST; ���
replaces ST by the difference fsubpr st(nbr), st
• calculates ST - ST(nbr); ���replaces ST(nbr) by the difference; ���pops ST from the stack
Multiplication Instructions
fmul • pops ST and ST(1); ���
multiplies these values; ���pushes product onto the stack
fmul st(nbr), st • multiplies ST(nbr) and ST; ���
replaces ST(nbr) by the product fmul st, st(num)
• multiplies ST and ST(nbr); ���replaces ST by the product
More Multiplication Instructions
fmul realMemoryOperand • multiplies ST and real number from memory; replaces ST by the product
fimul integerMemoryOperand • multiplies ST and integer from memory; replaces ST by the product
fmulp st(nbr), st • multiplies ST(nbr) and ST; ���
replaces ST(nbr) by the product; ���pops ST from stack
Division Instructions
fdiv • pops ST and ST(1); ���
calculates ST(1) / ST; ���pushes quotient onto the stack
fdiv st(nbr), st • calculates ST(nbr) / ST; ���
replaces ST(nbr) by the quotient fdiv st,st(nbr)
• calculates ST / ST(nbr); ���replaces ST by the quotient
More Division Instructions
fdiv realMemoryOperand • calculates ST / real number from memory; replaces ST by the quotient
fidiv integerMemoryOperand • calculates ST / integer from memory; ���
replaces ST by the quotient fdivp st(nbr),st
• calculates ST(nbr) / ST; ���replaces ST(nbr) by the quotient; ���pops ST from the stack
Reversed Division Instructions
Similar to reversed multiplication--each division instruction has a version that reverses operands used as dividend and divisor • fdivr (pops ST and ST(1),calculates ST/ST(1);pushes quotient onto the stack)
• fidivr memory (integer) (calculates integer from memory/ST; replaces ST by the quotient)
• fdivpr st(num),st calculates ST/ST(num); replaces ST(num) by the quotient; pops ST from the stack.
Miscellaneous Instructions
fabs • Absolute value: ST := | ST |
fchs • Change sign: ST := - ST
frndint • Rounds ST to an integer value
fsqrt • Replace ST by its square root There are also trigonometric, exponential and logarithmic functions
Comparisons Each instruction compares ST with some other operand Sets “condition code” bits 14, 10 and 8 in the status word register
• These bits are named C3, C2 and C0
result of comparison C3 (14)
C2 (10)
C0 (8)
ST > operand 0 0 0 ST < operand 0 0 1 ST = operand 1 0 0 not comparable 1 1 1
Comparison Instructions
fcom • compares ST and ST(1)
fcom st(nbr) • compares ST and ST(nbr)
fcom realMemoryOperand • compares ST and real number in memory
ficom integerMemoryOperand • compares ST and integer in memory
More Comparison Instructions ftst
• compares ST and 0.0 fcomp
• compares ST and ST(1); then pops stack fcompp
• compares ST and ST(1); then pops stack twice
result of comparison
C3 (14)
C2 (10)
C0 (8)
ST > operand 0 0 0 ST < operand 0 0 1 ST = operand 1 0 0 not comparable 1 1 1
Yet More Comparison Instructions
fcomp st(nbr) • compares ST and ST(nbr); then pops stack
fcomp realMemoryOperand • compares ST and real number in memory; then pops stack
ficomp integerMemoryOperand • compares ST and integer in memory; then pops stack
Status Word Access Conditional jump instructions look at bits in flags register, not in status word. The fstsw instructions provide access to the status word bits.
fstsw memoryWord • copies status register to memory word
fstsw AX • copies status register to AX
sahf;shifts condition code bits to
flags • sahf instruction puts C3 in the ZF position, C2 in the PF position, and C0 in the CF position
Programming With Floating Point Instructions
FP Program-Example 1 ; compute roots of quadratic equation .586
.MODEL FLAT
.STACK 4096
.DATA
aa REAL4 2.0
bb REAL4 -1.0
cc REAL4 -15.0
discr REAL4 ? x1 REAL4 ?
x2 REAL4 ?
four DWORD 4
two DWORD 2
ax2 + bx + c = 0
x1 =!b+ b2 ! 4ac
2a
x2 =!b! b2 ! 4ac
2a
FP Program- Example 1 .CODE main PROC
finit ; initialize FPU
fld bb ; b in ST
fmul bb ; b*b
fild four ; 4.0 in ST
fmul aa ; 4*a
fmul cc ; 4*a*c
fsub ; b*b-4*a*c fldz ; 0.0 in ST
fxch ; b*b-4*a*c in ST; 0.0 in ST(1)
fcom st(1) ; b*b-4*a*c >= 0 ?
fstsw ax ; copy condition code bits to AX
sahf ; shift condition code bits to flags
jnae endGE ; skip if not
FP Program-Example 1 fsqrt ; sqrt(b*b-4*a*c) in ST fst st(1) ; copy to ST(1)
fsub bb ; -b + sqrt(b*b-4*a*c)
fdiv aa ; (-b + sqrt(b*b-4*a*c))/a
fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x1 ; save and pop stack
fchs ; -sqrt(b*b-4*a*c)
fsub bb ; -b -sqrt(b*b-4*a*c)
fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x2 ; save and pop stack
endGE:
mov eax, 0 ; exit
ret
main ENDP
END 37
FP Program-Example 1 ; compute roots of quadratic equation .586
.MODEL FLAT
.STACK 4096
.DATA
aa REAL4 2.0
bb REAL4 -1.0
cc REAL4 -15.0
discr REAL4 ? x1 REAL4 ?
x2 REAL4 ?
four DWORD 4
two DWORD 2
ax2 + bx + c = 0
x1 =!b+ b2 ! 4ac
2a
x2 =!b! b2 ! 4ac
2a
FP Program-Example 1 .CODE main PROC
finit ; initialize FPU fld bb ; b in ST fmul bb ; b*b
fild four ; 4.0 in ST
fmul aa ; 4*a
fmul cc ; 4*a*c
fsub ; b*b-4*a*c fldz ; 0.0 in ST
fxch ; b*b-4*a*c in ST; 0.0 in ST(1)
fcom st(1) ; b*b-4*a*c >= 0 ?
fstsw ax ; copy condition code bits to AX
sahf ; shift condition code bits to flags
jnae endGE ; skip if not
fsqrt ; sqrt(b*b-4*a*c) in ST
b ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1 .CODE main PROC
finit ; initialize FPU fld bb ; b in ST fmul bb ; b*b fild four ; 4.0 in ST
fmul aa ; 4*a
fmul cc ; 4*a*c
fsub ; b*b-4*a*c fldz ; 0.0 in ST
fxch ; b*b-4*a*c in ST; 0.0 in ST(1)
fcom st(1) ; b*b-4*a*c >= 0 ?
fstsw ax ; copy condition code bits to AX
sahf ; shift condition code bits to flags
jnae endGE ; skip if not
fsqrt ; sqrt(b*b-4*a*c) in ST
b*b ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1 .CODE main PROC
finit ; initialize FPU fld bb ; b in ST fmul bb ; b*b fild four ; 4.0 in ST fmul aa ; 4*a
fmul cc ; 4*a*c
fsub ; b*b-4*a*c fldz ; 0.0 in ST
fxch ; b*b-4*a*c in ST; 0.0 in ST(1)
fcom st(1) ; b*b-4*a*c >= 0 ?
fstsw ax ; copy condition code bits to AX
sahf ; shift condition code bits to flags
jnae endGE ; skip if not
fsqrt ; sqrt(b*b-4*a*c) in ST
4.0 ST0
b*b ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1 .CODE main PROC
finit ; initialize FPU fld bb ; b in ST fmul bb ; b*b fild four ; 4.0 in ST fmul aa ; 4*a fmul cc ; 4*a*c
fsub ; b*b-4*a*c fldz ; 0.0 in ST
fxch ; b*b-4*a*c in ST; 0.0 in ST(1)
fcom st(1) ; b*b-4*a*c >= 0 ?
fstsw ax ; copy condition code bits to AX
sahf ; shift condition code bits to flags
jnae endGE ; skip if not
fsqrt ; sqrt(b*b-4*a*c) in ST
4*a ST0
b*b ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1 .CODE main PROC
finit ; initialize FPU fld bb ; b in ST fmul bb ; b*b fild four ; 4.0 in ST fmul aa ; 4*a fmul cc ; 4*a*c fsub ; b*b-4*a*c fldz ; 0.0 in ST
fxch ; b*b-4*a*c in ST; 0.0 in ST(1)
fcom st(1) ; b*b-4*a*c >= 0 ?
fstsw ax ; copy condition code bits to AX
sahf ; shift condition code bits to flags
jnae endGE ; skip if not
fsqrt ; sqrt(b*b-4*a*c) in ST
4*a*c ST0
b*b ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1 .CODE main PROC
finit ; initialize FPU fld bb ; b in ST fmul bb ; b*b fild four ; 4.0 in ST fmul aa ; 4*a fmul cc ; 4*a*c fsub ; b*b-4*a*c fldz ; 0.0 in ST
fxch ; b*b-4*a*c in ST; 0.0 in ST(1)
fcom st(1) ; b*b-4*a*c >= 0 ?
fstsw ax ; copy condition code bits to AX
sahf ; shift condition code bits to flags
jnae endGE ; skip if not
fsqrt ; sqrt(b*b-4*a*c) in ST
b*b-4*a*c ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1 .CODE main PROC
finit ; initialize FPU fld bb ; b in ST fmul bb ; b*b fild four ; 4.0 in ST fmul aa ; 4*a fmul cc ; 4*a*c fsub ; b*b-4*a*c fldz ; 0.0 in ST fxch ; b*b-4*a*c in ST; 0.0 in ST(1)
fcom st(1) ; b*b-4*a*c >= 0 ?
fstsw ax ; copy condition code bits to AX
sahf ; shift condition code bits to flags
jnae endGE ; skip if not
fsqrt ; sqrt(b*b-4*a*c) in ST
0 ST0
b*b-4*a*c ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1 .CODE main PROC
finit ; initialize FPU fld bb ; b in ST fmul bb ; b*b fild four ; 4.0 in ST fmul aa ; 4*a fmul cc ; 4*a*c fsub ; b*b-4*a*c fldz ; 0.0 in ST fxch ; b*b-4*a*c in ST; 0.0 in ST(1) fcom st(1) ; b*b-4*a*c >= 0 ?
fstsw ax ; copy condition code bits to AX
sahf ; shift condition code bits to flags
jnae endGE ; skip if not
fsqrt ; sqrt(b*b-4*a*c) in ST
b*b-4*a*c ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1 .CODE main PROC
finit ; initialize FPU fld bb ; b in ST fmul bb ; b*b fild four ; 4.0 in ST fmul aa ; 4*a fmul cc ; 4*a*c fsub ; b*b-4*a*c fldz ; 0.0 in ST fxch ; b*b-4*a*c in ST; 0.0 in ST(1) fcom st(1) ; b*b-4*a*c >= 0 ? fstsw ax ; copy condition code bits to AX
sahf ; shift condition code bits to flags
jnae endGE ; skip if not
fsqrt ; sqrt(b*b-4*a*c) in ST
b*b-4*a*c ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1 .CODE main PROC
finit ; fld bb ; fmul bb ; fild four ; fmul aa ; fmul cc ; fsub ; fldz ; fxch ; b*b-4*a*c in ST; 0.0 in ST(1) fcom st(1) ; b*b-4*a*c >= 0 ? fstsw ax ; copy condition code bits to AX
sahf ; shift condition code bits to flags
jnae endGE ; skip if not
fsqrt ; sqrt(b*b-4*a*c) in ST
b*b-4*a*c ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
result of comparison
C3 (14)
C2 (10)
C0 (8)
ST > operand 0 0 0 ST < operand 0 0 1 ST = operand 1 0 0 not comparable 1 1 1
FP Program-Example 1 .CODE main PROC
finit ; fld bb ; fmul bb ; fild four ; fmul aa ; fmul cc ; fsub ; fldz ; fxch ; b*b-4*a*c in ST; 0.0 in ST(1) fcom st(1) ; b*b-4*a*c >= 0 ? fstsw ax ; copy condition code bits to AX sahf ; shift condition code bits to flags
jnae endGE ; skip if not
fsqrt ; sqrt(b*b-4*a*c) in ST
b*b-4*a*c ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
result of comparison
C3 (14)
C2 (10)
C0 (8)
ST > operand 0 0 0 ST < operand 0 0 1 ST = operand 1 0 0 not comparable 1 1 1
FP Program-Example 1 .CODE main PROC
finit ; fld bb ; fmul bb ; fild four ; fmul aa ; fmul cc ; fsub ; fldz ; fxch ; b*b-4*a*c in ST; 0.0 in ST(1) fcom st(1) ; b*b-4*a*c >= 0 ? fstsw ax ; copy condition code bits to AX sahf ; shift condition code bits to flags jnae endGE ; skip if not
b*b-4*a*c ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
result of comparison
C3 (14)
C2 (10)
C0 (8)
ST > operand 0 0 0 ST < operand 0 0 1 ST = operand 1 0 0 not comparable 1 1 1
sahf instruction puts C3 in the ZF position, C2 in the PF position, and C0 in the CF position.
FP Program-Example 1 .CODE main PROC
finit ; fld bb ; fmul bb ; fild four ; fmul aa ; fmul cc ; fsub ; fldz ; fxch ; b*b-4*a*c in ST; 0.0 in ST(1) fcom st(1) ; b*b-4*a*c >= 0 ? fstsw ax ; copy condition code bits to AX sahf ; shift condition code bits to flags jnae endGE ; skip if not
b*b-4*a*c ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
result of comparison
C3 (14)
C2 (10)
C0 (8)
ST > operand 0 0 0 ST < operand 0 0 1 ST = operand 1 0 0 not comparable 1 1 1
sahf instruction puts C3 in the ZF position, C2 in the PF position, and C0 in the CF position.
FP Program-Example 1
fsqrt ; sqrt(b*b-4*a*c) in ST
fst st(1) ; copy to ST(1)
fsub bb ; -b + sqrt(b*b-4*a*c)
fdiv aa ; (-b + sqrt(b*b-4*a*c))/a
fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x1 ; save and pop stack
fchs ; -sqrt(b*b-4*a*c)
fsub bb ; -b -sqrt(b*b-4*a*c)
fdiv aa ; (-b + sqrt(b*b-4*a*c))/a
fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x2 ; save and pop stack
endGE:
mov eax, 0 ; exit
ret
main ENDP
END 52
√b*b-4*a*c ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1
fsqrt ; sqrt(b*b-4*a*c) in ST
fst st(1) ; copy to ST(1) fsub bb ; -b + sqrt(b*b-4*a*c)
fdiv aa ; (-b + sqrt(b*b-4*a*c))/a
fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x1 ; save and pop stack
fchs ; -sqrt(b*b-4*a*c)
fsub bb ; -b -sqrt(b*b-4*a*c)
fdiv aa ; (-b + sqrt(b*b-4*a*c))/a
fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x2 ; save and pop stack
endGE:
mov eax, 0 ; exit
ret
main ENDP
END 53
√b*b-4*a*c ST0
√b*b-4*a*c ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1
fsqrt ; sqrt(b*b-4*a*c) in ST
fst st(1) ; copy to ST(1) fsub bb ; -b + sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a
fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x1 ; save and pop stack
fchs ; -sqrt(b*b-4*a*c)
fsub bb ; -b -sqrt(b*b-4*a*c)
fdiv aa ; (-b + sqrt(b*b-4*a*c))/a
fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x2 ; save and pop stack
endGE:
mov eax, 0 ; exit
ret
main ENDP
END 54
-b+√b*b-4*a*c ST0
√b*b-4*a*c ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1
fsqrt ; sqrt(b*b-4*a*c) in ST
fst st(1) ; copy to ST(1) fsub bb ; -b + sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x1 ; save and pop stack
fchs ; -sqrt(b*b-4*a*c)
fsub bb ; -b -sqrt(b*b-4*a*c)
fdiv aa ; (-b + sqrt(b*b-4*a*c))/a
fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x2 ; save and pop stack
endGE:
mov eax, 0 ; exit
ret
main ENDP
END 55
(-b+√b*b-4*a*c)/a ST0
√b*b-4*a*c ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1
fsqrt ; sqrt(b*b-4*a*c) in ST
fst st(1) ; copy to ST(1) fsub bb ; -b + sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a) fstp x1 ; save and pop stack
fchs ; -sqrt(b*b-4*a*c)
fsub bb ; -b -sqrt(b*b-4*a*c)
fdiv aa ; (-b + sqrt(b*b-4*a*c))/a
fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x2 ; save and pop stack
endGE:
mov eax, 0 ; exit
ret
main ENDP
END 56
(-b+√b*b-4*a*c)/2*a ST0
√b*b-4*a*c ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
FP Program-Example 1
fsqrt ; sqrt(b*b-4*a*c) in ST
fst st(1) ; copy to ST(1) fsub bb ; -b + sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a) fstp x1 ; save and pop stack fchs ; -sqrt(b*b-4*a*c)
fsub bb ; -b -sqrt(b*b-4*a*c)
fdiv aa ; (-b + sqrt(b*b-4*a*c))/a
fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x2 ; save and pop stack
endGE:
mov eax, 0 ; exit
ret
main ENDP
END 57
√b*b-4*a*c ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
X1=(-b+√b*b-4*a*c)/2*a
FP Program-Example 1
fsqrt ; sqrt(b*b-4*a*c) in ST
fst st(1) ; copy to ST(1) fsub bb ; -b + sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a) fstp x1 ; save and pop stack fchs ; -sqrt(b*b-4*a*c) fsub bb ; -b -sqrt(b*b-4*a*c)
fdiv aa ; (-b + sqrt(b*b-4*a*c))/a
fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x2 ; save and pop stack
endGE:
mov eax, 0 ; exit
ret
main ENDP
END 58
-√b*b-4*a*c ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
X1=(-b+√b*b-4*a*c)/2*a
FP Program-Example 1
fsqrt ; sqrt(b*b-4*a*c) in ST
fst st(1) ; copy to ST(1) fsub bb ; -b + sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a) fstp x1 ; save and pop stack fchs ; -sqrt(b*b-4*a*c) fsub bb ; -b -sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a
fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x2 ; save and pop stack
endGE:
mov eax, 0 ; exit
ret
main ENDP
END 59
-b-√b*b-4*a*c ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
X1=(-b+√b*b-4*a*c)/2*a
FP Program-Example 1
fsqrt ; sqrt(b*b-4*a*c) in ST
fst st(1) ; copy to ST(1) fsub bb ; -b + sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a) fstp x1 ; save and pop stack fchs ; -sqrt(b*b-4*a*c) fsub bb ; -b -sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x2 ; save and pop stack
endGE:
mov eax, 0 ; exit
ret
main ENDP
END 60
(-b-√b*b-4*a*c)/a ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
X1=(-b+√b*b-4*a*c)/2*a
FP Program-Example 1
fsqrt ; sqrt(b*b-4*a*c) in ST
fst st(1) ; copy to ST(1) fsub bb ; -b + sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a) fstp x1 ; save and pop stack fchs ; -sqrt(b*b-4*a*c) fsub bb ; -b -sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a)
fstp x2 ; save and pop stack
endGE:
mov eax, 0 ; exit
ret
main ENDP
END 61
(-b-√b*b-4*a*c)/a ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
X1=(-b+√b*b-4*a*c)/2*a
FP Program-Example 1
fsqrt ; sqrt(b*b-4*a*c) in ST
fst st(1) ; copy to ST(1) fsub bb ; -b + sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a) fstp x1 ; save and pop stack fchs ; -sqrt(b*b-4*a*c) fsub bb ; -b -sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a) fstp x2 ; save and pop stack
endGE:
mov eax, 0 ; exit
ret
main ENDP
END 62
(-b-√b*b-4*a*c)/2*a ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
X1=(-b+√b*b-4*a*c)/2*a
FP Program-Example 1
fsqrt ; sqrt(b*b-4*a*c) in ST
fst st(1) ; copy to ST(1) fsub bb ; -b + sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a) fstp x1 ; save and pop stack fchs ; -sqrt(b*b-4*a*c) fsub bb ; -b -sqrt(b*b-4*a*c) fdiv aa ; (-b + sqrt(b*b-4*a*c))/a fidiv two ; (-b + sqrt(b*b-4*a*c))/(2*a) fstp x2 ; save and pop stack endGE:
mov eax, 0 ; exit
ret
main ENDP
END 63
0
ST0
0 ST1 0 ST2 0 ST3 0 ST4 0 ST5 0 ST6 0 ST7
X1=(-b+√b*b-4*a*c)/2*a X2=(-b-√b*b-4*a*c)/2*a