-
Notifications
You must be signed in to change notification settings - Fork 0
/
math.s
59 lines (52 loc) · 870 Bytes
/
math.s
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
; See LICENSE file for copyright and license details.
%ifndef MATH_S
%define MATH_S
%macro COS 1
movsd [tmp0], %1
fld qword [tmp0]
fcos
fstp qword [tmp0]
movsd %1, [tmp0]
%endmacro
%macro SIN 1
movsd [tmp0], %1
fld qword [tmp0]
fsin
fstp qword [tmp0]
movsd %1, [tmp0]
%endmacro
%macro ACOS 1 ;acos(x) = atan(sqrt((1-x*x)/(x*x)))
movsd [tmp0], %1
fld qword [tmp0]
fld st0
fmul st0, st1
fld1
fsubrp st1, st0
fsqrt
fxch
fpatan
fstp qword [tmp0]
movsd %1, [tmp0]
%endmacro
%macro ASIN 1 ;asin(x) = atan(sqrt(x*x/(1-x*x)))
movsd [tmp0], %1
fld qword [tmp0]
fld st0
fmul st0, st1
fld1
fsubrp st1, st0
fsqrt
fpatan
fstp qword [tmp0]
movsd %1, [tmp0]
%endmacro
%macro ATAN2 2
movsd [tmp0], %1
movsd [tmp1], %2
fld qword [tmp0] ;x
fld qword [tmp1] ;y
fpatan
fstp qword [tmp0]
movsd %1, [tmp0]
%endmacro
%endif ;MATH_S