Hi,
I'm somewhat confused with the Thumb mode code size. My understanding is compiling with ARM mode will generate 32-bit instructions and compiling with Thumb mode will generate 16-bit instructions. When I compile my Cortex-M0+ project (which should use Thumb mode instructions only), the output binary file always increments in multiple of 4 bytes. Do I miss something here?
Here are the instructions I use:
armcc -c -O3 -Ospace --cpu Cortex-M0plus --thumb --apcs=interwork -I ./ -g -c aaa.c -o aaa.o
armasm --cpu Cortex-M0plus --apcs=interwork -I ./ -g startup.s -o startup.o
armlink --cpu Cortex-M0plus --ro_base 0x00000000 --rw-base 0x00100000 --entry Reset_Handler --first __Vectors aaa.o startup.o -o aaa.axf
Thanks,
The AXF file contains a lot of other information - it's not just a raw hex file containing only the code, and different sections in it have alignment requirements the extra bits are probably just padding. If you want to get an accurate look at the size of the code use fromelf to disassemble it.
Forget to say, I'm referring the binary image size, not axf size.
fromelf --bin -o aaa.bin aaa.axf
I'd still dump out the disassembly and take a look at what it's doing - it wouldn't surprise me if the tools pad out to 4 byte multiples so the loader can use 32-bit loads.
View all questions in Cortex-M / M-Profile forum