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 // 加第四个字,带进位

相关推荐
Ronin-Lotus11 天前
微处理器原理与应用篇---ARM常见汇编指令
汇编·arm开发·微处理原理与应用
永夜的黎明14 天前
【二进制安全作业】250616课上作业1-栈溢出漏洞利用
c语言·汇编·安全
Geometry Fu16 天前
物联网控制技术 知识点总结 第三章 汇编语言 第四章 C51语言
汇编·物联网·51单片机
半桔16 天前
【Linux手册】进程的状态:从创建到消亡的“生命百态”
linux·运维·服务器·汇编·深度学习·面试
一条叫做nemo的鱼20 天前
从汇编的角度揭开C++ this指针的神秘面纱(下)
java·汇编·c++·函数调用·参数传递
一条叫做nemo的鱼20 天前
从汇编的角度揭开C++ this指针的神秘面纱(上)
汇编·c++·算法·函数调用·this指针·参数传递
qwertyuiop_i22 天前
汇编(函数调用)
汇编·windows·函数调用
不忘不弃22 天前
由汇编代码确定switch语句
汇编
南玖yy22 天前
深入理解 x86 汇编中的符号扩展指令:从 CBW 到 CDQ 的全解析
开发语言·汇编·arm开发·后端·架构·策略模式
iCxhust22 天前
汇编字符串比较函数
c语言·开发语言·汇编·单片机·嵌入式硬件