| 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 |
global ___gmpn_copyd |
| 26 |
|
| 27 |
%ifdef DLL |
| 28 |
export ___gmpn_copyd |
| 29 |
%endif |
| 30 |
|
| 31 |
%define PARAM_SIZE esp+frame+12 |
| 32 |
%define PARAM_SRC esp+frame+8 |
| 33 |
%define PARAM_DST esp+frame+4 |
| 34 |
|
| 35 |
%define SAVE_ESI PARAM_SIZE |
| 36 |
%define SAVE_EDI PARAM_SRC |
| 37 |
%define frame 0 |
| 38 |
|
| 39 |
section .text |
| 40 |
align 16 |
| 41 |
|
| 42 |
___gmpn_copyd: |
| 43 |
mov ecx,[PARAM_SIZE] |
| 44 |
mov [SAVE_ESI],esi |
| 45 |
mov esi,[PARAM_SRC] |
| 46 |
mov [SAVE_EDI],edi |
| 47 |
mov edi,[PARAM_DST] |
| 48 |
sub ecx,1 |
| 49 |
jb Lzero |
| 50 |
mov eax,[esi+ecx*4] ; src[size-1] |
| 51 |
jz Lone |
| 52 |
mov edx,[-4+esi+ecx*4] ; src[size-2] |
| 53 |
sub ecx,2 |
| 54 |
jbe Ldone_loop ; 2 or 3 limbs only |
| 55 |
|
| 56 |
; The usual overlap is |
| 57 |
; |
| 58 |
; high low |
| 59 |
; +------------------+ |
| 60 |
; | dst| |
| 61 |
; +------------------+ |
| 62 |
; +------------------+ |
| 63 |
; | src| |
| 64 |
; +------------------+ |
| 65 |
; |
| 66 |
; We can use an incrementing copy in the following circumstances. |
| 67 |
; |
| 68 |
; src+4*size<=dst,since then the regions are disjoint |
| 69 |
; |
| 70 |
; src==dst,clearly (though this shouldn't occur normally) |
| 71 |
; |
| 72 |
; src>dst,since in that case it's a requirement of the |
| 73 |
; parameters that src>=dst+size*4,and hence the |
| 74 |
; regions are disjoint |
| 75 |
; |
| 76 |
; eax prev high limb |
| 77 |
; ebx |
| 78 |
; ecx counter,size-3 down to 0 or -1,inclusive,by 2s |
| 79 |
; edx prev low limb |
| 80 |
; esi src |
| 81 |
; edi dst |
| 82 |
; ebp |
| 83 |
|
| 84 |
lea edx,[edi+ecx*4] |
| 85 |
cmp esi,edi |
| 86 |
jae Luse_movsl ; src >= dst |
| 87 |
cmp edx,edi |
| 88 |
mov edx,[4+esi+ecx*4] ; src[size-2] again |
| 89 |
jbe Luse_movsl ; src+4*size <= dst |
| 90 |
Ltop: |
| 91 |
mov [8+edi+ecx*4],eax |
| 92 |
mov eax,[esi+ecx*4] |
| 93 |
mov [4+edi+ecx*4],edx |
| 94 |
mov edx,[-4+esi+ecx*4] |
| 95 |
sub ecx,2 |
| 96 |
jnbe Ltop |
| 97 |
Ldone_loop: |
| 98 |
mov [8+edi+ecx*4],eax |
| 99 |
mov [4+edi+ecx*4],edx |
| 100 |
|
| 101 |
; copy low limb (needed if size was odd,but will already have been |
| 102 |
; done in the loop if size was even) |
| 103 |
|
| 104 |
mov eax,[esi] |
| 105 |
Lone: |
| 106 |
mov [edi],eax |
| 107 |
mov edi,[SAVE_EDI] |
| 108 |
mov esi,[SAVE_ESI] |
| 109 |
ret |
| 110 |
Luse_movsl: |
| 111 |
add ecx,3 |
| 112 |
cld |
| 113 |
rep movsd |
| 114 |
Lzero: |
| 115 |
mov esi,[SAVE_ESI] |
| 116 |
mov edi,[SAVE_EDI] |
| 117 |
ret |
| 118 |
|
| 119 |
end |