如何强制 IAR 使用所需的 Cortex-M0+ 指令(此功能的优化将被禁用.) [英] How to force IAR to use desired Cortex-M0+ instructions (optimization will be disabled for this func.)

查看:31
本文介绍了如何强制 IAR 使用所需的 Cortex-M0+ 指令(此功能的优化将被禁用.)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要强制 IAR tp 在我的代码的某些部分使用某些 Cortex-M0+ 指令,同时使用 C 进行编码.

I need to force IAR tp use certain Cortex-M0+ instruction in some part of my code while codding with C.

请不要提供纯 asm 函数或内联 asm 等.

Please do not offer pure asm functions or inline asm etc.

我已设法为 51 条指令执行此操作,但无法为 ;ADR、BLX、RSBS、SBCS、SXTH 指令.

I have managed to do this for 51 instruction but could not for ; ADR, BLX, RSBS, SBCS, SXTH instructions.

禁用此功能的优化(#pragma optimization=none)

Optimization is disabled for this function (#pragma optimization=none)

考虑到教学行为,我尝试了很多方法.但IAR更喜欢不同指令的相同功能.

I have tried many things by considering instruction behaviour. But IAR preferred to same function with different instructions.

之前有没有其他人为这种不必要的事情而挣扎过或有任何想法?

Did anyone else struggle with such a unnecessary thing before or has anyone an idea?

推荐答案

请不要提供纯 asm 函数或内联 asm 等

Please do not offer pure asm functions or inline asm etc.

但这些是解决您问题的唯一方法,不依赖于编译器版本.

But these are the only solution to your problem that won't depend on compiler version.

你可能有

设法为 51 条指令执行此操作

managed to do this for 51 instruction

..但是下一个(主要)编译器版本可能对如何为您的 C 代码生成指令有一个非常不同的想法,即使优化器关闭.GCC 的 BTDT.

..but the next (major) compiler version could have a vastly different idea on how to generate instructions for your C code, even when the optimizer is off. BTDT for GCC.

直接用汇编语言编写代码完全消除了这种编译器版本依赖性.您甚至应该有一些示例代码,因为大多数 C 启动(重置处理程序)代码是作为汇编语言文件提供的.

Coding stuff in assembly language directly eliminates this compiler version dependecy altogether. You should even have some example code, as most C-startup (reset handler) code is shipped as assembly language file.

这篇关于如何强制 IAR 使用所需的 Cortex-M0+ 指令(此功能的优化将被禁用.)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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