Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile thumb1 only

How do I tell gcc to compile into Thumb1-only instructions?

Everyone knows helloworld.c:

#include <stdio.h>  
main() {  
 printf("Hello world");  
}  

And this is my command line:

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

And voilá: most instructions are 32bit wide, as opposed to the 16bit I expected.

So, what am I doing wrong?

like image 598
Alexander Avatar asked Nov 20 '12 13:11

Alexander


1 Answers

Cortex-M3 supports Thumb-2 so the compiler is free to generate 32-bit versions. One of the following should achieve what you need:

-march=ARMv5 -mthumb
-march=ARMv4T -mthumb
-march=ARMv6-M
-mcpu=Cortex-M0
like image 153
Igor Skochinsky Avatar answered Nov 03 '22 01:11

Igor Skochinsky