Debian Codegraph @

msvc/gmp/mpn/x86i/dive_1.asm

raw
1
2 ; Copyright 2001, 2002 Free Software Foundation, Inc.
3 ;
4 ; This file is part of the GNU MP Library.
5 ;
6 ; The GNU MP Library is free software; you can redistribute it and/or
7 ; modify it under the terms of the GNU Lesser General Public License as
8 ; published by the Free Software Foundation; either version 2.1 of the
9 ; License, or (at your option) any later version.
10 ;
11 ; The GNU MP Library is distributed in the hope that it will be useful,
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ; Lesser General Public License for more details.
15 ;
16 ; You should have received a copy of the GNU Lesser General Public
17 ; License along with the GNU MP Library; see the file COPYING.LIB. If
18 ; not, write to the Free Software Foundation, Inc., 59 Temple Place -
19 ; Suite 330, Boston, MA 02111-1307, USA.
20 ;
21 ; Translation of AT&T syntax code by Brian Gladman
22
23 %include "x86i.inc"
24
25 %define PARAM_DIVISOR esp+frame+16
26 %define PARAM_SIZE esp+frame+12
27 %define PARAM_SRC esp+frame+8
28 %define PARAM_DST esp+frame+4
29 %define VAR_INVERSE PARAM_SRC
30 %assign frame 0
31
32 section .text
33
34 extern ___gmp_modlimb_invert_table
35 global ___gmpn_divexact_1
36 %ifdef DLL
37 export ___gmpn_divexact_1
38 %endif
39
40 align 16
41 ___gmpn_divexact_1:
42 mov eax,[PARAM_DIVISOR]
43 FR_push ebp
44 mov ebp,[PARAM_SIZE]
45 FR_push edi
46 FR_push ebx
47 mov ecx,-1 ; shift count
48 FR_push esi
49 Lstrip_twos:
50 inc ecx
51 shr eax,1
52 jnc Lstrip_twos
53 lea ebx,[1+eax+eax] ; d without twos
54 and eax,127 ; d/2,7 bits
55
56 %ifdef PIC
57 call Lmovl_eip_edx
58 add edx,_GLOBAL_OFFSET_TABLE_
59 mov edx,[___gmp_modlimb_invert_table+edx]
60 movzx eax,byte [eax+edx] ; inv 8 bits
61 %else
62 movzx eax,byte [___gmp_modlimb_invert_table+eax] ; inv 8 bits
63 %endif
64
65 lea edx,[eax+eax] ; 2*inv
66 mov [PARAM_DIVISOR],ebx ; d without twos
67 imul eax,eax ; inv*inv
68 mov esi,[PARAM_SRC]
69 mov edi,[PARAM_DST]
70 imul eax,ebx ; inv*inv*d
71 sub edx,eax ; inv = 2*inv - inv*inv*d
72 lea eax,[edx+edx] ; 2*inv
73 imul edx,edx ; inv*inv
74 lea esi,[esi+ebp*4] ; src end
75 lea edi,[edi+ebp*4] ; dst end
76 neg ebp ; -size
77 imul edx,ebx ; inv*inv*d
78 sub eax,edx ; inv = 2*inv - inv*inv*d
79
80 %ifdef ASSERT
81 FR_push eax
82 imul eax,[PARAM_DIVISOR]
83 cmp eax,1
84 FR_pop eax
85 %endif
86
87 mov [VAR_INVERSE],eax
88 mov eax,[esi+ebp*4] ; src[0]
89 xor ebx,ebx
90 xor edx,edx
91 inc ebp
92 jz Lone
93 mov edx,[esi+ebp*4] ; src[1]
94 shrd eax,edx,cl
95 mov edx,[VAR_INVERSE]
96 jmp Lentry
97
98 align 8
99 nop ; k6 code alignment
100 nop
101
102 ; eax q
103 ; ebx carry bit,0 or -1
104 ; ecx shift
105 ; edx carry limb
106 ; esi src end
107 ; edi dst end
108 ; ebp counter,limbs,negative
109
110 Ltop:
111 mov eax,[-4+esi+ebp*4]
112 sub edx,ebx ; accumulate carry bit
113 mov ebx,[esi+ebp*4]
114 shrd eax,ebx,cl
115 sub eax,edx ; apply carry limb
116 mov edx,[VAR_INVERSE]
117 sbb ebx,ebx
118 Lentry:
119 imul eax,edx
120 mov [-4+edi+ebp*4],eax
121 mov edx,[PARAM_DIVISOR]
122 mul edx
123 inc ebp
124 jnz Ltop
125 mov eax,[-4+esi] ; src high limb
126 Lone:
127 shr eax,cl
128 FR_pop esi
129 add eax,ebx ; apply carry bit
130 FR_pop ebx
131 sub eax,edx ; apply carry limb
132 imul eax,[VAR_INVERSE]
133 mov [-4+edi],eax
134 pop edi
135 pop ebp
136 ret
137
138 %ifdef PIC
139 Lmovl_eip_edx:
140 mov edx,[esp]
141 ret
142 %endif
143
144 end