From 2d8a6e3856d2e303247e96cd51b094d5b6f29529 Mon Sep 17 00:00:00 2001 From: Ken MacKay Date: Thu, 30 May 2013 21:04:21 -0700 Subject: [PATCH] Fixed constraints on inline asm. --- ecc.c | 8 ++++++++ ecc.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ecc.c b/ecc.c index 023a709..1af872e 100644 --- a/ecc.c +++ b/ecc.c @@ -192,7 +192,11 @@ static uint32_t vli_add(uint32_t *p_result, uint32_t *p_left, uint32_t *p_right) #if (ECC_ASM != ecc_asm_thumb2) ".syntax divided \n\t" #endif + #if (ECC_ASM == ecc_asm_thumb) : [dptr] "+l" (p_result), [lptr] "+l" (p_left), [rptr] "+l" (p_right), [ctr] "+l" (l_counter), [carry] "+l" (l_carry), [left] "=l" (l_left), [right] "=l" (l_right) + #else + : [dptr] "+r" (p_result), [lptr] "+r" (p_left), [rptr] "+r" (p_right), [ctr] "+r" (l_counter), [carry] "+r" (l_carry), [left] "=r" (l_left), [right] "=r" (l_right) + #endif : : "cc", "memory" ); @@ -238,7 +242,11 @@ static uint32_t vli_sub(uint32_t *p_result, uint32_t *p_left, uint32_t *p_right) #if (ECC_ASM != ecc_asm_thumb2) ".syntax divided \n\t" #endif + #if (ECC_ASM == ecc_asm_thumb) : [dptr] "+l" (p_result), [lptr] "+l" (p_left), [rptr] "+l" (p_right), [ctr] "+l" (l_counter), [carry] "+l" (l_carry), [left] "=l" (l_left), [right] "=l" (l_right) + #else + : [dptr] "+r" (p_result), [lptr] "+r" (p_left), [rptr] "+r" (p_right), [ctr] "+r" (l_counter), [carry] "+r" (l_carry), [left] "=r" (l_left), [right] "=r" (l_right) + #endif : : "cc", "memory" ); diff --git a/ecc.h b/ecc.h index 22a91a7..dc67f0a 100644 --- a/ecc.h +++ b/ecc.h @@ -14,7 +14,7 @@ ECC_USE_NAF - If enabled, this will convert the private key to a non-adjacent fo /* Inline assembly options. Inline assembly (gcc format) is provided for selected operations for Thumb and Thumb2/ARM. -Improves speed by about 57% on Cortex-M0. +Improves speed by about 57% on Cortex-M0 when using ecc_asm_thumb. Note: You must choose the appropriate option for your target architecture, or compilation will fail with strange assembler messages.