Programmatically cause Undefined Instruction exception

后端 未结 4 2141
再見小時候
再見小時候 2020-12-31 18:22

I want to cause an ARM Cortex-M3 Undefined Instruction exception for the test of my test fixture. The IAR compiler supports this with inline assembly like this:

asm(

4条回答
  •  甜味超标
    2020-12-31 18:57

    Building on Masta79's answer:

    There is a "permanently undefined" encoding listed in the ARMv7-M architecture reference manual - ARM DDI 0403D (documentation placeholder, registration required). The encoding is 0xf7fXaXXX (where 'X' is ignored). Of course instruction fetches are little-endian, so (without testing):

    asm volatile (".word 0xf7f0a000\n");

    should yield a guaranteed undefined instruction on any ARMv7-M or later processor.

提交回复
热议问题