expl.s 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
.global expm1l
.type expm1l,@function
expm1l:
	fldt 8(%rsp)
1:	fldl2e
	fmulp
	fld1
	fld %st(1)
	fabs
	fucom %st(1)
	fnstsw %ax
	fstp %st(0)
	fstp %st(0)
	sahf
	ja 1f
	f2xm1
	ret
1:	push %rax
	call 1f
	pop %rax
	fld1
	fsubrp
	ret

.global expl
.type expl,@function
expl:
	fldt 8(%rsp)
	fldl2e
	fmulp
	jmp 1f

.global exp2l
.type exp2l,@function
exp2l:
	fldt 8(%rsp)
1:	mov $0x467ff000,%eax
	mov %eax,-16(%rsp)
	mov $0x80000000,%eax
	mov %eax,-20(%rsp)
	xor %eax,%eax
	mov %eax,-24(%rsp)
43
	flds -16(%rsp)    # 16380
44 45 46 47 48 49 50
	fld %st(1)
	fabs
	fucom %st(1)
	fnstsw
	fstp %st(0)
	fstp %st(0)
	sahf
51 52
	ja 3f             # |x| > 16380
	jp 2f             # x is nan (avoid invalid except in fistp)
53 54 55 56 57 58 59 60 61
	fld %st(0)
	fistpl -16(%rsp)
	fildl -16(%rsp)
	fxch %st(1)
	fsub %st(1)
	mov $0x3fff,%eax
	add %eax,-16(%rsp)
	f2xm1
	fld1
62 63
	faddp             # 2^(x-rint(x))
	fldt -24(%rsp)    # 2^rint(x)
64
	fmulp
65
2:	fstp %st(1)
66 67
	ret

68
3:	fld %st(0)
69
	fstpt -24(%rsp)
70 71 72 73 74 75
	fld1
	mov -15(%rsp),%ax
	and $0x7fff,%ax
	cmp $0x7fff,%ax
	je 1f             # x = +-inf
	fld %st(1)
76
	frndint
77 78
	fxch %st(2)
	fsub %st(2)       # st(0)=x-rint(x), st(1)=1, st(2)=rint(x)
79
	f2xm1
80 81
	faddp             # 2^(x-rint(x))
1:	fscale
82 83
	fstp %st(1)
	ret