IA-32 Assembly Language Reference Manual

Division Instructions

Divide Real (fdiv)

fdiv{ls}
Example

Divide stack element 0 by stack element 7 and return the result to stack element 0.

fdiv %st(7), %st

Divide Real and Pop (fdivp)

fdivp	
Example

Divide stack element 7 by stack element 0 and return the result to stack element 7, then pop the stack.

fdivp %st, %st(7)

Divide Real Reversed (fdivr)

fdivr{ls}
Example

Divide stack element 0 by stack element 7 and return the result to stack element 7.

fdivr %st, %st(7)

Divide Real Reversed and Pop (fdivrp)

fdivrp	
Example

Divide stack element 0 by stack element 7 and return the result to stack element 7, then pop the stack.

fdivrp %st, %st(7)

Integer Divide (fidiv)

fidiv{l}	  
Example

Divide stack element 0 by the integer contents of register ECX, with an offset of 2, and return the result to register ECX.

fidiv 2(%ecx)

Integer Divide Reversed (fidivr)

fidivr{l}	
Example

Divide the integer contents of register ECX, with an offset of 2, by stack element 0 and return the result to stack element 0.

fidivr 2(%ecx) 

Floating-Point Opcode Errors


Caution - Caution -

The IA-32 Assembler generates the wrong object code for some of the floating-point opcodes fsub, fsubr, fdiv, and fdivr when there are two floating register operands, and the second op destination is not the zeroth floating-point register. This error has been made in many IA-32 assemblers and would probably cause problems if it were fixed.


Replace the following instructions, in column 1, with their substitutions, in column 2, for IA-32 platforms:

Table 2-11 Floating-point Opcodes

fsub %st,%st(n) 

fsubr %st, %st(n) 

fsubp %st,%st(n) 

fsubrp %st, %st(n) 

fsub  

fsubr 

fsubr %st,%st(n) 

fsub %st, %st(n) 

fsubrp %st,%st(n) 

fsubp %st, %st(n) 

fsubr 

fsub 

fdiv %st,%st(n) 

fdivr %st,%st(n) 

fdivp %st,%st(n) 

fdivrp %st,%st(n) 

fdiv 

fdivr 

fdivr %st, %st(n) 

fdvir %st, %st(n) 

fdivrp %st, %st(n) 

fdivp %st, %st(n) 

fdivr 

fdiv