# 数据处理指令

MOV数据传送Rd = Rn(Rn可能需要运算)
MVN数据取反传送Rd = ~Rn(Rn可能需要运算）
ADC带进位加Rd = Rn + op2 + C
AND逻辑加Rd = Rn && op2
EOR逻辑异或Rd = Rn ^ op2
SUBRd = Rn - op2
SBC带进位的减Rd = Rn - op2 + C - 1
RSB反转减Rd = op2 - Rn
RSC带进位的反转减Rd = op2 - Rn + C - 1
TST测试Rn && op2的结果更新标志位
TEQ测试相等Rn ^ op2的结果更新标志位
CMP比较Rn - op2的结果更新标志位
CMN符数比较Rn + op2的结果更新标志位
ORR逻辑或Rd = Rn || op2
BIC位清零Rd = Rn && ~(op2)

## 1. MOV传送指令

MOV指令将第二个操作数传送到目标寄存器中。

MOV{<cond>} {S} <Rd>, <shifter_operand>

if ConditionPassed(cond) then
Rd = shifter_operand
if S == 1 and Rd == R15 then
CPSR = SPSR
elif S == 1 then
N Flag = Rd[31]
Z Flag = if Rd == 0 then 1 else 0
C Flag = shifter_carry_out
V Flag = unaffected


## 2. MVN传送指令

MVN将第二个操作数的反码传送到目标寄存器中。

MVN{<cond>} {S} <Rd>, <shifter_operand>

if ConditionPassed(cond) then
Rd = NOT shifter_operand
if S == 1 and Rd == R15 then
CPSR = SPSR
elif S == 1 then
N Flag = Rd[31]
Z Flag = if Rd == 0 then 1 else 0
C Flag = shifter_carry_out
V Flag = unaffected


ADD{<cond>} {S} <Rd>, Rn, <shifter_operand>

if ConditionPassed(cond) then
Rd = Rn + shifter_operand
if S == 1 and Rd == R15 then
CPSR = SPSR
elif S == 1 then
N Flag = Rd[31]
Z Flag = if Rd == 0 then 1 else 0
C Flag = CarrayFrom(Rn + shifter_operand)
V Flag = OverflowFrom(Rn + shifter_operand)


ADC{<cond>} {S} <Rd>, Rn, <shifter_operand>

if ConditionPassed(cond) then
Rd = Rn + shifter_operand + C Flag
if S == 1 and Rd == R15 then
CPSR = SPSR
elif S == 1 then
N Flag = Rd[31]
Z Flag = if Rd == 0 then 1 else 0
C Flag = CarrayFrom(Rn + shifter_operand + C Flag)
V Flag = OverflowFrom(Rn + shifter_operand + C Flag)


## 5. SUB减法指令

SUB指令用Rn减去第二个操作数，然后将结果保存到目标寄存器中。

SUB{<cond>} {S} <Rd>, Rn, <shifter_operand>

if ConditionPassed(cond) then
Rd = Rn - shifter_operand
if S == 1 and Rd == R15 then
CPSR = SPSR
elif S == 1 then
N Flag = Rd[31]
Z Flag = if Rd == 0 then 1 else 0
C Flag = NOT BorrowFrom(Rn - shifter_operand)
V Flag = OverflowFrom(Rn - shifter_operand)


## 6. SBC带位减法指令

SBC指令用Rn减去第二个操作数，再减去CPSR寄存器中的C标志位的反码，然后将结果保存在目标寄存器中。

SBC{<cond>} {S} <Rd>, Rn, <shifter_operand>

if ConditionPassed(cond) then
Rd = Rn - shifter_operand + NOT(C Flag)
if S == 1 and Rd == R15 then
CPSR = SPSR
elif S == 1 then
N Flag = Rd[31]
Z Flag = if Rd == 0 then 1 else 0
C Flag = NOT BorrowFrom(Rn - shifter_operand - NOT(C Flag))
V Flag = OverflowFrom(Rn - shifter_operand - NOT(C Flag))


## 7. RSB逆向减法指令

RSB将第二个操作数减去Rn的结果保存在目标寄存器中。

RSB{<cond>} {S} <Rd>, Rn, <shifter_operand>

if ConditionPassed(cond) then
Rd = shifter_operand - Rn
if S == 1 and Rd == R15 then
CPSR = SPSR
elif S == 1 then
N Flag = Rd[31]
Z Flag = if Rd == 0 then 1 else 0
C Flag = NOT BorrowFrom(shifter_operand - Rn)
V Flag = OverflowFrom(shifter_operand - Rn)


## 8. RSC带位逆向减法指令

RSC将第二个操作数减去Rn，然后再减去CPSR寄存器中C标志位的反码，最后将结果保存在目标寄存器中。

RSC{<cond>} {S} <Rd>, Rn, <shifter_operand>

if ConditionPassed(cond) then
Rd = shifter_operand - Rn - NOT(C Flag)
if S == 1 and Rd == R15 then
CPSR = SPSR
elif S == 1 then
N Flag = Rd[31]
Z Flag = if Rd == 0 then 1 else 0
C Flag = NOT BorrowFrom(shifter_operand - Rn - NOT(C Flag))
V Flag = OverflowFrom(shifter_operand - Rn - NOT(C Flag))


ADD{<cond>} {S} <Rd>, Rn, <shifter_operand>

if ConditionPassed(cond) then
Rd = Rn & shifter_operand
if S == 1 and Rd == R15 then
CPSR = SPSR
elif S == 1 then
N Flag = Rd[31]
Z Flag = if Rd == 0 then 1 else 0
C Flag = shifter_carry_out
V Flag = unaffected


## 10. ORR逻辑或指令

ORR指令将Rn与第二个操作数做按位或运算，将结果保存在目标寄存器中。

ORR{<cond>} {S} <Rd>, Rn, <shifter_operand>

if ConditionPassed(cond) then
Rd = Rn | shifter_operand
if S == 1 and Rd == R15 then
CPSR = SPSR
elif S == 1 then
N Flag = Rd[31]
Z Flag = if Rd == 0 then 1 else 0
C Flag = shifter_carry_out
V Flag = unaffected


## 11. EOR逻辑异或指令

EOR指令将Rn与第二个操作数做异或运算，将结果保存在目标寄存器中。

EOR{<cond>} {S} <Rd>, Rn, <shifter_operand>

if ConditionPassed(cond) then
Rd = Rn ^ shifter_operand
if S == 1 and Rd == R15 then
CPSR = SPSR
elif S == 1 then
N Flag = Rd[31]
Z Flag = if Rd == 0 then 1 else 0
C Flag = shifter_carry_out
V Flag = unaffected


## 12. BIC位清除指令

BIC将第二个操作数与Rn的反码做按位与运算，将结果保存在目标寄存器中，实现的效果就是如果要让Rn中指定位位0，那么将第二个操作数的指定位设置为1即可。

BIC{<cond>} {S} <Rd>, Rn, <shifter_operand>

if ConditionPassed(cond) then
Rd = Rn & ~shifter_operand
if S == 1 and Rd == R15 then
CPSR = SPSR
elif S == 1 then
N Flag = Rd[31]
Z Flag = if Rd == 0 then 1 else 0
C Flag = shifter_carry_out
V Flag = unaffected


## 13. CMP比较指令

CMP用Rn减去第二个操作数，根据结果更新CPSR中的标志位。

CMP{<cond>}  Rn, <shifter_operand>

if ConditionPassed(cond) then
alu_out = Rn - shifter_operand
N Flag = alu_out[31]
Z Flag = if alu_out== 0 then 1 else 0
C Flag = NOT BorrowFrom(Rn - shifter_operand)
V Flag = OverflowFrom(Rn - shifter_operand)


## 14. CMN基于相反数的比较指令

CMN将Rn加上第二个操作数，根据结果更新CPSR中的标志位。

CMN{<cond>}  Rn, <shifter_operand>

if ConditionPassed(cond) then
alu_out = Rn + shifter_operand
N Flag = alu_out[31]
Z Flag = if alu_out== 0 then 1 else 0
C Flag = CarryFrom(Rn + shifter_operand)
V Flag = OverflowFrom(Rn + shifter_operand)


## 15. TST位测试指令

TST指令将第二个操作数与Rn按位做逻辑与操作，根据结果更新CPSR寄存器中的相应标志位。

TST{<cond>}  Rn, <shifter_operand>

if ConditionPassed(cond) then
alu_out = Rn & 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


## 16. TEQ相等测试指令

TST指令将第二个操作数与Rn按位做逻辑异或操作，根据结果更新CPSR寄存器中的相应标志位。

TEQ{<cond>}  Rn, <shifter_operand>

if ConditionPassed(cond) then
alu_out = Rn ^ 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


03-25 1万+

01-10 1671
09-27 1245
03-22 260
03-18 473
04-04 1868
05-20 2013
08-31 1390
04-12 228
08-05 50
06-21 836
01-05 475
12-18
12-20
09-18