Initial revision
[AROS-Contrib.git] / development / compilers / freepascal / rtl / go32v2 / fpu.as
blobc9d4cb37fc66cf8545b11326af9a3eef1b767e83
1 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
2 /* Translated from tasm to GAS by C. Sandmann */
3 /* One comment displaced to get it compiled by as.exe directly !!! */
4 /* by Pierre Muller */
6 /* This routine assumes DS == SS since [ESI] coding shorter than [EBP] coding */
8 .global __detect_80387 /* direct from the Intel manual */
9 __detect_80387: /* returns 1 if 387 (or more), else 0 */
10 pushl %esi
11 pushl %eax /* Dummy work area on stack */
12 movl %esp,%esi
13 fninit
14 movw $0x5a5a,(%esi)
15 fnstsw (%esi)
16 cmpb $0,(%esi)
17 jne Lno_387
19 fnstcw (%esi)
20 movl (%esi),%eax /* Only ax significant */
21 andl $0x103f,%eax
22 cmpl $0x3f,%eax
23 jne Lno_387
25 fld1
26 fldz
27 /* fdiv GAS encodes this as 0xdcf1 !! BUG */
28 .byte 0xde,0xf9
29 fld %st
30 fchs
31 fcompp
32 fstsw (%esi)
33 movzwl (%esi),%eax /* Clears upper %eax */
34 sahf
35 je Lno_387
36 fninit /* 387 present, initialize. */
37 fnstcw (%esi)
38 wait
39 andw $0x0fffa,(%esi)
40 /* enable invalid operation exception */
41 fldcw (%esi)
42 movw $1,%eax
43 jmp Lexit
44 Lno_387:
45 xorl %eax,%eax
46 Lexit:
47 popl %esi /* Fix stack first */
48 popl %esi
49 ret