| 1 |
|
| 2 |
; Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software |
| 3 |
; Foundation, Inc. |
| 4 |
; |
| 5 |
; This file is part of the GNU MP Library. |
| 6 |
; |
| 7 |
; The GNU MP Library is free software; you can redistribute it and/or |
| 8 |
; modify it under the terms of the GNU Lesser General Public License as |
| 9 |
; published by the Free Software Foundation; either version 2.1 of the |
| 10 |
; License, or (at your option) any later version. |
| 11 |
; |
| 12 |
; The GNU MP Library is distributed in the hope that it will be useful, |
| 13 |
; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
; Lesser General Public License for more details. |
| 16 |
; |
| 17 |
; You should have received a copy of the GNU Lesser General Public |
| 18 |
; License along with the GNU MP Library; see the file COPYING.LIB. If |
| 19 |
; not, write to the Free Software Foundation, Inc., 59 Temple Place - |
| 20 |
; Suite 330, Boston, MA 02111-1307, USA. |
| 21 |
; |
| 22 |
; Translation of AT&T syntax code by Brian Gladman |
| 23 |
|
| 24 |
%include "x86i.inc" |
| 25 |
|
| 26 |
|
| 27 |
%define VAR_STACK_SPACE 8 |
| 28 |
%define PARAM_YSIZE esp+frame+20 |
| 29 |
%define PARAM_YP esp+frame+16 |
| 30 |
%define PARAM_XSIZE esp+frame+12 |
| 31 |
%define PARAM_XP esp+frame+8 |
| 32 |
%define PARAM_WP esp+frame+4 |
| 33 |
%define VAR_MULTIPLIER esp+frame-4 |
| 34 |
%define VAR_COUNTER esp+frame-8 |
| 35 |
|
| 36 |
section .text |
| 37 |
|
| 38 |
global ___gmpn_mul_basecase |
| 39 |
%ifdef DLL |
| 40 |
export ___gmpn_mul_basecase |
| 41 |
%endif |
| 42 |
|
| 43 |
align 8 |
| 44 |
___gmpn_mul_basecase: |
| 45 |
sub esp,VAR_STACK_SPACE |
| 46 |
push esi |
| 47 |
push ebp |
| 48 |
push edi |
| 49 |
%assign frame VAR_STACK_SPACE+12 |
| 50 |
mov esi,[PARAM_XP] |
| 51 |
mov edi,[PARAM_WP] |
| 52 |
mov ebp,[PARAM_YP] |
| 53 |
mov eax,[esi] ; load xp[0] |
| 54 |
mul dword [ebp] ; multiply by yp[0] |
| 55 |
mov [edi],eax ; store to wp[0] |
| 56 |
mov ecx,[PARAM_XSIZE] ; xsize |
| 57 |
dec ecx ; If xsize = 1,ysize = 1 too |
| 58 |
jz Ldone |
| 59 |
FR_push ebx |
| 60 |
mov ebx,edx |
| 61 |
lea esi,[4+esi] |
| 62 |
lea edi,[4+edi] |
| 63 |
LoopM: |
| 64 |
mov eax,[esi] ; load next limb at xp[j] |
| 65 |
lea esi,[4+esi] |
| 66 |
mul dword [ebp] |
| 67 |
add eax,ebx |
| 68 |
mov ebx,edx |
| 69 |
adc ebx,0 |
| 70 |
mov [edi],eax |
| 71 |
lea edi,[4+edi] |
| 72 |
dec ecx |
| 73 |
jnz LoopM |
| 74 |
mov [edi],ebx ; most significant limb of product |
| 75 |
add edi,4 ; increment wp |
| 76 |
mov eax,[PARAM_XSIZE] |
| 77 |
shl eax,2 |
| 78 |
sub edi,eax |
| 79 |
sub esi,eax |
| 80 |
mov eax,[PARAM_YSIZE] ; ysize |
| 81 |
dec eax |
| 82 |
jz Lskip |
| 83 |
mov [VAR_COUNTER],eax ; set index i to ysize |
| 84 |
Louter: |
| 85 |
mov ebp,[PARAM_YP] ; yp |
| 86 |
add ebp,4 ; make ebp point to next v limb |
| 87 |
mov [PARAM_YP],ebp |
| 88 |
mov eax,[ebp] ; copy y limb ... |
| 89 |
mov [VAR_MULTIPLIER],eax ; ... to stack slot |
| 90 |
mov ecx,[PARAM_XSIZE] |
| 91 |
xor ebx,ebx |
| 92 |
and ecx,3 |
| 93 |
jz Lend0 |
| 94 |
Loop0: |
| 95 |
mov eax,[esi] |
| 96 |
mul dword [VAR_MULTIPLIER] |
| 97 |
lea esi,[4+esi] |
| 98 |
add eax,ebx |
| 99 |
mov ebx,0 |
| 100 |
adc edx,ebx |
| 101 |
add [edi],eax |
| 102 |
adc ebx,edx ; propagate carry into cylimb |
| 103 |
lea edi,[4+edi] |
| 104 |
dec ecx |
| 105 |
jnz Loop0 |
| 106 |
Lend0: |
| 107 |
mov ecx,[PARAM_XSIZE] |
| 108 |
shr ecx,2 |
| 109 |
jz LendX |
| 110 |
|
| 111 |
align 8 |
| 112 |
LoopX: |
| 113 |
mov eax,[esi] |
| 114 |
mul dword [VAR_MULTIPLIER] |
| 115 |
add ebx,eax |
| 116 |
mov ebp,0 |
| 117 |
adc ebp,edx |
| 118 |
|
| 119 |
mov eax,[4+esi] |
| 120 |
mul dword [VAR_MULTIPLIER] |
| 121 |
add [edi],ebx |
| 122 |
adc ebp,eax ; new lo + cylimb |
| 123 |
mov ebx,0 |
| 124 |
adc ebx,edx |
| 125 |
|
| 126 |
mov eax,[8+esi] |
| 127 |
mul dword [VAR_MULTIPLIER] |
| 128 |
add [4+edi],ebp |
| 129 |
adc ebx,eax ; new lo + cylimb |
| 130 |
mov ebp,0 |
| 131 |
adc ebp,edx |
| 132 |
|
| 133 |
mov eax,[12+esi] |
| 134 |
mul dword [VAR_MULTIPLIER] |
| 135 |
add [8+edi],ebx |
| 136 |
adc ebp,eax ; new lo + cylimb |
| 137 |
mov ebx,0 |
| 138 |
adc ebx,edx |
| 139 |
|
| 140 |
add [12+edi],ebp |
| 141 |
adc ebx,0 ; propagate carry into cylimb |
| 142 |
|
| 143 |
lea esi,[16+esi] |
| 144 |
lea edi,[16+edi] |
| 145 |
dec ecx |
| 146 |
jnz LoopX |
| 147 |
LendX: |
| 148 |
mov [edi],ebx |
| 149 |
add edi,4 |
| 150 |
|
| 151 |
; we incremented wp and xp in the loop above; compensate |
| 152 |
mov eax,[PARAM_XSIZE] |
| 153 |
shl eax,2 |
| 154 |
sub edi,eax |
| 155 |
sub esi,eax |
| 156 |
|
| 157 |
mov eax,[VAR_COUNTER] |
| 158 |
dec eax |
| 159 |
mov [VAR_COUNTER],eax |
| 160 |
jnz Louter |
| 161 |
Lskip: |
| 162 |
pop ebx |
| 163 |
pop edi |
| 164 |
pop ebp |
| 165 |
pop esi |
| 166 |
add esp,8 |
| 167 |
ret |
| 168 |
Ldone: |
| 169 |
mov [4+edi],edx ; store to wp[1] |
| 170 |
pop edi |
| 171 |
pop ebp |
| 172 |
pop esi |
| 173 |
add esp,8 |
| 174 |
ret |
| 175 |
|
| 176 |
end |