LPCXpresso 4.2.3 assembler issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPCXpresso 4.2.3 assembler issue

837 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Thu Sep 13 03:10:19 MST 2012
[SIZE=2][FONT=Tahoma]I always tgought the GNU assembler allowed a relaxed format for three operand instructions;

I.e. "adds r1, r1, r2" can be written as "adds r1, r2" when the first two operands are the same.

Indeed (with the assembler with LPCXpresso 4.2.3 WinXP), this is the case.

However, if the second addend is of the form "r2, lsl #3" (for example) the relaxed format throws an error.

Any one have any comments or observations; Is this a bug?

An example [BTW I always invoke the assembler directly, NOT via 'cc']
Example1.s

[/FONT][/SIZE][FONT=Tahoma][SIZE=2]
.file    "Example1.s"
.syntax unified
.thumb

.text
.align 4,0

MyFunc:
.type    MyFunc, %function

    adds    r3, r3, r1, lsl #7    @ OK
    adds    r3, r1, lsl #7        @ this give error

    adds    r3, r3, r1        @ OK
    adds    r3, r1            @ also OK

    b    .

.size    MyFunc, .-MyFunc

.align 2,0
.pool

.align    4,0
[/SIZE][/FONT][SIZE=2][FONT=Tahoma]

Regards, Mike

[/FONT][/SIZE]
0 Kudos
Reply
4 Replies

819 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Fri Sep 14 16:10:00 MST 2012
[FONT=Tahoma][SIZE=2]Thanks for the info. I will read up [/SIZE][/FONT][FONT=Tahoma][SIZE=2]AAV7M. It's a pity that the GNU docs for the arm assember is so crap. :(

Cheers, Mike.
[/SIZE][/FONT]
0 Kudos
Reply

819 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cfb on Fri Sep 14 07:34:15 MST 2012
My guess was wrong :o However, according to the ARMv7-M Architecture Reference Manual there are three different possible encodings (called T1, T2 and T3) for the ADD (register) instruction. My interpretation is that T2 is used if the <Rd> is omitted but a shift is only allowed in T3.

Just to complicate things even further, there is another note:

"Inside an IT block, if ADD<c> <Rd>,<Rn>,<Rd> cannot be assembled using encoding T1, it is assembled using encoding T2 as though ADD<c> <Rd>,<Rn> had been written. To prevent this happening, use the .W qualifier."

See Page A7-224 for more detail.
0 Kudos
Reply

819 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cfb on Thu Sep 13 20:55:21 MST 2012

Quote: MikeSimmonds

[SIZE=2][FONT=Tahoma]Any one have any comments or observations; Is this a bug?[/FONT][/SIZE]


Just guessing as I can't try it out right now: as Thumb is specified it might be defaulting to 16-bit instructions. Try adds.w
0 Kudos
Reply

819 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Thu Sep 13 03:28:34 MST 2012
[FONT=Tahoma][SIZE=1]========================================
c:/dev/nxp/tools/bin/arm-none-eabi-as -version
GNU assembler (Red Suite 2010Q4 by Code Red) 2.20.51.20100809
Copyright 2010 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `arm-none-eabi'.
... Example1.s
c:/dev/nxp/tools/bin/arm-none-eabi-as    -g3 -mcpu=cortex-m3 -mthumb -I. -ashln -listing-cont-lines=20 -o Example1.o Example1.s
Example1.s: Assembler messages:
Example1.s:13: Error: garbage following instruction -- `adds r3,r1,lsl#7'
   1                  
   2                  .file    "Example1.s"
   3                  .syntax unified
   4                  .thumb
   5                  
   6                  .text
   7                  .align 4,0
   8                  
   9                  MyFunc:
  10                  .type    MyFunc, %function
  11                  
  12 ???? 13EBC113         adds    r3, r3, r1, lsl #7    @ OK
  13                      adds    r3, r1, lsl #7        @ this give error
  14                  
  15 ???? 5B18             adds    r3, r3, r1        @ OK
  16 ???? 5B18             adds    r3, r1            @ also OK
  17                  
  18                      b    .
  19                  
  20                  .size    MyFunc, .-MyFunc
  21                  
  22                  .align 2,0
  23                  .pool
  24                  
  25                  .align    4,0
  26                  
DEFINED SYMBOLS
                            *ABS*:00000000 Example1.s
          Example1.s:7      .text:00000000 $d
          Example1.s:9      .text:00000000 MyFunc
          Example1.s:12     .text:00000000 $t
          Example1.s:12     .text:00000000 L0
          Example1.s:15     .text:00000000 L0
          Example1.s:16     .text:00000000 L0
          Example1.s:18     .text:00000000 L0
          Example1.s:18     .text:00000000 L0
          Example1.s:20     .text:00000000 L0
          Example1.s:22     .text:00000000 $d
                      .debug_line:00000000 L0
          Example1.s:26     .debug_line:00000000 L0
                      .debug_line:0000002b L0
          Example1.s:26     .text:00000000 L0
                   .debug_aranges:00000000 L0
          Example1.s:26     .debug_aranges:00000010 L0
                   .debug_aranges:0000000c $d
                            .text:00000000 L0
          Example1.s:26     .text:00000000 L0
                      .debug_info:00000000 L0
                      .debug_info:00000047 L0
          Example1.s:26     .text:00000000 $t
                            .data:00000000 $d
                             .bss:00000000 $d
                  .ARM.attributes:00000021 $d
          Example1.s:26     .debug_line:00000000 $d
                      .debug_info:00000047 $d
                    .debug_abbrev:00000014 $d

UNDEFINED SYMBOLS
lsl
umake: *** [Example1.o] Error 1
[/SIZE][/FONT]
0 Kudos
Reply