【汇编指令】数据处理指令之算术指令集

ARM指令集:

其中包括数据处理指令集

1)算术指令(ADD,ADC,SUB,SBC , RSB, RSC )

①加法指令:ADD,ADDS

其中带S的表示可以更新标志位

ADD/ADDS

Add values and store result to register.

Syntax ADD{cond}{S}  Rd, Rn, Op2
Description Add Rn and Op2 and store result to Rd.
Condition Flags If S is specified update flags: N, Z, C, V.
Example 
       ADDS  R0,R2,R4          //Add R2 and R4 and store result to R0, update flags
       ADD   R4,R4,#0xFF00     //Add value in 0xFF00 and R4 and store result in R4
 		area MY_kano,code,readonly
		code32
		entry

start

loop
		mov r0, #10
		mov r1, #2
		adds r2, r0   			;对于R2寄存器,使用add指令是等于把R0的值加到R2寄存器中,
		add r3, r0, r1			;对于加法指令的第一操作数可以是寄存器,R3目标寄存器只可以是一个
		add r4, r1, #0x4	 	;同样对于第一操作数寄存器,第二操作数可以是寄存器也可以是立即数
;		add r5, 0x1c, r1		;对于第一操作数不可以是立即数,只能是寄存器
		b loop

		end



②带进位的加法指令:ADC/ADDS

ADC

Add with Carry.

Syntax ADC{cond}{S}  Rd, Rn, Op2
Description Add Rn and Op2 and Carry flag and store result to Rd. ADC is typical used for multi-word arithmetic.
Condition Flags If S is specified update flags: N, Z, C, V.
Example 
ADDS  R0,R2,R4       // add R2 + R4, store result to R0, set flags
ADC   R1,R3,R5       // add R3 + R5 with carry from previous ADDS, store result to R1

 		area MY_kano,code,readonly
		code32
		entry

start

loop
		mov r0, #0xc
		mov r1, #0xa
;		sub r2, r0
		sub r3, r0,r1
		sub r4, r1, #0x9

		b loop

		end


③反向减法指令;RSB/RSC

     rsb r0, r0, #100                ;r0 = 100 - r0 ;表示把100减去R0的值存入r0中





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值