Debian Codegraph @

msvc/gmp/mpn/x86i/p6/mmx/popham.asm

raw
1
2 ; Copyright 2000, 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 REG_AAAAAAAAAAAAAAAA mm7
26 %define REG_3333333333333333 mm6
27 %define REG_0F0F0F0F0F0F0F0F mm5
28 %define REG_000000FF000000FF mm4
29
30 %ifndef PIC
31
32 section .data
33 align 8
34
35 Lrodata_AAAAAAAAAAAAAAAA:
36 dd 0AAAAAAAAh
37 dd 0AAAAAAAAh
38
39 Lrodata_3333333333333333:
40 dd 033333333h
41 dd 033333333h
42
43 Lrodata_0F0F0F0F0F0F0F0F:
44 dd 00F0F0F0Fh
45 dd 00F0F0F0Fh
46
47 Lrodata_000000FF000000FF:
48 dd 0000000FFh
49 dd 0000000FFh
50
51 %endif
52
53 %macro ph_fun 3
54
55 section .text
56 align 32
57 global %1%2
58
59 %ifdef DLL
60 export %1%2
61 %endif
62
63 %if %3 == 0
64 %ifdef PIC
65 nop ; avoid shrl crossing a 32-byte boundary
66 %endif
67 %endif
68
69 %1%2:
70 mov ecx, [PARAM_SIZE]
71 %ifdef PIC
72 mov eax, 0xAAAAAAAA
73 mov edx, 0x33333333
74 movd mm7,eax
75 movd mm6,edx
76 mov eax, 0x0F0F0F0F
77 mov edx, 0x000000FF
78 punpckldq mm7,mm7
79 punpckldq mm6,mm6
80 movd mm5,eax
81 movd mm4,edx
82 punpckldq mm5,mm5
83 punpckldq mm4,mm4
84 %else
85 movq mm7,[Lrodata_AAAAAAAAAAAAAAAA]
86 movq mm6,[Lrodata_3333333333333333]
87 movq mm5,[Lrodata_0F0F0F0F0F0F0F0F]
88 movq mm4,[Lrodata_000000FF000000FF]
89 %endif
90 mov eax,[PARAM_SRC]
91 %if %3 == 1
92 mov edx,[PARAM_SRC2]
93 %endif
94 pxor mm2,mm2
95 shr ecx,1
96 jnc %%Ltop
97 movd mm1,[eax+ecx*8] ; Zdisp( movd,0,(%eax,%ecx,8),%mm1)
98 %if %3 == 1
99 movd mm0,[edx+ecx*8] ; Zdisp( movd,0,(%edx,%ecx,8),%mm0)"
100 pxor mm1,mm0
101 %endif
102 inc ecx
103 jmp %%Lloaded
104
105 align 16
106 %if %3 == 0
107 nop
108 %endif
109
110 ; eax src
111 ; ebx
112 ; ecx counter,qwords,decrementing
113 ; edx [hamdist] src2
114 ;
115 ; mm0 (scratch)
116 ; mm1 (scratch)
117 ; mm2 total (low dword)
118 ; mm3
119 ; mm4 \
120 ; mm5 | special constants
121 ; mm6 |
122 ; mm7 /
123
124 %%Ltop:
125 movq mm1,[eax+ecx*8-8]
126 %if %3 == 1
127 pxor mm1,[edx+ecx*8-8]
128 %endif
129 %%Lloaded:
130 movq mm0,mm1
131 pand mm1,REG_AAAAAAAAAAAAAAAA
132 psrlq mm1,1
133 %if %3 == 1
134 nop
135 %endif
136 psubd mm0,mm1 ; bit pairs
137 %if %3 == 1
138 nop
139 %endif
140 movq mm1,mm0
141 psrlq mm0,2
142 pand mm0,REG_3333333333333333
143 pand mm1,REG_3333333333333333
144 paddd mm0,mm1 ; nibbles
145 movq mm1,mm0
146 psrlq mm0,4
147 pand mm0,REG_0F0F0F0F0F0F0F0F
148 pand mm1,REG_0F0F0F0F0F0F0F0F
149 paddd mm0,mm1 ; bytes
150 movq mm1,mm0
151 psrlq mm0,8
152 paddb mm0,mm1 ; words
153 movq mm1,mm0
154 psrlq mm0,16
155 paddd mm0,mm1 ; dwords
156 pand mm0,REG_000000FF000000FF
157 paddd mm2,mm0 ; low to total
158 psrlq mm0,32
159 paddd mm2,mm0 ; high to total
160 loop %%Ltop
161 movd eax,mm2
162 emms
163 ret
164 %endmacro
165
166 %define PARAM_SIZE esp+frame+8
167 %define PARAM_SRC esp+frame+4
168 %define frame 0
169
170 ph_fun ___g,mpn_popcount,0
171
172 %define PARAM_SIZE esp+frame+12
173 %define PARAM_SRC2 esp+frame+8
174 %define PARAM_SRC esp+frame+4
175 %define frame 0
176
177 ph_fun ___g,mpn_hamdist,1
178
179 end