== begin of div.c ==
int main()
{
        asm(
                "fdivp;"
        );
}
== end of div.c ==

if compiled
===============
$ gcc div.c
$ gdb a.out
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-pc-nto-qnx6.3.0"...(no debugging symbols
found)

(gdb) disas main
Dump of assembler code for function main:
0x080483ac <main+0>:    push   %ebp
0x080483ad <main+1>:    mov    %esp,%ebp
0x080483af <main+3>:    sub    $0x8,%esp
0x080483b2 <main+6>:    and    $0xfffffff0,%esp
0x080483b5 <main+9>:    mov    $0x0,%eax
0x080483ba <main+14>:   sub    %eax,%esp
0x080483bc <main+16>:   fdivp  %st,%st(1)
0x080483be <main+18>:   leave
0x080483bf <main+19>:   ret
End of assembler dump.
(gdb) x/2b 0x080483bc
0x80483bc <main+16>:    0xde    0xf1
(gdb)
===============
it generates 0xde 0xf1 opcode sequence. 
Accordingly to 25366614.pdf (IA-32 Intel® Architecture Software Developer’s
Manual Volume 2A) distrubuted at Intel website this opcode sequence stands for
fdivrp assembler instruction
======== begin of 25366614.pdf, page 3-237 =======
DE F1 FDIVRP Divide ST(0) by ST(1), store result in ST(1), and pop the
register stack
======== end of 25366614.pdf, page 3-237 =======
which produces ST(0)/ST(1) result, while fdivp is expected to have opcode
sequence of 0xde 0xf9 and to produce ST(1)/ST(0).
======== begin of 25366614.pdf, page 3-234 =======
DE F9 FDIVP Divide ST(1) by ST(0), store result in ST(1), and pop the
register stack.
======== end of 25366614.pdf, page 3-234 =======


-- 
           Summary: fdivp assembler instruction compiles to fdivrp
           Product: gcc
           Version: 3.3.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: inline-asm
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: oder at eleks dot lviv dot ua
 GCC build triplet: x86
  GCC host triplet: x86
GCC target triplet: x86


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30117

Reply via email to