仅编译thumb1

Ale*_*der 5 compiler-construction gcc arm thumb

如何告诉gcc编译成仅限Thumb1的指令?

每个人都知道helloworld.c:

#include <stdio.h>  
main() {  
 printf("Hello world");  
}  
Run Code Online (Sandbox Code Playgroud)

这是我的命令行:

user @ debian-armel:〜$ gcc -mcpu = cortex-m3 -mthumb helloworld.c && objdump -d a.out

瞧:大多数指令是32位宽,而不是我预期的16位.

那么,我做错了什么?

Igo*_*sky 4

Cortex-M3 支持 Thumb-2,因此编译器可以自由生成 32 位版本。以下之一应该可以满足您的需求:

-march=ARMv5 -mthumb
-march=ARMv4T -mthumb
-march=ARMv6-M
-mcpu=Cortex-M0
Run Code Online (Sandbox Code Playgroud)

  • 不,Cortex-M0 和 Cortex-M0+ 不支持 Thumb-2,BL 和一些系统指令(MSR、MRS、DSB、DMB、ISB)除外。请参阅[ARMv6-M 架构参考手册](http://infocenter.arm.com/help/topic/com.arm.doc.ddi0419c/index.html)。 (2认同)