diff --git a/library/bn_mul.h b/library/bn_mul.h index 05ee27b6b93d..275be604841b 100644 --- a/library/bn_mul.h +++ b/library/bn_mul.h @@ -711,19 +711,27 @@ defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1) #define MULADDC_X1_INIT \ - asm( + { \ + mbedtls_mpi_uint tmp_a, tmp_b; \ + asm volatile ( -#define MULADDC_X1_CORE \ - "ldr r0, [%0], #4 \n\t" \ - "ldr r1, [%1] \n\t" \ - "umaal r1, %2, %3, r0 \n\t" \ - "str r1, [%1], #4 \n\t" +#define MULADDC_X1_CORE \ + ".p2align 2 \n\t" \ + "ldr.w %[a], [%[in]], #4 \n\t" \ + "ldr.w %[b], [%[acc]] \n\t" \ + "umaal %[b], %[carry], %[scalar], %[a] \n\t" \ + "str.w %[b], [%[acc]], #4 \n\t" -#define MULADDC_X1_STOP \ - : "=r" (s), "=r" (d), "=r" (c) \ - : "r" (b), "0" (s), "1" (d), "2" (c) \ - : "r0", "r1", "memory" \ - ); +#define MULADDC_X1_STOP \ + : [a] "=&r" (tmp_a), \ + [b] "=&r" (tmp_b), \ + [in] "+r" (s), \ + [acc] "+r" (d), \ + [carry] "+l" (c) \ + : [scalar] "r" (b) \ + : "memory" \ + ); \ + } #define MULADDC_X2_INIT \ { \