Skip to content

Commit

Permalink
Make UMAAL-based bignum assembly more readable
Browse files Browse the repository at this point in the history
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
  • Loading branch information
Hanno Becker committed Apr 7, 2022
1 parent 40b2c0a commit be109c0
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions library/bn_mul.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,19 +710,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 \
{ \
Expand Down

0 comments on commit be109c0

Please sign in to comment.