ARM base instruction -- adcs

Add with Carry, setting flags, adds two register values and the Carry flag value, and writes the result to the destination register. It updates the condition flags based on the result.

带进位加法,设置标志,将两个寄存器值和进位标志值相加,并将结果写入目标寄存器。它根据结果更新条件标志。

32-bit variant

Applies when sf == 0.

ADCS <Wd>, <Wn>, <Wm>

64-bit variant

Applies when sf == 1.

ADCS <Xd>, <Xn>, <Xm>

Decode for all variants of this encoding

integer d = UInt(Rd);

integer n = UInt(Rn);

integer m = UInt(Rm);

integer datasize = if sf == '1' then 64 else 32;

Operation

bits(datasize) result;

bits(datasize) operand1 = X[n];

bits(datasize) operand2 = X[m];

bits(4) nzcv;

(result, nzcv) = AddWithCarry(operand1, operand2, PSTATE.C);

PSTATE.<N,Z,C,V> = nzcv;

X[d] = result;

(bits(N), bits(4)) AddWithCarry(bits(N) x, bits(N) y, bit carry_in)

integer unsigned_sum = UInt(x) + UInt(y) + UInt(carry_in);

integer signed_sum = SInt(x) + SInt(y) + UInt(carry_in);

bits(N) result = unsigned_sum<N-1:0>; // same value as signed_sum<N-1:0>

bit n = result<N-1>;

bit z = if IsZero(result) then '1' else '0';

bit c = if UInt(result) == unsigned_sum then '0' else '1';

bit v = if SInt(result) == signed_sum then '0' else '1';

return (result, n:z:c:v);

ADC指令用于把两个操作数相加,再加上CPSR中的C条件标志位的值,并将结果存放到目的寄存器中

adds r0, r4, r8 // 加低端的字

adcs r1, r5, r9 // 加第二个字,带进位

adcs r2, r6, r10 // 加第三个字,带进位

adc r3, r7, r11 // 加第四个字,带进位

相关推荐
花阴偷移8 小时前
逆向基础--汇编源程序认识(08)
汇编
阿昭L2 天前
计算机外设与CPU通信
汇编·计算机外设
wyiyiyi3 天前
【数据结构+算法】进栈顺序推算、卡特兰数与逆波兰表达式
汇编·数据结构·笔记·算法
white-persist3 天前
汇编代码详细解释:汇编语言如何转化为对应的C语言,怎么转化为对应的C代码?
java·c语言·前端·网络·汇编·安全·网络安全
CC-NX3 天前
32位汇编:实验9分支程序结构使用
汇编·算法·win32·分支结构
花阴偷移4 天前
逆向基础--汇编基础(字与物料地址) (004)
汇编
小尧嵌入式5 天前
STM32启动汇编文件详解及启动逻辑
汇编·arm开发·stm32·单片机
花阴偷移5 天前
逆向基础--汇编基础(CS与IP) (05)
网络·汇编·网络协议·tcp/ip
梓仁沐白10 天前
CSAPP实验2:Bomb
汇编
资料,小偿11 天前
8086微机原理与汇编语言,8086程序设计,EMU8086,MASM,汇编程序设计,proteus
汇编·51单片机·proteus