| 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+16 |
| 26 |
%define PARAM_DIVISOR esp+frame+12 |
| 27 |
%define PARAM_SIZE esp+frame+8 |
| 28 |
%define PARAM_SRC esp+frame+4 |
| 29 |
|
| 30 |
section .text |
| 31 |
|
| 32 |
global ___gmpn_mod_1c |
| 33 |
%ifdef DLL |
| 34 |
export ___gmpn_mod_1c |
| 35 |
%endif |
| 36 |
|
| 37 |
align 16 |
| 38 |
___gmpn_mod_1c: |
| 39 |
%assign frame 0 |
| 40 |
mov ecx,[PARAM_SIZE] |
| 41 |
FR_push ebx |
| 42 |
mov ebx,[PARAM_SRC] |
| 43 |
FR_push esi |
| 44 |
mov esi,[PARAM_DIVISOR] |
| 45 |
or ecx,ecx |
| 46 |
mov edx,[PARAM_CARRY] |
| 47 |
jnz Ltop |
| 48 |
pop esi |
| 49 |
mov eax,edx |
| 50 |
pop ebx |
| 51 |
ret |
| 52 |
|
| 53 |
global ___gmpn_mod_1 |
| 54 |
%ifdef DLL |
| 55 |
export ___gmpn_mod_1 |
| 56 |
%endif |
| 57 |
align 16 |
| 58 |
___gmpn_mod_1: |
| 59 |
|
| 60 |
%assign frame 0 |
| 61 |
mov ecx,[PARAM_SIZE] |
| 62 |
FR_push ebx |
| 63 |
mov ebx,[PARAM_SRC] |
| 64 |
FR_push esi |
| 65 |
or ecx,ecx |
| 66 |
jz Ldone_zero |
| 67 |
mov esi,[PARAM_DIVISOR] |
| 68 |
mov eax,[-4+ebx+ecx*4] ; src high limb |
| 69 |
cmp eax,esi |
| 70 |
sbb edx,edx ; -1 if high<divisor |
| 71 |
add ecx,edx ; skip one division if high<divisor |
| 72 |
jz Ldone_eax |
| 73 |
and edx,eax ; carry if high<divisor |
| 74 |
|
| 75 |
; eax scratch (quotient) |
| 76 |
; ebx src |
| 77 |
; ecx counter |
| 78 |
; edx carry (remainder) |
| 79 |
; esi divisor |
| 80 |
; edi |
| 81 |
; ebp |
| 82 |
|
| 83 |
Ltop: |
| 84 |
mov eax,[-4+ebx+ecx*4] |
| 85 |
div esi |
| 86 |
dec ecx |
| 87 |
jnz Ltop |
| 88 |
mov eax,edx |
| 89 |
Ldone_eax: |
| 90 |
pop esi |
| 91 |
pop ebx |
| 92 |
ret |
| 93 |
Ldone_zero: |
| 94 |
pop esi |
| 95 |
xor eax,eax |
| 96 |
pop ebx |
| 97 |
ret |
| 98 |
|
| 99 |
end |