On 2015-06-15 10:11:50 +0300, Martin Storsjö wrote:
> On Mon, 15 Jun 2015, Janne Grunau wrote:
> 
> >On 2015-06-13 11:03:42 +0300, Martin Storsjö wrote:
> >>---
> >> gas-preprocessor.pl | 4 ++--
> >> 1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >>diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
> >>index 7ba31fe..4407f45 100755
> >>--- a/gas-preprocessor.pl
> >>+++ b/gas-preprocessor.pl
> >>@@ -947,8 +947,8 @@ sub handle_serialized_line {
> >>         s/mov\s*pc\s*,\s*lr/bx lr/g;
> >>
> >>         # Convert stmdb/ldmia with only one register into a plain str/ldr 
> >> with post-increment/decrement
> >
> >please add "wide thumb2 encoding requires at least two registers in
> >register list while all other encodings support one register too" to the
> >comment.
> 
> Ok
> 
> >>-        $line =~ s/stmdb\s+sp!\s*,\s*\{([^,-]+)\}/str $1, [sp, #-4]!/g;
> >>-        $line =~ s/ldmia\s+sp!\s*,\s*\{([^,-]+)\}/ldr $1, [sp], #4/g;
> >>+        $line =~ s/stm(?:db|fd)\s+sp!\s*,\s*\{([^,-]+)\}/str $1, [sp, 
> >>#-4]!/g;
> >>+        $line =~ s/ldm(?:ia|fd)\s+sp!\s*,\s*\{([^,-]+)\}/ldr $1, [sp], 
> >>#4/g;
> >
> >please handle the UAL syntax ldm/stm too while you're at it
> 
> Hmm, so just a ? after the (?:db|fd) group?

yes, but just for the ldm. see below

> Is a plain "stm sp!, {...}" supposed to subtract, not add? I tested
> the following snippet with gas:
>
>         .text
> #       .thumb
>         .syntax unified
> 
>         stm     sp!, {r1}
>         stmia   sp!, {r1}
>         stmdb   sp!, {r1}
>         stmfd   sp!, {r1}
> 
> In ARM mode, the stm assembles in the same way as stmia, i.e.
> ascending, not descending. In thumb mode, however, the stm and stmia
> assemble into "str.w r1, [sp, #-4]!", while the stmdb/stmfd assemble
> into "push {r1}" (which is functionally equivalent).

you seemed to have the cases mixed up. stm/stmia translates to push {r1} 
here. that is still wrong though push should decrement the base pointer 
while stm/stmia should increment them

> So the stm instruction (and stmia as well) seems to adjust the base
> register in different direction (but only if the base register is
> sp) depending on arm/thumb mode, even if .syntax unified is used.

More likely a bug in binutils but at least it is smart enough not to 
generate an unpredictable encoding unlike llvm's internal assembler.

Janne
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to