1 dnl AMD64 mpn_rsh1add_n
-- rp
[] = (up
[] + vp
[]) >> 1
2 dnl AMD64 mpn_rsh1sub_n
-- rp
[] = (up
[] - vp
[]) >> 1
4 dnl Copyright
2003, 2005, 2009, 2011, 2012 Free Software Foundation
, Inc.
6 dnl
This file is part of the GNU MP Library.
8 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
9 dnl it under the terms of
either:
11 dnl
* the GNU Lesser General
Public License as published by the Free
12 dnl Software Foundation
; either version 3 of the License, or (at your
13 dnl option
) any later version.
17 dnl
* the GNU General
Public License as published by the Free Software
18 dnl Foundation
; either version 2 of the License, or (at your option) any
21 dnl
or both
in parallel
, as here.
23 dnl The GNU MP Library is distributed
in the hope that it will be useful
, but
24 dnl WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
25 dnl
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License
28 dnl You should have received copies of the GNU General
Public License
and the
29 dnl GNU Lesser General
Public License along with the GNU MP Library. If
not,
30 dnl see
https://www.gnu.
org/licenses
/.
32 include(`..
/config.m4
')
35 C AMD K8,K9 2.14 (mpn_add_n + mpn_rshift need 4.125)
36 C AMD K10 2.14 (mpn_add_n + mpn_rshift need 4.125)
45 C * Rewrite to use indexed addressing, like addlsh1.asm and sublsh1.asm.
53 ifdef(`OPERATION_rsh1add_n', `
56 define
(func_n
, mpn_rsh1add_n
)
57 define
(func_nc
, mpn_rsh1add_nc
)')
58 ifdef(`OPERATION_rsh1sub_n', `
61 define
(func_n
, mpn_rsh1sub_n
)
62 define
(func_nc
, mpn_rsh1sub_nc
)')
64 MULFUNC_PROLOGUE(mpn_rsh1add_n mpn_rsh1add_nc mpn_rsh1sub_n mpn_rsh1sub_nc)
74 IFDOS(` mov 56(%rsp), %r8 ')
77 xor R32
(%rax
), R32
(%rax
)
78 neg %r8 C set C flag from parameter
89 xor R32
(%rax
), R32
(%rax
)
93 rcr %rbx C rotate
, save acy
94 adc R32
(%rax
), R32
(%rax
) C return value
100 je L
(do
) C jump if n
= 1 5 9 ...
102 L
(n1
): cmp $2, R32
(%r11
)
103 jne L
(n2
) C jump unless n
= 2 6 10 ...
104 add %rbx
, %rbx C rotate carry limb
, restore acy
115 L
(n2
): cmp $3, R32
(%r11
)
116 jne L
(n3
) C jump unless n
= 3 7 11 ...
117 add %rbx
, %rbx C rotate carry limb
, restore acy
131 L
(n3
): dec n C come here for n
= 4 8 12 ...
132 add %rbx
, %rbx C rotate carry limb
, restore acy
148 L
(cj2
): mov %r9
, -8(rp
)
149 L
(cj1
): mov %r10
, %rbx
155 L
(top
): add %rbx
, %rbx C rotate carry limb
, restore acy
169 rcr %r11 C rotate
, save acy
185 L
(end): mov %rbx
, (rp
)