Q(饱和标志)在ARM中的重要性 [英] Importance of Q(Saturation Flag) in ARM

查看:86
本文介绍了Q(饱和标志)在ARM中的重要性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解Q标记在ARM处理器中的重要性.我知道有某些说明,例如QADD,QSUB等.

I want to understand the importance of Q flag in ARM Processor. I know there are certain instructions like QADD,QSUB etc.

但是我需要通过一些例子来理解这一点,以阐明这个概念.

But I need to understand this with some examples which will clarify the concept.

请给我解释.

谢谢

推荐答案

《 ARM体系结构参考手册》(ARM DDI 0100E)中对此进行了解释:

This is explained in the "ARM Architecture Reference Manual" (ARM DDI 0100E):

Bit [27]是粘性溢出标志,也称为Q标志.如果发生以下任何情况,则此标志设置为1:

Bit[27] of the CPSR is a sticky overflow flag, also known as the Q flag. This flag is set to 1 if any of the following occurs:

  • QADD QDADD 指令中的加法结果饱和
  • QSUB QDSUB 指令中的减法结果饱和
  • QDADD QDSUB 指令中加倍中间结果的饱和度
  • SMLA< x>< y> SMLAW< y> 指令期间发生签名溢出
  • Saturation of the addition result in a QADD or QDADD instruction
  • Saturation of the subtraction result in a QSUB or QDSUB instruction
  • Saturation of the doubling intermediate result in a QDADD or QDSUB instruction
  • Signed overflow during an SMLA<x><y> or SMLAW<y> instruction

Q标志为 sticky ,因为一旦将其设置为1,它就不受后续计算是否饱和和/或溢出的影响.其预期用途是:

The Q flag is sticky in that once it has been set to 1, it is not affected by whether subsequent calculations saturate and/or overflow. Its intended usage is:

  1. 使用 MSR CPSR_f,#0 指令清除Q标志(这还将清除条件代码标志).
  2. 执行一系列计算.
  3. 使用 MRS Rn,CPSR 指令读取 CPSR ,然后测试Q标志的值.如果仍为0,则在第2步中没有发生任何上述类型的饱和或溢出.否则,至少发生了一次断断续续或溢出的情况.
  1. Use an MSR CPSR_f,#0 instruction to clear the Q flag (this also clears the condition code flags).
  2. Peform a sequence of calculations.
  3. Use an MRS Rn,CPSR instruction to read the CPSR, then test the value of the Q flag. If it is still 0, none of the above types of saturation or overflow occured during step 2. Otherwise, at least one instance of stauration or overflow occured.


一个例子:


An example:

mov     r2,#0x70000000
qadd    r3,r2,r2

0x70000000 + 0x70000000 将变为 0xE0000000 ,但是由于 qadd 处于饱和状态,结果将饱和为 0x7FFFFFFF (最大的32位正整数)并设置了Q标志.

0x70000000 + 0x70000000 would become 0xE0000000, but since qadd is saturating, the result is saturated to 0x7FFFFFFF (the largest positive 32-bit integer) and the Q flag is set.

这篇关于Q(饱和标志)在ARM中的重要性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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