Tizen 2.1 base
[external/gmp.git] / mpn / x86 / bdiv_dbm1c.asm
1 dnl  x86 mpn_bdiv_dbm1.
2
3 dnl  Copyright 2008 Free Software Foundation, Inc.
4
5 dnl  This file is part of the GNU MP Library.
6
7 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl  it under the terms of the GNU Lesser General Public License as published
9 dnl  by the Free Software Foundation; either version 3 of the License, or (at
10 dnl  your option) any later version.
11
12 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15 dnl  License for more details.
16
17 dnl  You should have received a copy of the GNU Lesser General Public License
18 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20 include(`../config.m4')
21
22 C           cycles/limb
23 C K7:            3.5
24 C P4 m0:          ?
25 C P4 m1:          ?
26 C P4 m2:        13.67
27 C P4 m3:          ?
28 C P4 m4:          ?
29 C P6-13:         5.1
30
31 C TODO
32 C  * Optimize for more x86 processors
33
34 ASM_START()
35         TEXT
36         ALIGN(16)
37 PROLOGUE(mpn_bdiv_dbm1c)
38         mov     16(%esp), %ecx          C d
39         push    %esi
40         mov     12(%esp), %esi          C ap
41         push    %edi
42         mov     12(%esp), %edi          C qp
43         push    %ebp
44         mov     24(%esp), %ebp          C n
45         push    %ebx
46
47         mov     (%esi), %eax
48         mul     %ecx
49         mov     36(%esp), %ebx
50         sub     %eax, %ebx
51         mov     %ebx, (%edi)
52         sbb     %edx, %ebx
53
54         mov     %ebp, %eax
55         and     $3, %eax
56         jz      L(b0)
57         cmp     $2, %eax
58         jc      L(b1)
59         jz      L(b2)
60         jmp     L(b3)
61
62 L(b0):  mov     4(%esi), %eax
63         lea     -4(%esi), %esi
64         lea     12(%edi), %edi
65         add     $-4, %ebp
66         jmp     L(0)
67 L(b3):
68         lea     -8(%esi), %esi
69         lea     8(%edi), %edi
70         add     $-3, %ebp
71         jmp     L(3)
72
73 L(b2):  mov     4(%esi), %eax
74         lea     4(%esi), %esi
75         lea     4(%edi), %edi
76         add     $-2, %ebp
77         jmp     L(2)
78
79         ALIGN(8)
80 L(top):
81         mov     4(%esi), %eax
82         mul     %ecx
83         lea     16(%edi), %edi
84         sub     %eax, %ebx
85         mov     8(%esi), %eax
86         mov     %ebx, -12(%edi)
87         sbb     %edx, %ebx
88 L(0):   mul     %ecx
89         sub     %eax, %ebx
90         mov     %ebx, -8(%edi)
91         sbb     %edx, %ebx
92 L(3):   mov     12(%esi), %eax
93         mul     %ecx
94         sub     %eax, %ebx
95         mov     %ebx, -4(%edi)
96         mov     16(%esi), %eax
97         lea     16(%esi), %esi
98         sbb     %edx, %ebx
99 L(2):   mul     %ecx
100         sub     %eax, %ebx
101         mov     %ebx, 0(%edi)
102         sbb     %edx, %ebx
103 L(b1):  add     $-4, %ebp
104         jns     L(top)
105
106         mov     %ebx, %eax
107         pop     %ebx
108         pop     %ebp
109         pop     %edi
110         pop     %esi
111         ret
112 EPILOGUE()