this repo has no description
1/*
2 * Written by Ian Ollmann
3 *
4 * Copyright � 2005, Apple Computer. All rights reserved.
5 */
6
7#include <machine/asm.h>
8
9#define LOCAL_STACK_SIZE 4
10#include "abi.h"
11
12
13ENTRY(ilogbl)
14 SUBP $LOCAL_STACK_SIZE, STACKP
15 movl $0x4f000000, (STACKP) // 0x1.0p31
16 flds (STACKP) // { 0x1.0p31 }
17 fldt FIRST_ARG_OFFSET(STACKP) // { x, 0x1.0p31 }
18 fldz // { 0, x, 0x1.0p31 }
19 fucomip %st(1), %st(0) // { x, 0x1.0p31 } if( x == 0 or NaN )
20 fcmove %st(1), %st(0) // { x or 0x1.0p31, 0x1.0p31 } then x = 0x1.0p31 //avoids div/0 for fxtract(0)
21 fxtract // { sig, exp, 0x1.0p31 }
22 fstp %st(0) // { exp, 0x1.0p31 }
23 fcmove %st(1), %st(0) // { exp or 0x1.0p31, 0x1.0p31 } if( x == 0 or NaN ) then exp = 0x1.0p31 //set to overflow
24 movl $0x7fffffff, %edx // load the inf result
25 fucomi %st(1), %st(0) // compare exp with 0x1.0p31. Only inf inputs will have exponents that test > 0x1.0p31.
26 fistpl (STACKP) // convert exponent to int. Set invalid if input was zero, NaN or Inf
27 fstp %st(0) // { }
28 movl (STACKP), %eax // load result into eax
29 cmova %edx, %eax // patch up Inf result to return 0x7fffffff instead
30 ADDP $LOCAL_STACK_SIZE, STACKP
31 ret
32