Revert "Merge branch 'upstream' into tizen"
[platform/upstream/nettle.git] / x86_64 / ecc-192-modp.asm
1 C nettle, low-level cryptographics library
2 C
3 C Copyright (C) 2013 Niels Möller
4 C
5 C The nettle library is free software; you can redistribute it and/or modify
6 C it under the terms of the GNU Lesser General Public License as published by
7 C the Free Software Foundation; either version 2.1 of the License, or (at your
8 C option) any later version.
9 C
10 C The nettle library is distributed in the hope that it will be useful, but
11 C WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 C or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
13 C License for more details.
14 C
15 C You should have received a copy of the GNU Lesser General Public License
16 C along with the nettle library; see the file COPYING.LIB.  If not, write to
17 C the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 C MA 02111-1301, USA.
19
20         .file "ecc-192-modp.asm"
21
22 define(<RP>, <%rsi>)
23 define(<T0>, <%rdi>) C Overlaps unused ecc input
24 define(<T1>, <%rcx>)
25 define(<T2>, <%rdx>)
26 define(<T3>, <%r8>)
27 define(<H>, <%r9>)
28 define(<C1>, <%r10>)
29 define(<C2>, <%r11>)
30
31         C ecc_192_modp (const struct ecc_curve *ecc, mp_limb_t *rp)
32         .text
33         ALIGN(16)
34 PROLOGUE(nettle_ecc_192_modp)
35         W64_ENTRY(2, 0)
36         mov     16(RP), T2
37         mov     24(RP), T3
38         mov     40(RP), H
39         xor     C1, C1
40         xor     C2, C2
41
42         add     H, T2
43         adc     H, T3
44         C Carry to be added in at T1 and T2
45         setc    LREG(C2)
46         
47         mov     8(RP), T1
48         mov     32(RP), H
49         adc     H, T1
50         adc     H, T2
51         C Carry to be added in at T0 and T1
52         setc    LREG(C1)
53         
54         mov     (RP), T0
55         adc     T3, T0
56         adc     T3, T1
57         adc     $0, C2
58
59         C Add in C1 and C2
60         add     C1, T1
61         adc     C2, T2
62         setc    LREG(C1)
63
64         C Fold final carry.
65         adc     $0, T0
66         adc     C1, T1
67         adc     $0, T2
68
69         mov     T0, (RP)
70         mov     T1, 8(RP)
71         mov     T2, 16(RP)
72
73         W64_EXIT(2, 0)
74         ret
75 EPILOGUE(nettle_ecc_192_modp)