How to force gcc generate thumb 32 bit instructions?

1.5k views Asked by At

Is it possible to force generating thumb 32 bit instructions when possible?

For example I have:

int main(void) {
 8000280:   b480        push    {r7}
 8000282:   b085        sub sp, #20
 8000284:   af00        add r7, sp, #0
    uint32_t a, b, c;

    a = 1;
 8000286:   2301        movs    r3, #1
 8000288:   60fb        str r3, [r7, #12]
    b = 1;
 800028a:   2301        movs    r3, #1
 800028c:   60bb        str r3, [r7, #8]
    c = a+b;
 800028e:   68fa        ldr r2, [r7, #12]
 8000290:   68bb        ldr r3, [r7, #8]
 8000292:   4413        add r3, r2
 8000294:   607b        str r3, [r7, #4]

    while (1) ;
 8000296:   e7fe        b.n 8000296 <main+0x16>

But they are all thumb 16 bit. For testing reason I want thumb 32 bit instructions.

1

There are 1 answers

0
Freddie Chopin On

Well, I don't think you can do that directly, but there is a very strange way of achieving that in a very indirect way. Just a few days ago I've seen a project where the compilation process was not just a simple arm-none-eabi-gcc ... -c file.c -o file.o. The project was calling arm-none-eabi-gcc to also generate extended assembly listing, which was later assembled manually with arm-none-eabi-as into an object file. If you would do it like that, then between these two steps you could modify the assembly listing to have wide instructions only - in most (all?) cases you could just use sed to add .w suffix to the instructions (change add r3, r2 into add.w r3, r2 and so on). Whether or not such level of build complication is worth it, is up to you...