简体   繁体   中英

ARM GCC inline assembly

I am trying the following :

int main()
{
    unsigned int result = 0;

    unsigned int op1 = 10, op2 = 20;
    asm volatile ("uadd8 %0, %1, %2" :
                "=r" (result) :
                "r" (op1), "r" (op2) );

}

I want to compile this for Cortex A9 I am using arm GNU GCC toolchain.

But I keep getting this error:

arm-none-linux-gnueabi-gcc test_2.c

Assembler messages:

Error: selected processor does not support ARM mode `uadd8 r4,r3,r2'

I tried by forcing to thumb mode by adding .code 16 also but no luck .

What is the issue here ?

The reason is that the default ARM architecture in your compiler does not implement that instruction. The uadd8 is supported in Thumb mode for architectures ARMv6T2 and ARMv7 and in ARM mode for ARMv6 and ARMv7. Hence you need to pass the proper -march= option to gcc . For example:

 -march=armv6
 -march=armv6t2 -mthumb
 -march=armv7-a
 -march=armv7-a -marm

You can check what is the default (or set by options) architecture for the compilation with:

arm-elf-gcc -E -dM -x c /dev/null | grep ARM_ARCH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM