4

I have a simple assembly file (temp.S) with one thumb2 (T32) instruction. for exmaple: orr R4,R7,R8
I want to assemble it with the linaro assembler but I can't find the right flags to do it.

if I try:

arm-linux-gnueabihf-as -o temp.o temp.S  

then I get the assembly of the A32 version of the instruction

however, if I try:

arm-linux-gnueabihf-as -o temp.o -mthumb temp.S  

I get the error messages

>  temp.S: Assembler messages:  
>  temp.S:1: Error: lo register required -- `orr R4,R7,R8  

as if it was expecting a T16 instruction.

Any help with the correct flags for T32 instructions would be appreciated.

By the way, my assembler version is: GNU assembler (crosstool-NG linaro-1.13.1-4.8-2014.01 - Linaro GCC 2013.11) 2.24.0.20131220

LorDex
  • 2,591
  • 1
  • 20
  • 32
siwesam
  • 463
  • 5
  • 8
  • 2
    What if you add `.syntax unified` and `.code 16` at the top of your assembly file(s) and skip the `-mthumb` command line option? – Michael Jul 28 '14 at 10:56
  • Agree with Michael, that works just fine. – old_timer Jul 28 '14 at 13:43
  • GCC 4.5 doc mentions behaviour of -mthumb better than the current version of the same doc https://gcc.gnu.org/onlinedocs/gcc-4.4.5/gcc/ARM-Options.html – auselen Jul 28 '14 at 16:01

1 Answers1

3

Quoting from the Ubuntu wiki:

For historical reasons as does support a -mthumb command-line option, but it doesn't do what you want: this enables the older Thumb-1, which has it's own, incompatible syntax. To produce Thumb-2 code you still need to turn on unified assembler syntax, which can only be done using the .syntax unified directive in the assembler source. To keep everything in one place and avoid confusion, it's better to control the assembler output mode with directives rather than attempting to control it on the command line.


TL;DR, put this in your assembly file(s):

.syntax unified /* use unified assembler syntax */
.code 16        /* assemble in Thumb-2  (.thumb" can also be used) */
Michael
  • 57,169
  • 9
  • 80
  • 125
  • Most likely, setting [`-mcpu` or `-march`](https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html) would also be an alternative solution. `.syntax unified` will signal *thumb2* to the assembler. – artless noise Jul 28 '14 at 16:08