updated licenses
[gnutls:gnutls.git] / lib / accelerated / x86 / coff / padlock-x86-coff.s
1 # Copyright (c) 2011-2012, Andy Polyakov <appro@openssl.org>
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
6 # are met:
7
8 #     * Redistributions of source code must retain copyright notices,
9 #      this list of conditions and the following disclaimer.
10 #
11 #     * Redistributions in binary form must reproduce the above
12 #      copyright notice, this list of conditions and the following
13 #      disclaimer in the documentation and/or other materials
14 #      provided with the distribution.
15 #
16 #     * Neither the name of the Andy Polyakov nor the names of its
17 #      copyright holder and contributors may be used to endorse or
18 #      promote products derived from this software without specific
19 #      prior written permission.
20 #
21 # ALTERNATIVELY, provided that this notice is retained in full, this
22 # product may be distributed under the terms of the GNU General Public
23 # License (GPL), in which case the provisions of the GPL apply INSTEAD OF
24 # those given above.
25 #
26 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
27 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #
38 # *** This file is auto-generated ***
39 #
40 .file   "devel/perlasm/e_padlock-x86.s"
41 .text
42 .globl  _padlock_capability
43 .def    _padlock_capability;    .scl    2;      .type   32;     .endef
44 .align  16
45 _padlock_capability:
46 .L_padlock_capability_begin:
47         pushl   %ebx
48         pushfl
49         popl    %eax
50         movl    %eax,%ecx
51         xorl    $2097152,%eax
52         pushl   %eax
53         popfl
54         pushfl
55         popl    %eax
56         xorl    %eax,%ecx
57         xorl    %eax,%eax
58         btl     $21,%ecx
59         jnc     .L000noluck
60         .byte   0x0f,0xa2
61         xorl    %eax,%eax
62         cmpl    $0x746e6543,%ebx
63         jne     .L000noluck
64         cmpl    $0x48727561,%edx
65         jne     .L000noluck
66         cmpl    $0x736c7561,%ecx
67         jne     .L000noluck
68         movl    $3221225472,%eax
69         .byte   0x0f,0xa2
70         movl    %eax,%edx
71         xorl    %eax,%eax
72         cmpl    $3221225473,%edx
73         jb      .L000noluck
74         movl    $1,%eax
75         .byte   0x0f,0xa2
76         orl     $15,%eax
77         xorl    %ebx,%ebx
78         andl    $4095,%eax
79         cmpl    $1791,%eax
80         sete    %bl
81         movl    $3221225473,%eax
82         pushl   %ebx
83         .byte   0x0f,0xa2
84         popl    %ebx
85         movl    %edx,%eax
86         shll    $4,%ebx
87         andl    $4294967279,%eax
88         orl     %ebx,%eax
89 .L000noluck:
90         popl    %ebx
91         ret
92 .globl  _padlock_key_bswap
93 .def    _padlock_key_bswap;     .scl    2;      .type   32;     .endef
94 .align  16
95 _padlock_key_bswap:
96 .L_padlock_key_bswap_begin:
97         movl    4(%esp),%edx
98         movl    240(%edx),%ecx
99 .L001bswap_loop:
100         movl    (%edx),%eax
101         bswap   %eax
102         movl    %eax,(%edx)
103         leal    4(%edx),%edx
104         subl    $1,%ecx
105         jnz     .L001bswap_loop
106         ret
107 .globl  _padlock_verify_context
108 .def    _padlock_verify_context;        .scl    2;      .type   32;     .endef
109 .align  16
110 _padlock_verify_context:
111 .L_padlock_verify_context_begin:
112         movl    4(%esp),%edx
113         leal    .Lpadlock_saved_context,%eax
114         pushfl
115         call    __padlock_verify_ctx
116 .L002verify_pic_point:
117         leal    4(%esp),%esp
118         ret
119 .def    __padlock_verify_ctx;   .scl    3;      .type   32;     .endef
120 .align  16
121 __padlock_verify_ctx:
122         btl     $30,4(%esp)
123         jnc     .L003verified
124         cmpl    (%eax),%edx
125         je      .L003verified
126         pushfl
127         popfl
128 .L003verified:
129         movl    %edx,(%eax)
130         ret
131 .globl  _padlock_reload_key
132 .def    _padlock_reload_key;    .scl    2;      .type   32;     .endef
133 .align  16
134 _padlock_reload_key:
135 .L_padlock_reload_key_begin:
136         pushfl
137         popfl
138         ret
139 .globl  _padlock_aes_block
140 .def    _padlock_aes_block;     .scl    2;      .type   32;     .endef
141 .align  16
142 _padlock_aes_block:
143 .L_padlock_aes_block_begin:
144         pushl   %edi
145         pushl   %esi
146         pushl   %ebx
147         movl    16(%esp),%edi
148         movl    20(%esp),%esi
149         movl    24(%esp),%edx
150         movl    $1,%ecx
151         leal    32(%edx),%ebx
152         leal    16(%edx),%edx
153 .byte   243,15,167,200
154         popl    %ebx
155         popl    %esi
156         popl    %edi
157         ret
158 .globl  _padlock_ecb_encrypt
159 .def    _padlock_ecb_encrypt;   .scl    2;      .type   32;     .endef
160 .align  16
161 _padlock_ecb_encrypt:
162 .L_padlock_ecb_encrypt_begin:
163         pushl   %ebp
164         pushl   %ebx
165         pushl   %esi
166         pushl   %edi
167         movl    20(%esp),%edi
168         movl    24(%esp),%esi
169         movl    28(%esp),%edx
170         movl    32(%esp),%ecx
171         testl   $15,%edx
172         jnz     .L004ecb_abort
173         testl   $15,%ecx
174         jnz     .L004ecb_abort
175         leal    .Lpadlock_saved_context,%eax
176         pushfl
177         cld
178         call    __padlock_verify_ctx
179 .L005ecb_pic_point:
180         leal    16(%edx),%edx
181         xorl    %eax,%eax
182         xorl    %ebx,%ebx
183         cmpl    $128,%ecx
184         jbe     .L006ecb_short
185         testl   $32,(%edx)
186         jnz     .L007ecb_aligned
187         testl   $15,%edi
188         setz    %al
189         testl   $15,%esi
190         setz    %bl
191         testl   %ebx,%eax
192         jnz     .L007ecb_aligned
193         negl    %eax
194         movl    $512,%ebx
195         notl    %eax
196         leal    -24(%esp),%ebp
197         cmpl    %ebx,%ecx
198         cmovcl  %ecx,%ebx
199         andl    %ebx,%eax
200         movl    %ecx,%ebx
201         negl    %eax
202         andl    $511,%ebx
203         leal    (%eax,%ebp,1),%esp
204         andl    $-16,%esp
205         jmp     .L008ecb_loop
206 .align  16
207 .L008ecb_loop:
208         movl    %edi,(%ebp)
209         movl    %esi,4(%ebp)
210         movl    %ecx,8(%ebp)
211         movl    %ebx,%ecx
212         movl    %ebx,12(%ebp)
213         testl   $15,%edi
214         cmovnzl %esp,%edi
215         testl   $15,%esi
216         jz      .L009ecb_inp_aligned
217         shrl    $2,%ecx
218 .byte   243,165
219         subl    %ebx,%edi
220         movl    %ebx,%ecx
221         movl    %edi,%esi
222 .L009ecb_inp_aligned:
223         leal    -16(%edx),%eax
224         leal    16(%edx),%ebx
225         shrl    $4,%ecx
226 .byte   243,15,167,200
227         movl    (%ebp),%edi
228         movl    12(%ebp),%ebx
229         testl   $15,%edi
230         jz      .L010ecb_out_aligned
231         movl    %ebx,%ecx
232         shrl    $2,%ecx
233         leal    (%esp),%esi
234 .byte   243,165
235         subl    %ebx,%edi
236 .L010ecb_out_aligned:
237         movl    4(%ebp),%esi
238         movl    8(%ebp),%ecx
239         addl    %ebx,%edi
240         addl    %ebx,%esi
241         subl    %ebx,%ecx
242         movl    $512,%ebx
243         jnz     .L008ecb_loop
244         cmpl    %ebp,%esp
245         je      .L011ecb_done
246         pxor    %xmm0,%xmm0
247         leal    (%esp),%eax
248 .L012ecb_bzero:
249         movaps  %xmm0,(%eax)
250         leal    16(%eax),%eax
251         cmpl    %eax,%ebp
252         ja      .L012ecb_bzero
253 .L011ecb_done:
254         leal    24(%ebp),%esp
255         jmp     .L013ecb_exit
256 .align  16
257 .L006ecb_short:
258         xorl    %eax,%eax
259         leal    -24(%esp),%ebp
260         subl    %ecx,%eax
261         leal    (%eax,%ebp,1),%esp
262         andl    $-16,%esp
263         xorl    %ebx,%ebx
264 .L014ecb_short_copy:
265         movups  (%esi,%ebx,1),%xmm0
266         leal    16(%ebx),%ebx
267         cmpl    %ebx,%ecx
268         movaps  %xmm0,-16(%esp,%ebx,1)
269         ja      .L014ecb_short_copy
270         movl    %esp,%esi
271         movl    %ecx,%ebx
272         jmp     .L008ecb_loop
273 .align  16
274 .L007ecb_aligned:
275         leal    -16(%edx),%eax
276         leal    16(%edx),%ebx
277         shrl    $4,%ecx
278 .byte   243,15,167,200
279 .L013ecb_exit:
280         movl    $1,%eax
281         leal    4(%esp),%esp
282 .L004ecb_abort:
283         popl    %edi
284         popl    %esi
285         popl    %ebx
286         popl    %ebp
287         ret
288 .globl  _padlock_cbc_encrypt
289 .def    _padlock_cbc_encrypt;   .scl    2;      .type   32;     .endef
290 .align  16
291 _padlock_cbc_encrypt:
292 .L_padlock_cbc_encrypt_begin:
293         pushl   %ebp
294         pushl   %ebx
295         pushl   %esi
296         pushl   %edi
297         movl    20(%esp),%edi
298         movl    24(%esp),%esi
299         movl    28(%esp),%edx
300         movl    32(%esp),%ecx
301         testl   $15,%edx
302         jnz     .L015cbc_abort
303         testl   $15,%ecx
304         jnz     .L015cbc_abort
305         leal    .Lpadlock_saved_context,%eax
306         pushfl
307         cld
308         call    __padlock_verify_ctx
309 .L016cbc_pic_point:
310         leal    16(%edx),%edx
311         xorl    %eax,%eax
312         xorl    %ebx,%ebx
313         cmpl    $64,%ecx
314         jbe     .L017cbc_short
315         testl   $32,(%edx)
316         jnz     .L018cbc_aligned
317         testl   $15,%edi
318         setz    %al
319         testl   $15,%esi
320         setz    %bl
321         testl   %ebx,%eax
322         jnz     .L018cbc_aligned
323         negl    %eax
324         movl    $512,%ebx
325         notl    %eax
326         leal    -24(%esp),%ebp
327         cmpl    %ebx,%ecx
328         cmovcl  %ecx,%ebx
329         andl    %ebx,%eax
330         movl    %ecx,%ebx
331         negl    %eax
332         andl    $511,%ebx
333         leal    (%eax,%ebp,1),%esp
334         andl    $-16,%esp
335         jmp     .L019cbc_loop
336 .align  16
337 .L019cbc_loop:
338         movl    %edi,(%ebp)
339         movl    %esi,4(%ebp)
340         movl    %ecx,8(%ebp)
341         movl    %ebx,%ecx
342         movl    %ebx,12(%ebp)
343         testl   $15,%edi
344         cmovnzl %esp,%edi
345         testl   $15,%esi
346         jz      .L020cbc_inp_aligned
347         shrl    $2,%ecx
348 .byte   243,165
349         subl    %ebx,%edi
350         movl    %ebx,%ecx
351         movl    %edi,%esi
352 .L020cbc_inp_aligned:
353         leal    -16(%edx),%eax
354         leal    16(%edx),%ebx
355         shrl    $4,%ecx
356 .byte   243,15,167,208
357         movaps  (%eax),%xmm0
358         movaps  %xmm0,-16(%edx)
359         movl    (%ebp),%edi
360         movl    12(%ebp),%ebx
361         testl   $15,%edi
362         jz      .L021cbc_out_aligned
363         movl    %ebx,%ecx
364         shrl    $2,%ecx
365         leal    (%esp),%esi
366 .byte   243,165
367         subl    %ebx,%edi
368 .L021cbc_out_aligned:
369         movl    4(%ebp),%esi
370         movl    8(%ebp),%ecx
371         addl    %ebx,%edi
372         addl    %ebx,%esi
373         subl    %ebx,%ecx
374         movl    $512,%ebx
375         jnz     .L019cbc_loop
376         cmpl    %ebp,%esp
377         je      .L022cbc_done
378         pxor    %xmm0,%xmm0
379         leal    (%esp),%eax
380 .L023cbc_bzero:
381         movaps  %xmm0,(%eax)
382         leal    16(%eax),%eax
383         cmpl    %eax,%ebp
384         ja      .L023cbc_bzero
385 .L022cbc_done:
386         leal    24(%ebp),%esp
387         jmp     .L024cbc_exit
388 .align  16
389 .L017cbc_short:
390         xorl    %eax,%eax
391         leal    -24(%esp),%ebp
392         subl    %ecx,%eax
393         leal    (%eax,%ebp,1),%esp
394         andl    $-16,%esp
395         xorl    %ebx,%ebx
396 .L025cbc_short_copy:
397         movups  (%esi,%ebx,1),%xmm0
398         leal    16(%ebx),%ebx
399         cmpl    %ebx,%ecx
400         movaps  %xmm0,-16(%esp,%ebx,1)
401         ja      .L025cbc_short_copy
402         movl    %esp,%esi
403         movl    %ecx,%ebx
404         jmp     .L019cbc_loop
405 .align  16
406 .L018cbc_aligned:
407         leal    -16(%edx),%eax
408         leal    16(%edx),%ebx
409         shrl    $4,%ecx
410 .byte   243,15,167,208
411         movaps  (%eax),%xmm0
412         movaps  %xmm0,-16(%edx)
413 .L024cbc_exit:
414         movl    $1,%eax
415         leal    4(%esp),%esp
416 .L015cbc_abort:
417         popl    %edi
418         popl    %esi
419         popl    %ebx
420         popl    %ebp
421         ret
422 .globl  _padlock_xstore
423 .def    _padlock_xstore;        .scl    2;      .type   32;     .endef
424 .align  16
425 _padlock_xstore:
426 .L_padlock_xstore_begin:
427         pushl   %edi
428         movl    8(%esp),%edi
429         movl    12(%esp),%edx
430 .byte   15,167,192
431         popl    %edi
432         ret
433 .def    __win32_segv_handler;   .scl    3;      .type   32;     .endef
434 .align  16
435 __win32_segv_handler:
436         movl    $1,%eax
437         movl    4(%esp),%edx
438         movl    12(%esp),%ecx
439         cmpl    $3221225477,(%edx)
440         jne     .L026ret
441         addl    $4,184(%ecx)
442         movl    $0,%eax
443 .L026ret:
444         ret
445 .globl  _padlock_sha1_oneshot
446 .def    _padlock_sha1_oneshot;  .scl    2;      .type   32;     .endef
447 .align  16
448 _padlock_sha1_oneshot:
449 .L_padlock_sha1_oneshot_begin:
450         pushl   %edi
451         pushl   %esi
452         xorl    %eax,%eax
453         movl    12(%esp),%edi
454         movl    16(%esp),%esi
455         movl    20(%esp),%ecx
456         pushl   __win32_segv_handler
457 .byte   100,255,48
458 .byte   100,137,32
459         movl    %esp,%edx
460         addl    $-128,%esp
461         movups  (%edi),%xmm0
462         andl    $-16,%esp
463         movl    16(%edi),%eax
464         movaps  %xmm0,(%esp)
465         movl    %esp,%edi
466         movl    %eax,16(%esp)
467         xorl    %eax,%eax
468 .byte   243,15,166,200
469         movaps  (%esp),%xmm0
470         movl    16(%esp),%eax
471         movl    %edx,%esp
472 .byte   100,143,5,0,0,0,0
473         leal    4(%esp),%esp
474         movl    16(%esp),%edi
475         movups  %xmm0,(%edi)
476         movl    %eax,16(%edi)
477         popl    %esi
478         popl    %edi
479         ret
480 .globl  _padlock_sha1_blocks
481 .def    _padlock_sha1_blocks;   .scl    2;      .type   32;     .endef
482 .align  16
483 _padlock_sha1_blocks:
484 .L_padlock_sha1_blocks_begin:
485         pushl   %edi
486         pushl   %esi
487         movl    12(%esp),%edi
488         movl    16(%esp),%esi
489         movl    %esp,%edx
490         movl    20(%esp),%ecx
491         addl    $-128,%esp
492         movups  (%edi),%xmm0
493         andl    $-16,%esp
494         movl    16(%edi),%eax
495         movaps  %xmm0,(%esp)
496         movl    %esp,%edi
497         movl    %eax,16(%esp)
498         movl    $-1,%eax
499 .byte   243,15,166,200
500         movaps  (%esp),%xmm0
501         movl    16(%esp),%eax
502         movl    %edx,%esp
503         movl    12(%esp),%edi
504         movups  %xmm0,(%edi)
505         movl    %eax,16(%edi)
506         popl    %esi
507         popl    %edi
508         ret
509 .globl  _padlock_sha256_oneshot
510 .def    _padlock_sha256_oneshot;        .scl    2;      .type   32;     .endef
511 .align  16
512 _padlock_sha256_oneshot:
513 .L_padlock_sha256_oneshot_begin:
514         pushl   %edi
515         pushl   %esi
516         xorl    %eax,%eax
517         movl    12(%esp),%edi
518         movl    16(%esp),%esi
519         movl    20(%esp),%ecx
520         pushl   __win32_segv_handler
521 .byte   100,255,48
522 .byte   100,137,32
523         movl    %esp,%edx
524         addl    $-128,%esp
525         movups  (%edi),%xmm0
526         andl    $-16,%esp
527         movups  16(%edi),%xmm1
528         movaps  %xmm0,(%esp)
529         movl    %esp,%edi
530         movaps  %xmm1,16(%esp)
531         xorl    %eax,%eax
532 .byte   243,15,166,208
533         movaps  (%esp),%xmm0
534         movaps  16(%esp),%xmm1
535         movl    %edx,%esp
536 .byte   100,143,5,0,0,0,0
537         leal    4(%esp),%esp
538         movl    16(%esp),%edi
539         movups  %xmm0,(%edi)
540         movups  %xmm1,16(%edi)
541         popl    %esi
542         popl    %edi
543         ret
544 .globl  _padlock_sha256_blocks
545 .def    _padlock_sha256_blocks; .scl    2;      .type   32;     .endef
546 .align  16
547 _padlock_sha256_blocks:
548 .L_padlock_sha256_blocks_begin:
549         pushl   %edi
550         pushl   %esi
551         movl    12(%esp),%edi
552         movl    16(%esp),%esi
553         movl    20(%esp),%ecx
554         movl    %esp,%edx
555         addl    $-128,%esp
556         movups  (%edi),%xmm0
557         andl    $-16,%esp
558         movups  16(%edi),%xmm1
559         movaps  %xmm0,(%esp)
560         movl    %esp,%edi
561         movaps  %xmm1,16(%esp)
562         movl    $-1,%eax
563 .byte   243,15,166,208
564         movaps  (%esp),%xmm0
565         movaps  16(%esp),%xmm1
566         movl    %edx,%esp
567         movl    12(%esp),%edi
568         movups  %xmm0,(%edi)
569         movups  %xmm1,16(%edi)
570         popl    %esi
571         popl    %edi
572         ret
573 .globl  _padlock_sha512_blocks
574 .def    _padlock_sha512_blocks; .scl    2;      .type   32;     .endef
575 .align  16
576 _padlock_sha512_blocks:
577 .L_padlock_sha512_blocks_begin:
578         pushl   %edi
579         pushl   %esi
580         movl    12(%esp),%edi
581         movl    16(%esp),%esi
582         movl    20(%esp),%ecx
583         movl    %esp,%edx
584         addl    $-128,%esp
585         movups  (%edi),%xmm0
586         andl    $-16,%esp
587         movups  16(%edi),%xmm1
588         movups  32(%edi),%xmm2
589         movups  48(%edi),%xmm3
590         movaps  %xmm0,(%esp)
591         movl    %esp,%edi
592         movaps  %xmm1,16(%esp)
593         movaps  %xmm2,32(%esp)
594         movaps  %xmm3,48(%esp)
595 .byte   243,15,166,224
596         movaps  (%esp),%xmm0
597         movaps  16(%esp),%xmm1
598         movaps  32(%esp),%xmm2
599         movaps  48(%esp),%xmm3
600         movl    %edx,%esp
601         movl    12(%esp),%edi
602         movups  %xmm0,(%edi)
603         movups  %xmm1,16(%edi)
604         movups  %xmm2,32(%edi)
605         movups  %xmm3,48(%edi)
606         popl    %esi
607         popl    %edi
608         ret
609 .byte   86,73,65,32,80,97,100,108,111,99,107,32,120,56,54,32
610 .byte   109,111,100,117,108,101,44,32,67,82,89,80,84,79,71,65
611 .byte   77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101
612 .byte   110,115,115,108,46,111,114,103,62,0
613 .align  16
614 .data
615 .align  4
616 .Lpadlock_saved_context:
617 .long   0