以编程方式导致未定义指令异常 [英] Programmatically cause Undefined Instruction exception

查看:572
本文介绍了以编程方式导致未定义指令异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的测试夹具测试导致ARM Cortex-M3未定义指令异常。 IAR编译器支持这样的内联汇编,像这样:

asm(udf.w#0);

<不幸的是,GNU CC内联汇编器不知道恩智浦LPC177x8x的这个操作码。它写入诊断:

  ccw3kZ46.s:404:错误:错误的指令`udf.w#0'

如何创建导致Undefined Instruction异常的函数?

解决方案

建立在 Masta79 的答案上:



列在ARMv7-M体系结构参考手册 - ARM DDI 0403D(文档占位符,需要注册)。编码是0xf7fXaXXX(其中'X'被忽略)。 (没有测试):

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



应在任何ARMv7-M或更高版本的处理器上产生保证未定义的指令。


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("udf.w #0");

Unfortunately the GNU CC inline assembler does not know this opcode for the NXP LPC177x8x. It writes the diagnostic:

ccw3kZ46.s:404: Error: bad instruction `udf.w #0'

How can I create a function that causes a Undefined Instruction exception?

解决方案

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.

这篇关于以编程方式导致未定义指令异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆