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

相关推荐
iCxhust1 天前
微机原理课程设计大综合---计数器
汇编·单片机·嵌入式硬件·课程设计·微机原理
xxjj998a2 天前
PHP与汇编:从Web到硬件的编程差异
开发语言·汇编·php
陈eaten3 天前
汇编使用AES指令集实现AES解密
汇编·python·aes解密·aes指令集
顾鉴行思3 天前
10 字符串常量到底存在哪里?
c语言·汇编·经验分享
iCxhust3 天前
在 emu8086 中可以直接编译运行的完整汇编程序,演示数组的定义、遍历、求和、求最大值。
开发语言·前端·javascript·汇编·单片机·嵌入式硬件·算法
浩浩测试一下4 天前
堆栈中的 参数与局部变量 (逆向分析)
汇编·逆向·免杀·堆栈·windows编程·pe壳
iCxhust4 天前
微机原理实践教程(C语言篇)---A001闪烁灯
c语言·开发语言·汇编·单片机·嵌入式硬件·51单片机·微机原理
浩浩测试一下5 天前
抬栈 恢复上下文 (逆向分析)
汇编·逆向·堆栈·windows核心编程
zhouwy1135 天前
ARM汇编指令集详解
汇编·arm开发
iCxhust5 天前
微机原理实践教程(汇编篇)---A002流水灯
汇编·单片机·嵌入式硬件·51单片机·微机原理