到目前为止,我使用了 3 个 NOP 来“清理”管道。 最近我遇到了为我做那件事的 ISB 指令。 查看 arm 信息中心,我注意到这个命令需要 4 个周期(在 Cortex M0 下),而 3 个 NOP 只需要 3 个。
我为什么要使用这个命令?它与 3 个 NOP 有什么不同?
最佳答案
这是 NOP ( http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/CHDJJGFB.html ) 的问题:
Operation
NOP performs no operation and is not guaranteed to be time consuming. The processor might remove it from the pipeline before it reaches the execution stage.
Use NOP for padding, for example to place the subsequent instructions on a 64-bit boundary.
其他 ARM Cortex 设备的文档中有相同的信息,因此将该指令用于填充以外的任何目的是根本不可靠的。您唯一能保证的是这条指令将占用 2 (nop
) 或 4 个字节 (nop.w
),并且它不会执行任何操作 - 仅此而已。
关于assembly - ARM Cortex M 中的 ISB 指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41790296/