1dnl ARM mpn_modexact_1c_odd 2 3dnl Contributed to the GNU project by Torbjörn Granlund. 4 5dnl Copyright 2012 Free Software Foundation, Inc. 6 7dnl This file is part of the GNU MP Library. 8dnl 9dnl The GNU MP Library is free software; you can redistribute it and/or modify 10dnl it under the terms of either: 11dnl 12dnl * the GNU Lesser General Public License as published by the Free 13dnl Software Foundation; either version 3 of the License, or (at your 14dnl option) any later version. 15dnl 16dnl or 17dnl 18dnl * the GNU General Public License as published by the Free Software 19dnl Foundation; either version 2 of the License, or (at your option) any 20dnl later version. 21dnl 22dnl or both in parallel, as here. 23dnl 24dnl The GNU MP Library is distributed in the hope that it will be useful, but 25dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 26dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 27dnl for more details. 28dnl 29dnl You should have received copies of the GNU General Public License and the 30dnl GNU Lesser General Public License along with the GNU MP Library. If not, 31dnl see https://www.gnu.org/licenses/. 32 33include(`../config.m4') 34 35C cycles/limb 36C StrongARM ? 37C XScale ? 38C Cortex-A7 ? 39C Cortex-A8 ? 40C Cortex-A9 10 41C Cortex-A15 9 42 43C Architecture requirements: 44C v5 - 45C v5t - 46C v5te - 47C v6 - 48C v6t2 - 49C v7a - 50 51define(`up', `r0') 52define(`n', `r1') 53define(`d', `r2') 54define(`cy', `r3') 55 56 .protected binvert_limb_table 57ASM_START() 58PROLOGUE(mpn_modexact_1c_odd) 59 stmfd sp!, {r4, r5} 60 61 LEA( r4, binvert_limb_table) 62 63 ldr r5, [up], #4 C up[0] 64 65 and r12, d, #254 66 ldrb r4, [r4, r12, lsr #1] 67 mul r12, r4, r4 68 mul r12, d, r12 69 rsb r12, r12, r4, asl #1 70 mul r4, r12, r12 71 mul r4, d, r4 72 rsb r4, r4, r12, asl #1 C r4 = inverse 73 74 subs n, n, #1 C set carry as side-effect 75 beq L(end) 76 77L(top): sbcs cy, r5, cy 78 ldr r5, [up], #4 79 sub n, n, #1 80 mul r12, r4, cy 81 tst n, n 82 umull r12, cy, d, r12 83 bne L(top) 84 85L(end): sbcs cy, r5, cy 86 mul r12, r4, cy 87 umull r12, r0, d, r12 88 addcc r0, r0, #1 89 90 ldmfd sp!, {r4, r5} 91 ret r14 92EPILOGUE() 93