2
; Copyright 2001, 2002 Free Software Foundation, Inc.
4
; This file is part of the GNU MP Library.
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.
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.
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.
21
; Translation of AT&T syntax code by Brian Gladman
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
34
extern ___gmp_modlimb_invert_table
35
global ___gmpn_divexact_1
37
export ___gmpn_divexact_1
42
mov eax,[PARAM_DIVISOR]
47
mov ecx,-1 ; shift count
53
lea ebx,[1+eax+eax] ; d without twos
54
and eax,127 ; d/2,7 bits
58
add edx,_GLOBAL_OFFSET_TABLE_
59
mov edx,[___gmp_modlimb_invert_table+edx]
60
movzx eax,byte [eax+edx] ; inv 8 bits
62
movzx eax,byte [___gmp_modlimb_invert_table+eax] ; inv 8 bits
65
lea edx,[eax+eax] ; 2*inv
66
mov [PARAM_DIVISOR],ebx ; d without twos
67
imul eax,eax ; inv*inv
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
77
imul edx,ebx ; inv*inv*d
78
sub eax,edx ; inv = 2*inv - inv*inv*d
82
imul eax,[PARAM_DIVISOR]
88
mov eax,[esi+ebp*4] ; src[0]
93
mov edx,[esi+ebp*4] ; src[1]
99
nop ; k6 code alignment
103
; ebx carry bit,0 or -1
108
; ebp counter,limbs,negative
111
mov eax,[-4+esi+ebp*4]
112
sub edx,ebx ; accumulate carry bit
115
sub eax,edx ; apply carry limb
116
mov edx,[VAR_INVERSE]
120
mov [-4+edi+ebp*4],eax
121
mov edx,[PARAM_DIVISOR]
125
mov eax,[-4+esi] ; src high limb
129
add eax,ebx ; apply carry bit
131
sub eax,edx ; apply carry limb
132
imul eax,[VAR_INVERSE]