1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 .file "polynomial_Xsig.S"
25
26 #include "fpu_asm.h"
27
28
29 #define TERM_SIZE $8
30 #define SUM_MS -20(%ebp)
31 #define SUM_MIDDLE -24(%ebp)
32 #define SUM_LS -28(%ebp)
33 #define ACCUM_MS -4(%ebp)
34 #define ACCUM_MIDDLE -8(%ebp)
35 #define ACCUM_LS -12(%ebp)
36 #define OVERFLOWED -16(%ebp)
37
38 .text
39 ENTRY(polynomial_Xsig)
40 pushl %ebp
41 movl %esp,%ebp
42 subl $32,%esp
43 pushl %esi
44 pushl %edi
45 pushl %ebx
46
47 movl PARAM2,%esi
48 movl PARAM3,%edi
49
50 movl TERM_SIZE,%eax
51 mull PARAM4
52 addl %eax,%edi
53
54 movl 4(%edi),%edx
55 movl %edx,SUM_MS
56 movl (%edi),%edx
57 movl %edx,SUM_MIDDLE
58 xor %eax,%eax
59 movl %eax,SUM_LS
60 movb %al,OVERFLOWED
61
62 subl TERM_SIZE,%edi
63 decl PARAM4
64 js L_accum_done
65
66 L_accum_loop:
67 xor %eax,%eax
68 movl %eax,ACCUM_MS
69 movl %eax,ACCUM_MIDDLE
70
71 movl SUM_MIDDLE,%eax
72 mull (%esi)
73 movl %edx,ACCUM_LS
74
75 movl SUM_MIDDLE,%eax
76 mull 4(%esi)
77 addl %eax,ACCUM_LS
78 adcl %edx,ACCUM_MIDDLE
79 adcl $0,ACCUM_MS
80
81 movl SUM_MS,%eax
82 mull (%esi)
83 addl %eax,ACCUM_LS
84 adcl %edx,ACCUM_MIDDLE
85 adcl $0,ACCUM_MS
86
87 movl SUM_MS,%eax
88 mull 4(%esi)
89 addl %eax,ACCUM_MIDDLE
90 adcl %edx,ACCUM_MS
91
92 testb $0xff,OVERFLOWED
93 jz L_no_overflow
94
95 movl (%esi),%eax
96 addl %eax,ACCUM_MIDDLE
97 movl 4(%esi),%eax
98 adcl %eax,ACCUM_MS
99
100 L_no_overflow:
101
102
103
104
105
106 movl ACCUM_LS,%eax
107 addl (%edi),%eax
108 movl %eax,SUM_LS
109 movl ACCUM_MIDDLE,%eax
110 adcl (%edi),%eax
111 movl %eax,SUM_MIDDLE
112 movl ACCUM_MS,%eax
113 adcl 4(%edi),%eax
114 movl %eax,SUM_MS
115 sbbb %al,%al
116 movb %al,OVERFLOWED
117
118 subl TERM_SIZE,%edi
119 decl PARAM4
120 jns L_accum_loop
121
122 L_accum_done:
123 movl PARAM1,%edi
124 movl SUM_LS,%eax
125 addl %eax,(%edi)
126 movl SUM_MIDDLE,%eax
127 adcl %eax,4(%edi)
128 movl SUM_MS,%eax
129 adcl %eax,8(%edi)
130
131 popl %ebx
132 popl %edi
133 popl %esi
134 leave
135 ret