I'm developing a project on a Cortex-M0 processor, and I've a problem about a 'Switch" statement with procedure call in its "case"; The C compiler (Normally) codes this "Switch" with an indirect Jump Table; Please suppose the C file has name "Code_with_switch.c". If I see the corresponding "Code_with_Switch.asm" file the table contains some ".word Func_x_Address" statements for every "x" case; but in ARM-Cortex-M processors the Jump address MUST BE ODD, and in assembly this detail is solved specifying ".thumb_func" before every "Func_x_address". Unfortunately the compiler (with "natural ARM CORTEX" options) doesn't specify this Function nature, and at the end of the history the table contains EVEN addresses and the system crashes in HFault handler. To remove the problem I had to add the "-fno-jump-tables" in C compiler options. Inthiis way the "switch" iis solved in several "cmp Rx,#case" statements and the code doesn't crash any more, but the execution speed is slower and this coding is horrible. I serach in internet for about 8 hours the solution with a lot of "search" strings, but without success. In CrosssStudio Help I didn't find the solution. Please, can you help me?
Please sign in to leave a comment.