From 38435a9aff78b013067d1cccf7b9822af6e28cfb Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 11 Mar 2013 16:44:31 -0700 Subject: [PATCH] ARM: Convert string/ assembly to unified syntax. --- ports/ChangeLog.arm | 5 +++++ ports/sysdeps/arm/memcpy.S | 25 +++++++++++++------------ ports/sysdeps/arm/memmove.S | 25 +++++++++++++------------ ports/sysdeps/arm/memset.S | 35 +++++++++++++++++++---------------- ports/sysdeps/arm/strlen.S | 3 +++ 5 files changed, 53 insertions(+), 40 deletions(-) diff --git a/ports/ChangeLog.arm b/ports/ChangeLog.arm index 65b157e032..34a6cf334f 100644 --- a/ports/ChangeLog.arm +++ b/ports/ChangeLog.arm @@ -1,5 +1,10 @@ 2013-03-11 Roland McGrath + * sysdeps/arm/memcpy.S: Convert to unified assembly syntax. + * sysdeps/arm/memmove.S: Likewise. + * sysdeps/arm/memset.S: Likewise. + * sysdeps/arm/strlen.S: Likewise. + * sysdeps/arm/memcpy.S: Use r10 instead of r9. * sysdeps/arm/memmove.S: Likewise. diff --git a/ports/sysdeps/arm/memcpy.S b/ports/sysdeps/arm/memcpy.S index c8f5535140..eb9699ddf6 100644 --- a/ports/sysdeps/arm/memcpy.S +++ b/ports/sysdeps/arm/memcpy.S @@ -53,6 +53,7 @@ #endif .text + .syntax unified /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */ @@ -84,7 +85,7 @@ ENTRY(memcpy) CALGN( ands ip, r1, #31 ) CALGN( rsb r3, ip, #32 ) - CALGN( sbcnes r4, r3, r2 ) @ C is always set here + CALGN( sbcsne r4, r3, r2 ) @ C is always set here CALGN( bcs 2f ) CALGN( adr r4, 6f ) CALGN( subs r2, r2, r3 ) @ C gets set @@ -139,12 +140,12 @@ ENTRY(memcpy) cfi_restore (r8) 8: movs r2, r2, lsl #31 - ldrneb r3, [r1], #1 - ldrcsb r4, [r1], #1 - ldrcsb ip, [r1] - strneb r3, [r0], #1 - strcsb r4, [r0], #1 - strcsb ip, [r0] + ldrbne r3, [r1], #1 + ldrbcs r4, [r1], #1 + ldrbcs ip, [r1] + strbne r3, [r0], #1 + strbcs r4, [r0], #1 + strbcs ip, [r0] #if defined (__ARM_ARCH_4T__) && defined(__THUMB_INTERWORK__) pop {r0, r4, lr} @@ -160,11 +161,11 @@ ENTRY(memcpy) 9: rsb ip, ip, #4 cmp ip, #2 - ldrgtb r3, [r1], #1 - ldrgeb r4, [r1], #1 + ldrbgt r3, [r1], #1 + ldrbge r4, [r1], #1 ldrb lr, [r1], #1 - strgtb r3, [r0], #1 - strgeb r4, [r0], #1 + strbgt r3, [r0], #1 + strbge r4, [r0], #1 subs r2, r2, ip strb lr, [r0], #1 blt 8b @@ -185,7 +186,7 @@ ENTRY(memcpy) CALGN( ands ip, r1, #31 ) CALGN( rsb ip, ip, #32 ) - CALGN( sbcnes r4, ip, r2 ) @ C is always set here + CALGN( sbcsne r4, ip, r2 ) @ C is always set here CALGN( subcc r2, r2, ip ) CALGN( bcc 15f ) diff --git a/ports/sysdeps/arm/memmove.S b/ports/sysdeps/arm/memmove.S index 16cc8ce8c2..9e8ad65f44 100644 --- a/ports/sysdeps/arm/memmove.S +++ b/ports/sysdeps/arm/memmove.S @@ -53,6 +53,7 @@ #endif .text + .syntax unified /* * Prototype: void *memmove(void *dest, const void *src, size_t n); @@ -100,7 +101,7 @@ ENTRY(memmove) blt 5f CALGN( ands ip, r1, #31 ) - CALGN( sbcnes r4, ip, r2 ) @ C is always set here + CALGN( sbcsne r4, ip, r2 ) @ C is always set here CALGN( bcs 2f ) CALGN( adr r4, 6f ) CALGN( subs r2, r2, ip ) @ C is set here @@ -155,12 +156,12 @@ ENTRY(memmove) cfi_restore (r8) 8: movs r2, r2, lsl #31 - ldrneb r3, [r1, #-1]! - ldrcsb r4, [r1, #-1]! - ldrcsb ip, [r1, #-1] - strneb r3, [r0, #-1]! - strcsb r4, [r0, #-1]! - strcsb ip, [r0, #-1] + ldrbne r3, [r1, #-1]! + ldrbcs r4, [r1, #-1]! + ldrbcs ip, [r1, #-1] + strbne r3, [r0, #-1]! + strbcs r4, [r0, #-1]! + strbcs ip, [r0, #-1] #if defined (__ARM_ARCH_4T__) && defined (__THUMB_INTERWORK__) pop {r0, r4, lr} @@ -175,11 +176,11 @@ ENTRY(memmove) cfi_restore_state 9: cmp ip, #2 - ldrgtb r3, [r1, #-1]! - ldrgeb r4, [r1, #-1]! + ldrbgt r3, [r1, #-1]! + ldrbge r4, [r1, #-1]! ldrb lr, [r1, #-1]! - strgtb r3, [r0, #-1]! - strgeb r4, [r0, #-1]! + strbgt r3, [r0, #-1]! + strbge r4, [r0, #-1]! subs r2, r2, ip strb lr, [r0, #-1]! blt 8b @@ -200,7 +201,7 @@ ENTRY(memmove) CALGN( ands ip, r1, #31 ) CALGN( rsb ip, ip, #32 ) - CALGN( sbcnes r4, ip, r2 ) @ C is always set here + CALGN( sbcsne r4, ip, r2 ) @ C is always set here CALGN( subcc r2, r2, ip ) CALGN( bcc 15f ) diff --git a/ports/sysdeps/arm/memset.S b/ports/sysdeps/arm/memset.S index 9924cb9115..5e055adea8 100644 --- a/ports/sysdeps/arm/memset.S +++ b/ports/sysdeps/arm/memset.S @@ -20,6 +20,9 @@ #define NO_THUMB #include + .text + .syntax unified + /* void *memset (dstpp, c, len) */ ENTRY(memset) @@ -29,7 +32,7 @@ ENTRY(memset) 1: tst r3, #3 @ aligned yet? - strneb r1, [r3], #1 + strbne r1, [r3], #1 subne r2, r2, #1 bne 1b @@ -40,27 +43,27 @@ ENTRY(memset) 1: subs r2, r2, #8 - stmcsia r3!, {r1, ip} @ store up to 32 bytes per loop iteration - subcss r2, r2, #8 - stmcsia r3!, {r1, ip} - subcss r2, r2, #8 - stmcsia r3!, {r1, ip} - subcss r2, r2, #8 - stmcsia r3!, {r1, ip} + stmiacs r3!, {r1, ip} @ store up to 32 bytes per loop iteration + subscs r2, r2, #8 + stmiacs r3!, {r1, ip} + subscs r2, r2, #8 + stmiacs r3!, {r1, ip} + subscs r2, r2, #8 + stmiacs r3!, {r1, ip} bcs 1b and r2, r2, #7 2: subs r2, r2, #1 @ store up to 4 bytes per loop iteration - strcsb r1, [r3], #1 - subcss r2, r2, #1 - strcsb r1, [r3], #1 - subcss r2, r2, #1 - strcsb r1, [r3], #1 - subcss r2, r2, #1 - strcsb r1, [r3], #1 + strbcs r1, [r3], #1 + subscs r2, r2, #1 + strbcs r1, [r3], #1 + subscs r2, r2, #1 + strbcs r1, [r3], #1 + subscs r2, r2, #1 + strbcs r1, [r3], #1 bcs 2b - + DO_RET(lr) END(memset) libc_hidden_builtin_def (memset) diff --git a/ports/sysdeps/arm/strlen.S b/ports/sysdeps/arm/strlen.S index 2b947e240e..fef62cff47 100644 --- a/ports/sysdeps/arm/strlen.S +++ b/ports/sysdeps/arm/strlen.S @@ -25,6 +25,9 @@ * exit: r0 = len */ + .syntax unified + .text + ENTRY(strlen) bic r1, r0, $3 @ addr of word containing first byte ldr r2, [r1], $4 @ get the first word -- 2.11.4.GIT