-
-
Save kmackay/bba81bc0ea04c5516925 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uECC_VLI_API void uECC_vli_mult(uint32_t *result, const uint32_t *left, const uint32_t *right) { | |
register uint32_t *r0 __asm__("r0") = result; | |
register const uint32_t *r1 __asm__("r1") = left; | |
register const uint32_t *r2 __asm__("r2") = right; | |
__asm__ volatile ( | |
".syntax unified \n\t" | |
"ldmia r2!, {r3, r4, r5, r6} \n\t" // Load right number | |
"ldr r14, [r1], #4 \n\t" // Load left digit | |
"umull r7, r8, r3, r14 \n\t" | |
"str r7, [r0], #4 \n\t" // Store result digit | |
"mov r9, #0 \n\t" // Carry prepare | |
"umaal r8, r9, r4, r14 \n\t" // Multiply | |
"mov r10, #0 \n\t" // Carry prepare | |
"umaal r9, r10, r5, r14 \n\t" // Multiply | |
"mov r11, #0 \n\t" // Carry prepare | |
"umaal r10, r11, r6, r14 \n\t" // Multiply | |
REPEAT(7, | |
"ldr r14, [r1], #4 \n\t" // Load left digit | |
"mov r7, #0 \n\t" // Carry prepare | |
"umaal r7, r8, r3, r14 \n\t" // Multiply | |
"str r7, [r0], #4 \n\t" // Store partial result digit | |
"umaal r8, r9, r4, r14 \n\t" // Multiply | |
"umaal r9, r10, r5, r14 \n\t" // Multiply | |
"umaal r10, r11, r6, r14 \n\t" // Multiply | |
) | |
"str r8, [r0], #4 \n\t" // Store partial result digit | |
"str r9, [r0], #4 \n\t" // Store partial result digit | |
"str r10, [r0], #4 \n\t" // Store partial result digit | |
"str r11, [r0], #4 \n\t" // Store partial result digit | |
"sub r0, #32 \n\t" | |
"sub r1, #32 \n\t" | |
"ldmia r2!, {r3, r4, r5, r6} \n\t" // Load right number | |
"ldr r14, [r1], #4 \n\t" // Load left digit | |
"ldr r7, [r0] \n\t" // Load partial result digit | |
"mov r8, #0 \n\t" // Carry prepare | |
"umaal r7, r8, r3, r14 \n\t" // Multiply | |
"str r7, [r0], #4 \n\t" // Store result digit | |
"mov r9, #0 \n\t" // Carry prepare | |
"umaal r8, r9, r4, r14 \n\t" // Multiply | |
"mov r10, #0 \n\t" // Carry prepare | |
"umaal r9, r10, r5, r14 \n\t" // Multiply | |
"mov r11, #0 \n\t" // Carry prepare | |
"umaal r10, r11, r6, r14 \n\t" // Multiply | |
REPEAT(7, | |
"ldr r14, [r1], #4 \n\t" // Load left digit | |
"ldr r7, [r0] \n\t" // Load partial result digit | |
"umaal r7, r8, r3, r14 \n\t" // Multiply | |
"str r7, [r0], #4 \n\t" // Store result digit | |
"umaal r8, r9, r4, r14 \n\t" // Multiply | |
"umaal r9, r10, r5, r14 \n\t" // Multiply | |
"umaal r10, r11, r6, r14 \n\t" // Multiply | |
) | |
"str r8, [r0], #4 \n\t" // Store result digit | |
"str r9, [r0], #4 \n\t" // Store result digit | |
"str r10, [r0], #4 \n\t" // Store result digit | |
"str r11, [r0], #4 \n\t" // Store result digit | |
#if (uECC_PLATFORM != uECC_arm_thumb2) | |
".syntax divided \n\t" | |
#endif | |
: "+r" (r0), "+r" (r1), "+r" (r2) | |
: | |
: "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r14", "cc", "memory" | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment