Debian Codegraph @

mpi/arm/mpih-sub1.S

raw
1 /* ARM sub_n -- Subtract two limb vectors of the same length > 0 and store
2 * sum in a third limb vector.
3 *
4 * Copyright (C) 2013 Jussi Kivilinna <[email protected]>
5 *
6 * This file is part of Libgcrypt.
7 *
8 * Libgcrypt is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as
10 * published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * Libgcrypt is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
20 *
21 * Note: This code is heavily based on the GNU MP Library (version 4.2.1).
22 */
23
24 #include "sysdep.h"
25 #include "asm-syntax.h"
26
27 .syntax unified
28 .arm
29
30 /*******************
31 * mpi_limb_t
32 * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, r0
33 * mpi_ptr_t s1_ptr, r1
34 * mpi_ptr_t s2_ptr, r2
35 * mpi_size_t size) r3
36 */
37
38 .text
39
40 .globl _gcry_mpih_sub_n
41 .type _gcry_mpih_sub_n,%function
42 _gcry_mpih_sub_n:
43 push {r4, r5, r6, r7, r8, r9, r10, lr};
44 cmp r0, #0; /* prepare carry flag for sub */
45
46 tst r3, #3;
47 beq .Large_loop;
48
49 .Loop:
50 ldr r4, [r1], #4;
51 sub r3, #1;
52 ldr lr, [r2], #4;
53 sbcs r4, lr;
54 tst r3, #3;
55 str r4, [r0], #4;
56 bne .Loop;
57
58 teq r3, #0;
59 beq .Lend;
60
61 .Large_loop:
62 ldm r1!, {r4, r6, r8, r10};
63 sub r3, #4;
64 ldm r2!, {r5, r7, r9, lr};
65 sbcs r4, r5;
66 sbcs r6, r7;
67 sbcs r8, r9;
68 sbcs r10, lr;
69 teq r3, #0;
70 stm r0!, {r4, r6, r8, r10};
71 bne .Large_loop;
72
73 .Lend:
74 sbc r0, r3, #0;
75 neg r0, r0;
76 pop {r4, r5, r6, r7, r8, r9, r10, pc};
77 .size _gcry_mpih_sub_n,.-_gcry_mpih_sub_n;