This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH ARM/THUMB] replace mov with movs in crt0.S


On 23/11/11 14:12, Thomas Klein wrote:
> Hi,
> 
> When using 'unified syntax' a MOV rd, rs with two low registers isn't
> present for all thumb architectures.
> The result would be unpredictable when running on v4t or v5t architectures.
> 
> In case of not using the condition flags a MOVS rd, rs (alias LSLS Rd, 
> Rs, #0)
> can be used instead.
> 
> Is this correct, or is there anything wrong with this idea.
> 

So looking at the entire source for crt0.S, the only use of unified
syntax is conditional upon __thumb2__ being defined.  If that is defined
then the 16-bit MOV lo, lo instruction is available.

What options are you using to build newlib that is causing you to see a
problem here?

R.

> Regards
>    Thomas
> 
> 
> 
> diff.out
> 
> 
> Index: newlib/libc/sys/arm/crt0.S
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/sys/arm/crt0.S,v
> retrieving revision 1.14
> diff -u -p -r1.14 crt0.S
> --- newlib/libc/sys/arm/crt0.S	11 Oct 2011 09:29:56 -0000	1.14
> +++ newlib/libc/sys/arm/crt0.S	23 Nov 2011 12:35:06 -0000
> @@ -286,7 +286,7 @@ __change_mode:	
>  	cmp	r3, #'\''
>  	bne	.LC21
>  .LC20:
> -	mov	r2, r3
> +	movs	r2, r3
>  	b	.LC22
>  
>  .LC21:
> @@ -327,7 +327,7 @@ __change_mode:	
>  	mov	r1, sp		/* Point at stacked arg pointers.  */
>  	/* We've now got the stacked args in order, reverse them.  */
>  #ifdef __thumb__
> -	mov	r2, r0
> +	movs	r2, r0
>  	lsls	r2, #2
>  	add	r2, sp
>  	mov	r3, sp
> @@ -365,13 +365,13 @@ __change_mode:	
>  	   to create constructors and destructors, and for these
>  	   targets we need to call the _init function and arrange
>  	   for _fini to be called at program exit.  */
> -	mov	r4, r0
> -	mov	r5, r1
> +	movs	r4, r0
> +	movs	r5, r1
>  	ldr	r0, .Lfini
>  	bl	FUNCTION (atexit)
>  	bl	FUNCTION (_init)
> -	mov	r0, r4
> -	mov	r1, r5
> +	movs	r0, r4
> +	movs	r1, r5
>  #endif	
>  	bl	FUNCTION (main)
>  
> 
> 
> ChangeLog
> 
> 
> 2011-11-23  Thomas Klein  <th.r.klein@web.de>
> 
> 	* libc/sys/arm/crt0.S (__change_mode): Replace MOV with MOVS to allow
> 	a low register move even for architecures v4t or v5t.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]