Debian Codegraph @

msvc/gmp/mpn/x86i/divrem_1.asm

raw
1
2 ; Copyright 1999, 2000, 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_CARRY esp+frame+24
26 %define PARAM_DIVISOR esp+frame+20
27 %define PARAM_SIZE esp+frame+16
28 %define PARAM_SRC esp+frame+12
29 %define PARAM_XSIZE esp+frame+8
30 %define PARAM_DST esp+frame+4
31
32 section .text
33
34 global ___gmpn_divrem_1c
35 %ifdef DLL
36 export ___gmpn_divrem_1c
37 %endif
38
39 align 16
40 ___gmpn_divrem_1c:
41 %assign frame 0
42 mov ecx,[PARAM_SIZE]
43 FR_push edi
44 mov edi,[PARAM_SRC]
45 FR_push esi
46 mov esi,[PARAM_DIVISOR]
47 FR_push ebx
48 mov ebx,[PARAM_DST]
49 FR_push ebp
50 mov ebp,[PARAM_XSIZE]
51 or ecx,ecx
52 mov edx,[PARAM_CARRY]
53 jz Lfraction
54 lea ebx,[-4+ebx+ebp*4] ; dst one limb below integer part
55 jmp Linteger_top
56
57 global ___gmpn_divrem_1
58 %ifdef DLL
59 export ___gmpn_divrem_1
60 %endif
61 align 16
62 ___gmpn_divrem_1:
63
64 %assign frame 0
65 mov ecx,[PARAM_SIZE]
66 FR_push edi
67 mov edi,[PARAM_SRC]
68 FR_push esi
69 mov esi,[PARAM_DIVISOR]
70 or ecx,ecx
71 jz Lsize_zero
72 FR_push ebx
73 mov eax,[-4+edi+ecx*4] ; src high limb
74 xor edx,edx
75 mov ebx,[PARAM_DST]
76 FR_push ebp
77 mov ebp,[PARAM_XSIZE]
78 cmp eax,esi
79 lea ebx,[-4+ebx+ebp*4] ; dst one limb below integer part
80 jae Linteger_entry
81
82 ; high<divisor,so high of dst is zero,and avoid one div
83
84 mov [ebx+ecx*4],edx
85 dec ecx
86 mov edx,eax
87 jz Lfraction
88
89 ; eax scratch (quotient)
90 ; ebx dst+4*xsize-4
91 ; ecx counter
92 ; edx scratch (remainder)
93 ; esi divisor
94 ; edi src
95 ; ebp xsize
96
97 Linteger_top:
98 mov eax,[-4+edi+ecx*4]
99 Linteger_entry:
100 div esi
101 mov [ebx+ecx*4],eax
102 dec ecx
103 jnz Linteger_top
104 Lfraction:
105 or ecx,ebp
106 jz Ldone
107 mov ebx,[PARAM_DST]
108
109 ; eax scratch (quotient)
110 ; ebx dst
111 ; ecx counter
112 ; edx scratch (remainder)
113 ; esi divisor
114 ; edi
115 ; ebp
116
117 Lfraction_top:
118 xor eax,eax
119 div esi
120 mov [-4+ebx+ecx*4],eax
121 dec ecx
122 jnz Lfraction_top
123 Ldone:
124 pop ebp
125 mov eax,edx
126 pop ebx
127 pop esi
128 pop edi
129 ret
130 Lsize_zero:
131 mov ecx,[PARAM_XSIZE]
132 xor eax,eax
133 mov edi,[PARAM_DST]
134 cld ; better safe than sorry,see mpn/x86/README
135 rep stosd
136 pop esi
137 pop edi
138 ret
139
140 end