简体   繁体   English

如何强制 IAR 使用所需的 Cortex-M0+ 指令(此功能的优化将被禁用。)

[英]How to force IAR to use desired Cortex-M0+ instructions (optimization will be disabled for this func.)

I need to force IAR tp use certain Cortex-M0+ instruction in some part of my code while codding with C.我需要强制 IAR tp 在我的代码的某些部分使用某些 Cortex-M0+ 指令,同时使用 C 进行编码。

Please do not offer pure asm functions or inline asm etc.请不要提供纯 asm 函数或内联 asm 等。

I have managed to do this for 51 instruction but could not for ;我已经设法为 51 条指令执行此操作,但不能为 ; ADR, BLX, RSBS, SBCS, SXTH instructions. ADR、BLX、RSBS、SBCS、SXTH 指令。

Optimization is disabled for this function (#pragma optimization=none)此功能禁用优化(#pragma optimization=none)

I have tried many things by considering instruction behaviour.通过考虑教学行为,我尝试了很多事情。 But IAR preferred to same function with different instructions.但 IAR 更喜欢具有不同指令的相同功能。

Did anyone else struggle with such a unnecessary thing before or has anyone an idea?之前有没有其他人为这种不必要的事情而挣扎或有任何想法?

Please do not offer pure asm functions or inline asm etc.请不要提供纯 asm 函数或内联 asm 等。

But these are the only solution to your problem that won't depend on compiler version.但这些是您的问题的唯一解决方案,不依赖于编译器版本。

You may have你可能有

managed to do this for 51 instruction设法为 51 条指令执行此操作

..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. ..但是下一个(主要)编译器版本可能对如何为您的 C 代码生成指令有截然不同的想法,即使优化器关闭。 BTDT for GCC. GCC 的 BTDT。

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.您甚至应该有一些示例代码,因为大多数 C 启动(重置处理程序)代码是作为汇编语言文件提供的。

Apart from BLX which isn't available on cortex-m this code may get you there.除了在 cortex-m 上不可用的 BLX 之外,此代码可能会让您到达那里。 Maybe you have to turn on some optimizations.也许你必须开启一些优化。

char const * getstr(void)
{
    return "ADR";
}

long long llfunc(long long v1, long long v2)
{
    return v1 - v2;
}

int neg(int i)
{
    return -i;
}


void efunc(short);

void func(short s)
{
    efunc(s + 5);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM