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 = Xn;

bits(datasize) operand2 = Xm;

bits(4) nzcv;

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

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

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

相关推荐
水饺编程1 天前
第2章:Linux 基础,pwd 命令
linux·c语言·汇编
半杯咖啡半行码2 天前
STM32之ARM通用汇编指令详解:从指令格式到寻址方式
汇编·arm开发·stm32
Seeing52 天前
音乐111111
汇编
Funlang2 天前
从汇编到Fun语言
汇编
l1t2 天前
DeepSeek总结的有符号、无符号、未对齐:从汇编到 SQL 的教训
汇编·数据库·sql
Hi202402178 天前
同一个 NMS 算子,两种语言实现:CUDA C 与 Rust 生成 LLVM IR 和 Vortex 汇编的差异
c语言·汇编·rust·gpgpu·vortex·cudac
lhbweilai8 天前
深挖FreeRTOS内核实现(二)
c语言·汇编·stm32·单片机
水饺编程8 天前
第1章:开发环境搭建,在 Windows 中安装 VS 2019
linux·c语言·汇编·visual studio
水饺编程9 天前
第1章:下载 Linux 0.12 内核
linux·c语言·汇编·ubuntu
水饺编程9 天前
第1章:开发环境搭建,在 Windows 中安装 Git
linux·c语言·汇编·git·ubuntu