mirror of
https://github.com/kmackay/micro-ecc.git
synced 2026-10-01 21:37:36 +00:00
Remove unnecessary zero test for a slight speed improvement.
This commit is contained in:
+6
-44
@@ -15571,26 +15571,10 @@ static void vli_mmod_fast(uint8_t *RESTRICT p_result, uint8_t *RESTRICT p_produc
|
|||||||
"adc %[carry], __zero_reg__ \n\t" /* Store carry bit (carry flag is cleared). */
|
"adc %[carry], __zero_reg__ \n\t" /* Store carry bit (carry flag is cleared). */
|
||||||
/* at this point x is at the end of p_product, y is at the end of p_result, z is 20 bytes into tmp */
|
/* at this point x is at the end of p_product, y is at the end of p_result, z is 20 bytes into tmp */
|
||||||
"sbiw r28, 20 \n\t" /* move y back to point at p_result */
|
"sbiw r28, 20 \n\t" /* move y back to point at p_result */
|
||||||
|
"adiw r30, 4 \n\t" /* move z to point to the end of tmp */
|
||||||
|
|
||||||
"eor r19, r19 \n\t"
|
/* do omega_mult again with the 4 relevant bytes */
|
||||||
"ld r18, z+ \n\t"
|
/* z points to the end of tmp, x points to the end of p_product */
|
||||||
"add r19, r18 \n\t"
|
|
||||||
"ld r18, z+ \n\t"
|
|
||||||
"adc r19, r18 \n\t"
|
|
||||||
"ld r18, z+ \n\t"
|
|
||||||
"adc r19, r18 \n\t"
|
|
||||||
"ld r18, z+ \n\t"
|
|
||||||
"adc r19, r18 \n\t"
|
|
||||||
/* now z points to the end of tmp */
|
|
||||||
"brcs mmod_remult \n\t" /* carry was set, so something was not zero (need to mult again) */
|
|
||||||
"cp r19, __zero_reg__ \n\t"
|
|
||||||
"brne mmod_remult \n\t" /* sum was not equal to zero (need to mult again) */
|
|
||||||
"rjmp mmod_after_remult \n\t"
|
|
||||||
|
|
||||||
"mmod_remult: \n\t" /* do omega_mult with the 4 relevant bytes */
|
|
||||||
|
|
||||||
/* z already points to the end of tmp, x points to the end of p_product */
|
|
||||||
|
|
||||||
"ld r18, -z \n\t" /* Load word. */
|
"ld r18, -z \n\t" /* Load word. */
|
||||||
"lsr r18 \n\t" /* Shift. */
|
"lsr r18 \n\t" /* Shift. */
|
||||||
"st -x, r18 \n\t" /* Store the first result word. */
|
"st -x, r18 \n\t" /* Store the first result word. */
|
||||||
@@ -15660,8 +15644,6 @@ static void vli_mmod_fast(uint8_t *RESTRICT p_result, uint8_t *RESTRICT p_produc
|
|||||||
"adc %[carry], __zero_reg__ \n\t" /* Store carry bit (carry flag is cleared). */
|
"adc %[carry], __zero_reg__ \n\t" /* Store carry bit (carry flag is cleared). */
|
||||||
"sbiw r28, 20 \n\t" /* move y back to point at p_result */
|
"sbiw r28, 20 \n\t" /* move y back to point at p_result */
|
||||||
|
|
||||||
"mmod_after_remult: \n\t"
|
|
||||||
|
|
||||||
"sbiw r30, 1 \n\t" /* fix stack pointer */
|
"sbiw r30, 1 \n\t" /* fix stack pointer */
|
||||||
"in r0, __SREG__ \n\t"
|
"in r0, __SREG__ \n\t"
|
||||||
"cli \n\t"
|
"cli \n\t"
|
||||||
@@ -15886,27 +15868,9 @@ static void vli_mmod_fast(uint8_t *RESTRICT p_result, uint8_t *RESTRICT p_produc
|
|||||||
"adc %[carry], __zero_reg__ \n\t" /* Store carry bit (carry flag is cleared). */
|
"adc %[carry], __zero_reg__ \n\t" /* Store carry bit (carry flag is cleared). */
|
||||||
/* at this point x is at the end of p_product, y is at the end of p_result, z is 32 bytes into tmp */
|
/* at this point x is at the end of p_product, y is at the end of p_result, z is 32 bytes into tmp */
|
||||||
"sbiw r28, 32 \n\t" /* move y back to point at p_result */
|
"sbiw r28, 32 \n\t" /* move y back to point at p_result */
|
||||||
|
|
||||||
"eor r19, r19 \n\t"
|
/* do omega_mult again with the 5 relevant bytes */
|
||||||
"ld r18, z+ \n\t"
|
/* z points to l_tmp + uECC_WORDS, x points to the end of p_product */
|
||||||
"add r19, r18 \n\t"
|
|
||||||
"ld r18, z+ \n\t"
|
|
||||||
"adc r19, r18 \n\t"
|
|
||||||
"ld r18, z+ \n\t"
|
|
||||||
"adc r19, r18 \n\t"
|
|
||||||
"ld r18, z+ \n\t"
|
|
||||||
"adc r19, r18 \n\t"
|
|
||||||
"ld r18, z+ \n\t"
|
|
||||||
"adc r19, r18 \n\t"
|
|
||||||
/* now z points to the end of tmp */
|
|
||||||
"brcs mmod_remult \n\t" /* carry was set, so something was not zero (need to mult again) */
|
|
||||||
"cp r19, __zero_reg__ \n\t"
|
|
||||||
"brne mmod_remult \n\t" /* sum was not equal to zero (need to mult again) */
|
|
||||||
"rjmp mmod_after_remult \n\t"
|
|
||||||
|
|
||||||
"mmod_remult: \n\t" /* do omega_mult with the 5 relevant bytes */
|
|
||||||
/* z points to the end of tmp, x points to the end of p_product */
|
|
||||||
"sbiw r30, 5 \n\t" /* move z back to point at l_tmp + uECC_WORDS */
|
|
||||||
"sbiw r26, 32 \n\t" /* shift x back to point into the p_product buffer (we can overwrite it now) */
|
"sbiw r26, 32 \n\t" /* shift x back to point into the p_product buffer (we can overwrite it now) */
|
||||||
|
|
||||||
"ld r18, z+ \n\t"
|
"ld r18, z+ \n\t"
|
||||||
@@ -16003,8 +15967,6 @@ static void vli_mmod_fast(uint8_t *RESTRICT p_result, uint8_t *RESTRICT p_produc
|
|||||||
"adc %[carry], __zero_reg__ \n\t" /* Store carry bit (carry flag is cleared). */
|
"adc %[carry], __zero_reg__ \n\t" /* Store carry bit (carry flag is cleared). */
|
||||||
"sbiw r28, 32 \n\t" /* move y back to point at p_result */
|
"sbiw r28, 32 \n\t" /* move y back to point at p_result */
|
||||||
|
|
||||||
"mmod_after_remult: \n\t"
|
|
||||||
|
|
||||||
"sbiw r30, 1 \n\t" /* fix stack pointer */
|
"sbiw r30, 1 \n\t" /* fix stack pointer */
|
||||||
"in r0, __SREG__ \n\t"
|
"in r0, __SREG__ \n\t"
|
||||||
"cli \n\t"
|
"cli \n\t"
|
||||||
|
|||||||
@@ -785,12 +785,9 @@ static void vli_mmod_fast(uECC_word_t *RESTRICT p_result, uECC_word_t *RESTRICT
|
|||||||
omega_mult(l_tmp, p_product + uECC_WORDS); /* (Rq, q) = q * c */
|
omega_mult(l_tmp, p_product + uECC_WORDS); /* (Rq, q) = q * c */
|
||||||
|
|
||||||
l_carry = vli_add(p_result, p_product, l_tmp); /* (C, r) = r + q */
|
l_carry = vli_add(p_result, p_product, l_tmp); /* (C, r) = r + q */
|
||||||
if(!vli_isZero(l_tmp + uECC_WORDS)) /* if Rq > 0 */
|
vli_clear(p_product);
|
||||||
{
|
omega_mult(p_product, l_tmp + uECC_WORDS); /* Rq*c */
|
||||||
vli_clear(p_product);
|
l_carry += vli_add(p_result, p_result, p_product); /* (C1, r) = r + Rq*c */
|
||||||
omega_mult(p_product, l_tmp + uECC_WORDS); /* Rq*c */
|
|
||||||
l_carry += vli_add(p_result, p_result, p_product); /* (C1, r) = r + Rq*c */
|
|
||||||
}
|
|
||||||
|
|
||||||
while(l_carry > 0)
|
while(l_carry > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user