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