6b13f685e
김민수
BSP 최초 추가
|
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#ifndef _POLY_H
#define _POLY_H
typedef struct {
unsigned long lsw;
unsigned long midw;
unsigned long msw;
} Xsig;
asmlinkage void mul64(unsigned long long const *a, unsigned long long const *b,
unsigned long long *result);
asmlinkage void polynomial_Xsig(Xsig *, const unsigned long long *x,
const unsigned long long terms[], const int n);
asmlinkage void mul32_Xsig(Xsig *, const unsigned long mult);
asmlinkage void mul64_Xsig(Xsig *, const unsigned long long *mult);
asmlinkage void mul_Xsig_Xsig(Xsig *dest, const Xsig *mult);
asmlinkage void shr_Xsig(Xsig *, const int n);
asmlinkage int round_Xsig(Xsig *);
asmlinkage int norm_Xsig(Xsig *);
asmlinkage void div_Xsig(Xsig *x1, const Xsig *x2, const Xsig *dest);
#define LL_MSW(x) (((unsigned long *)&x)[1])
#define MK_XSIG(a,b,c) { c, b, a }
#define XSIG_LL(x) (*(unsigned long long *)&x.midw)
static inline unsigned long mul_32_32(const unsigned long arg1,
const unsigned long arg2)
{
int retval;
asm volatile ("mull %2; movl %%edx,%%eax":"=a" (retval)
:"0"(arg1), "g"(arg2)
:"dx");
return retval;
}
static inline void add_Xsig_Xsig(Xsig *dest, const Xsig *x2)
{
asm volatile ("movl %1,%%edi; movl %2,%%esi;
"
"movl (%%esi),%%eax; addl %%eax,(%%edi);
"
"movl 4(%%esi),%%eax; adcl %%eax,4(%%edi);
"
"movl 8(%%esi),%%eax; adcl %%eax,8(%%edi);
":"=g"
(*dest):"g"(dest), "g"(x2)
:"ax", "si", "di");
}
static inline void add_two_Xsig(Xsig *dest, const Xsig *x2, long int *exp)
{
asm volatile ("movl %2,%%ecx; movl %3,%%esi;
"
"movl (%%esi),%%eax; addl %%eax,(%%ecx);
"
"movl 4(%%esi),%%eax; adcl %%eax,4(%%ecx);
"
"movl 8(%%esi),%%eax; adcl %%eax,8(%%ecx);
"
"jnc 0f;
"
"rcrl 8(%%ecx); rcrl 4(%%ecx); rcrl (%%ecx)
"
"movl %4,%%ecx; incl (%%ecx)
"
"movl $1,%%eax; jmp 1f;
"
"0: xorl %%eax,%%eax;
" "1:
":"=g" (*exp), "=g"(*dest)
:"g"(dest), "g"(x2), "g"(exp)
:"cx", "si", "ax");
}
static inline void negate_Xsig(Xsig *x)
{
asm volatile ("movl %1,%%esi;
"
"xorl %%ecx,%%ecx;
"
"movl %%ecx,%%eax; subl (%%esi),%%eax; movl %%eax,(%%esi);
"
"movl %%ecx,%%eax; sbbl 4(%%esi),%%eax; movl %%eax,4(%%esi);
"
"movl %%ecx,%%eax; sbbl 8(%%esi),%%eax; movl %%eax,8(%%esi);
":"=g"
(*x):"g"(x):"si", "ax", "cx");
}
#endif /* _POLY_H */
|