Skip to content

Commit 60909d5

Browse files
Merge pull request #6971 from SparkiDev/iar_thumb2_asm
IAR Thumb2 ASM: fixes
2 parents ebbeb6c + 9ac3083 commit 60909d5

15 files changed

Lines changed: 3986 additions & 2408 deletions

wolfcrypt/src/port/arm/thumb2-aes-asm.S

Lines changed: 236 additions & 176 deletions
Large diffs are not rendered by default.

wolfcrypt/src/port/arm/thumb2-aes-asm_c.c

Lines changed: 411 additions & 257 deletions
Large diffs are not rendered by default.

wolfcrypt/src/port/arm/thumb2-curve25519.S

Lines changed: 386 additions & 386 deletions
Large diffs are not rendered by default.

wolfcrypt/src/port/arm/thumb2-curve25519_c.c

Lines changed: 109 additions & 109 deletions
Large diffs are not rendered by default.

wolfcrypt/src/port/arm/thumb2-sha256-asm.S

Lines changed: 58 additions & 58 deletions
Large diffs are not rendered by default.

wolfcrypt/src/port/arm/thumb2-sha256-asm_c.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#ifdef WOLFSSL_ARMASM_INLINE
4040

4141
#ifdef WOLFSSL_ARMASM
42-
#if !defined(__aarch64__) && defined(__arm__)
42+
#if !defined(__aarch64__) && defined(__thumb__)
4343

4444
#ifdef __IAR_SYSTEMS_ICC__
4545
#define __asm__ asm
@@ -84,8 +84,8 @@ void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, word32 len)
8484
register wc_Sha256* sha256 __asm__ ("r0") = (wc_Sha256*)sha256_p;
8585
register const byte* data __asm__ ("r1") = (const byte*)data_p;
8686
register word32 len __asm__ ("r2") = (word32)len_p;
87-
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
8887
register uint32_t* L_SHA256_transform_len_k_c __asm__ ("r3") = (uint32_t*)&L_SHA256_transform_len_k;
88+
#endif /* !WOLFSSL_NO_VAR_ASSIGN_REG */
8989

9090
__asm__ __volatile__ (
9191
"SUB sp, sp, #0xc0\n\t"
@@ -101,7 +101,7 @@ void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, word32 len)
101101
"STRD r10, r11, [sp, #88]\n\t"
102102
/* Start of loop processing a block */
103103
"\n"
104-
"L_SHA256_transform_len_begin_%=:\n\t"
104+
"L_SHA256_transform_len_begin:\n\t"
105105
/* Load, Reverse and Store W - 64 bytes */
106106
"LDR r4, [%[data]]\n\t"
107107
"LDR r5, [%[data], #4]\n\t"
@@ -149,7 +149,7 @@ void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, word32 len)
149149
"MOV r12, #0x3\n\t"
150150
/* Start of 16 rounds */
151151
"\n"
152-
"L_SHA256_transform_len_start_%=:\n\t"
152+
"L_SHA256_transform_len_start:\n\t"
153153
/* Round 0 */
154154
"LDR r5, [%[sha256], #16]\n\t"
155155
"LDR r6, [%[sha256], #20]\n\t"
@@ -904,10 +904,10 @@ void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, word32 len)
904904
"STR r9, [sp, #60]\n\t"
905905
"ADD r3, r3, #0x40\n\t"
906906
"SUBS r12, r12, #0x1\n\t"
907-
#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__)
908-
"BNE L_SHA256_transform_len_start_%=\n\t"
907+
#ifdef __GNUC__
908+
"BNE L_SHA256_transform_len_start\n\t"
909909
#else
910-
"BNE.N L_SHA256_transform_len_start_%=\n\t"
910+
"BNE.W L_SHA256_transform_len_start\n\t"
911911
#endif
912912
/* Round 0 */
913913
"LDR r5, [%[sha256], #16]\n\t"
@@ -1449,14 +1449,20 @@ void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, word32 len)
14491449
"SUBS %[len], %[len], #0x40\n\t"
14501450
"SUB r3, r3, #0xc0\n\t"
14511451
"ADD %[data], %[data], #0x40\n\t"
1452-
#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__)
1453-
"BNE L_SHA256_transform_len_begin_%=\n\t"
1452+
#ifdef __GNUC__
1453+
"BNE L_SHA256_transform_len_begin\n\t"
14541454
#else
1455-
"BNE.N L_SHA256_transform_len_begin_%=\n\t"
1455+
"BNE.W L_SHA256_transform_len_begin\n\t"
14561456
#endif
14571457
"ADD sp, sp, #0xc0\n\t"
1458-
: [sha256] "+r" (sha256), [data] "+r" (data), [len] "+r" (len), [L_SHA256_transform_len_k] "+r" (L_SHA256_transform_len_k_c)
1458+
#ifndef WOLFSSL_NO_VAR_ASSIGN_REG
1459+
: [sha256] "+r" (sha256), [data] "+r" (data), [len] "+r" (len),
1460+
[L_SHA256_transform_len_k] "+r" (L_SHA256_transform_len_k_c)
14591461
:
1462+
#else
1463+
: [sha256] "+r" (sha256), [data] "+r" (data), [len] "+r" (len)
1464+
: [L_SHA256_transform_len_k] "r" (L_SHA256_transform_len_k)
1465+
#endif /* WOLFSSL_NO_VAR_ASSIGN_REG */
14601466
: "memory", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
14611467
);
14621468
}
@@ -1465,7 +1471,7 @@ void Transform_Sha256_Len(wc_Sha256* sha256, const byte* data, word32 len)
14651471
#endif /* !NO_SHA256 */
14661472
#endif /* !__aarch64__ && __thumb__ */
14671473
#endif /* WOLFSSL_ARMASM */
1468-
#endif /* !defined(__aarch64__) && defined(__arm__) */
1474+
#endif /* !defined(__aarch64__) && defined(__thumb__) */
14691475
#endif /* WOLFSSL_ARMASM */
14701476

14711477
#endif /* WOLFSSL_ARMASM_INLINE */

0 commit comments

Comments
 (0)