Chapter14 - THE ARITHMETIC COPROCESSOR, MMX, AND SIMD TECHNOLOGIES
Chapter14 - THE ARITHMETIC COPROCESSOR, MMX, AND SIMD TECHNOLOGIES
Chapter14 - THE ARITHMETIC COPROCESSOR, MMX, AND SIMD TECHNOLOGIES
SIMID Technologies
Introduction
• The Intel family of arithmetic coprocessors
includes the 8087, 80287, 80387SX, 80387DX,
and 80487SX for use
with the 80486SX microprocessor.
• This chapter provides detail on the entire
family of arithmetic coprocessors.
• Many programs now require or at least
benefit from a coprocessor.
IE
• An invalid error indicates a stack overflow or
underflow, indeterminate form (0 ÷ 0, +∞, –∞,
etc.), or use of a NAN as an operand.
– indicates errors such as produced by taking the
square root of a negative number, etc.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
Control Register
• The control register selects the precision,
rounding control, and infinity control.
– also masks and unmasks exception bits
corresponding to the rightmost 6 bits of
the status register
• FLDCW is used to load a value into the
control register.
RC
• Rounding control determines the type of
rounding, as defined in Figure 14–6.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
Control Register Bits
PC
• The precision control sets the precision
of the result, as defined in Figure 14–6.
Exception Masks
• Determine whether the error indicated by the
exception affects the error bit in the status
register.
– if logic 1 is placed in an exception control bits,
the corresponding status register bit is masked
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
Figure 14–6 The 80X87 arithmetic coprocessor control register.
FABS
• Changes the sign of the top of the stack to
positive.
FCHS
• Changes the sign from positive to negative
or negative to positive.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
Comparison Instructions
• Examine data at the top of the stack in
relation to another element and return
the result of the comparison in the status
register condition code bits C3–C0.
FCOM
• Compares the floating-point data at the top
of the stack with an operand, which may be
any register or any memory operand.
– if not coded with the instruction, the next stack
element ST(1) is compared with the stack top ST
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
Comparison Instructions
FCOMP/FCOMPP
• Both perform as FCOM, but also pop one
or two data from the stack.
FICOM/FICOMP
• The top of the stack is compared with the
integer stored at a memory operand.
– FICOMP also pops the top of the stack
FSINCOS
• Finds sine and cosine of ST, expressed in
radians, and leaves results as ST = sine and
ST(1) = cosine.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
Transcendental Operations
FYL2X
• Finds Y log2 X.
– value X is taken from the stack top
– Y is taken from ST(1)
• Result is found at the stack top after a pop.
– value of X must range between 0 and ∞
– value of Y must be between –∞ and +∞
• A logarithm with any positive base (b) is found
by equation LOGb X = (LOG2 b)–1 LOG2 X.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
Transcendental Operations
FYL2P1
• Finds Finds Y log2 (X + 1).
• The value of X is taken from the stack top
and Y is taken from ST(1).
• The result is found at the top of the stack
after a pop.
FSTCW
• Stores the control register into the
word-sized memory operand.
FCLEX
• Clears the error flags in the status register
and also the busy flag.
FRSTOR
• Restores the state of the machine from
memory. This instruction is used to restore
the information saved by FSAVE.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
Figure 14–8 Memory format when the 80X87 registers are saved with the FSAVE
instruction.
FLDENV
• Reloads the environment saved by FSTENV.
FINCSP
• Increments the stack pointer.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
Figure 14–9 Memory format for the FSTENV instruction: (a) real mode and (b)
protected mode.
FFREE
• Frees a register by changing the destination
register’s tag to empty.
– does not affect the contents of the register
FWAIT
• Causes the microprocessor to wait for the
coprocessor to finish an operation.
– should be used before the microprocessor
accesses memory data affected by the
coprocessor
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
Coprocessor Instructions
• Newer coprocessors contain the same basic
instructions provided by earlier versions, with
a few additional instructions
• 80387-Core2 contain additional instructions:
– FCOS (cosine)
– FPREM1 (partial remainder)
– FSIN (sine)
– FSINCOS (sine and cosine)
– FUCOM/FUCOMP/FUCOMPP (unordered
compare)
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
14–4 Programming with the
Arithmetic Coprocessor
• This section provides programming
examples for the arithmetic coprocessor.
• Each example is chosen to illustrate a
programming technique for the coprocessor.