TST指令将< shifter_operand > 表示的数值与寄存器< Rn >的值按位做逻辑与操作,根据操作的结果更新CPSR中相应的条件标志位。
指令的编码格式
指令的语法格式
TST{< cond >} {S} < Rd >, < Rn> ,< shifter_operand >
其中:
- < cond >为指令执行的条件码。当< cond >忽略是指令为无条件执行。
- < Rn > 寄存器为第1个操作数所在的寄存器。
- < shifter_operand >为第2个操作数。计算方法见之前介绍。
指令操作的伪代码
if ConditionPassed<cond> then
alu_out=Rn AND shifter_operand
N Flag=alu_out[31]
Z Flag=if alu_out==0 then 1 else 0
C Flag=shifter_carry_out
V Flag=unaffected
指令的使用
TST指令通常用于测试寄存器中某个(些)位是1还是0。