~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to gmp3/mpn/x86/mod_34lsub1.asm

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl  Generic x86 mpn_mod_32lsub1 -- mpn remainder modulo 2^24-1.
 
2
dnl
 
3
dnl       cycles/limb
 
4
dnl  P5:     3.0
 
5
dnl  P6:     3.66
 
6
dnl  K6:     3.0
 
7
dnl  K7:     1.3
 
8
dnl  P4:     9
 
9
 
 
10
dnl  Copyright 2000, 2001 Free Software Foundation, Inc.
 
11
dnl
 
12
dnl  This file is part of the GNU MP Library.
 
13
dnl
 
14
dnl  The GNU MP Library is free software; you can redistribute it and/or
 
15
dnl  modify it under the terms of the GNU Lesser General Public License as
 
16
dnl  published by the Free Software Foundation; either version 2.1 of the
 
17
dnl  License, or (at your option) any later version.
 
18
dnl
 
19
dnl  The GNU MP Library is distributed in the hope that it will be useful,
 
20
dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
21
dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
22
dnl  Lesser General Public License for more details.
 
23
dnl
 
24
dnl  You should have received a copy of the GNU Lesser General Public
 
25
dnl  License along with the GNU MP Library; see the file COPYING.LIB.  If
 
26
dnl  not, write to the Free Software Foundation, Inc., 59 Temple Place -
 
27
dnl  Suite 330, Boston, MA 02111-1307, USA.
 
28
 
 
29
include(`../config.m4')
 
30
 
 
31
 
 
32
C mp_limb_t mpn_mod_34lsub1 (mp_srcptr src, mp_size_t size)
 
33
C
 
34
 
 
35
defframe(PARAM_SIZE, 8)
 
36
defframe(PARAM_SRC,  4)
 
37
 
 
38
dnl  re-use parameter space
 
39
define(SAVE_EBX, `PARAM_SRC')
 
40
 
 
41
        TEXT
 
42
        ALIGN(16)
 
43
PROLOGUE(mpn_mod_34lsub1)
 
44
deflit(`FRAME',0)
 
45
 
 
46
        movl    PARAM_SIZE, %ecx
 
47
        movl    PARAM_SRC, %edx
 
48
 
 
49
        subl    $2, %ecx
 
50
        ja      L(three_or_more)
 
51
 
 
52
        movl    (%edx), %eax
 
53
        jb      L(one)
 
54
 
 
55
        movl    4(%edx), %ecx
 
56
        movl    %eax, %edx
 
57
        shrl    $24, %eax               C src[0] low
 
58
 
 
59
        andl    $0xFFFFFF, %edx         C src[0] high
 
60
        addl    %edx, %eax
 
61
        movl    %ecx, %edx
 
62
 
 
63
        andl    $0xFFFF, %ecx
 
64
        shrl    $16, %edx               C src[1] high
 
65
        addl    %edx, %eax
 
66
 
 
67
        shll    $8, %ecx                C src[1] low
 
68
        addl    %ecx, %eax
 
69
 
 
70
L(one):
 
71
        ret
 
72
 
 
73
 
 
74
L(three_or_more):
 
75
        C eax
 
76
        C ebx
 
77
        C ecx   size-2
 
78
        C edx   src
 
79
        C esi
 
80
        C edi
 
81
        C ebp
 
82
 
 
83
        movl    %ebx, SAVE_EBX          C and arrange 16-byte loop alignment
 
84
        xorl    %ebx, %ebx
 
85
 
 
86
        pushl   %esi    FRAME_pushl()
 
87
        xorl    %esi, %esi
 
88
 
 
89
        pushl   %edi    FRAME_pushl()
 
90
        xorl    %eax, %eax              C and clear carry flag
 
91
 
 
92
 
 
93
        C offset 0x40 here
 
94
L(top):
 
95
        C eax   acc 0mod3
 
96
        C ebx   acc 1mod3
 
97
        C ecx   counter, limbs
 
98
        C edx   src
 
99
        C esi   acc 2mod3
 
100
        C edi
 
101
        C ebp
 
102
 
 
103
        leal    12(%edx), %edx
 
104
        leal    -2(%ecx), %ecx
 
105
 
 
106
        adcl    -12(%edx), %eax
 
107
        adcl    -8(%edx), %ebx
 
108
        adcl    -4(%edx), %esi
 
109
 
 
110
        decl    %ecx
 
111
        jg      L(top)
 
112
 
 
113
 
 
114
        C ecx is -2, -1 or 0 representing 0, 1 or 2 more limbs, respectively
 
115
 
 
116
        movl    $0xFFFFFFFF, %edi
 
117
        incl    %ecx
 
118
        js      L(combine)
 
119
 
 
120
        adcl    (%edx), %eax
 
121
        movl    $0xFFFFFF00, %edi
 
122
        decl    %ecx
 
123
        js      L(combine)
 
124
 
 
125
        adcl    4(%edx), %ebx
 
126
        movl    $0xFFFF0000, %edi
 
127
 
 
128
 
 
129
L(combine):
 
130
        C eax   acc 0mod3
 
131
        C ebx   acc 1mod3
 
132
        C ecx
 
133
        C edx
 
134
        C esi   acc 2mod3
 
135
        C edi   mask
 
136
        C ebp
 
137
 
 
138
        sbbl    %ecx, %ecx              C carry
 
139
        movl    %eax, %edx              C 0mod3
 
140
 
 
141
        shrl    $24, %eax               C 0mod3 high
 
142
        andl    %edi, %ecx              C carry masked
 
143
 
 
144
        subl    %ecx, %eax              C apply carry
 
145
        movl    %ebx, %edi              C 1mod3
 
146
 
 
147
        shrl    $16, %ebx               C 1mod3 high
 
148
        andl    $0x00FFFFFF, %edx       C 0mod3 low
 
149
 
 
150
        addl    %edx, %eax              C apply 0mod3 low
 
151
        andl    $0xFFFF, %edi
 
152
 
 
153
        shll    $8, %edi                C 1mod3 low
 
154
        addl    %ebx, %eax              C apply 1mod3 high
 
155
 
 
156
        addl    %edi, %eax              C apply 1mod3 low
 
157
        movl    %esi, %edx              C 2mod3
 
158
 
 
159
        shrl    $8, %esi                C 2mod3 high
 
160
        andl    $0xFF, %edx             C 2mod3 low
 
161
 
 
162
        shll    $16, %edx               C 2mod3 low
 
163
        addl    %esi, %eax              C apply 2mod3 high
 
164
 
 
165
        addl    %edx, %eax              C apply 2mod3 low
 
166
        popl    %edi    FRAME_popl()
 
167
 
 
168
        movl    SAVE_EBX, %ebx
 
169
        popl    %esi    FRAME_popl()
 
170
 
 
171
        ret
 
172
 
 
173
EPILOGUE()