[PATCH] arm/strlen-thumb2-Os.S: Correct assembly syntax for ldrb instruction

Richard Earnshaw Richard.Earnshaw@foss.arm.com
Fri May 15 13:25:15 GMT 2020


On 12/05/2020 18:58, Keith Packard via Newlib wrote:
> We want to use a post-indexed addressing mode (which means use the
> original register contents as the address, then increment that
> register) which is only valid in Encoding T3 of the LDRB instruction.
> 
> According to the ARMv7-M Architecture Reference Manual, the assembly
> syntax for Encoding T3 does not include the '.W' width specifier as
> that is used to specify Encoding T2, presumably to provide a wider
> immediate field for possible relocations.
> 
> GAS allows the .W specifier for this addressing mode and generates
> identical output with and without it. clang does not allow the .W
> specifier for this addressing mode, so removing it offers wider
> portability and closer adherance to the ARM assembly syntax
> specification.
> 
> Signed-off-by: Keith Packard <keithp@keithp.com>
> ---
>  newlib/libc/machine/arm/strlen-thumb2-Os.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/newlib/libc/machine/arm/strlen-thumb2-Os.S b/newlib/libc/machine/arm/strlen-thumb2-Os.S
> index 961f41a0a..aed8adf33 100644
> --- a/newlib/libc/machine/arm/strlen-thumb2-Os.S
> +++ b/newlib/libc/machine/arm/strlen-thumb2-Os.S
> @@ -45,7 +45,7 @@
>  
>  def_fn	strlen p2align=1
>  	mov     r3, r0
> -1:	ldrb.w  r2, [r3], #1
> +1:	ldrb    r2, [r3], #1
>  	cmp     r2, #0
>  	bne	1b
>  	subs    r0, r3, r0
> 

IIRC the .w was deliberate to keep the alignment right for some
subsequent instructions.

LLVM's assembler needs fixing if it doesn't accept '.w'.

R.


More information about the Newlib mailing list