第一范文网 - 专业文章范例文档资料分享平台

ARM汇编语言程序设计总结

来源:用户分享 时间:2025/8/16 20:10:36 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

ARM汇编语言程序设计总结

一、常用指令

1.存储器访问指令

LDR STR

LDR

Load 32-bit word to Memory. Syntax

LDR{cond} Rd, [Rn]

LDR{cond} Rd, [Rn, offset] LDR{cond} Rd, [Rn, offset]! LDR{cond} Rd, label LDR{cond} Rd, [Rn], offset Description

LDR{cond} Rd, [Rn, offset] (Pre-indexed offset) Rn and offset are added and used as address value.

LDR{cond} Rd, [Rn, offset]{!} (Pre-indexed offset with update)

Rn and offset are added and used as address value. The new address value is written to Rn. LDR{cond} Rd, label (Program-relative)

The assembler calculates the PC offset and generates LDR{cond} Rd, [R15, offset]. LDR{cond} Rd, [Rn], offset (Post-indexed offset)

Rn is used as address value. After memory transfer, the offset is added to Rn. Example

LDR{cond} Rd, [Rn] (zero offset)

Rn is used as address value.

LDR R8,[R10] //loads r8 from the address in r10. LDRNE R2,[R5,#960]! //(conditionally) loads r2 from a word 960 bytes above the address in r5, and increments r5 by 960.

LDR R0,localdata //loads a word located at label localdata

STR

Store register 32-bit words to Memory. The address must be 32-bit word-aligned.

Syntax STR{cond} Rd, [Rn]

STR{cond} Rd, [Rn, offset] STR{cond} Rd, [Rn, offset]! STR{cond} Rd, label

STR{cond} Rd, [Rn], offset Description

STR{cond} Rd, [Rn] (zero offset)

Rn is used as address value.

STR{cond} Rd, [Rn, offset] (Pre-indexed offset) Rn and offset are added and used as address value.

STR{cond} Rd, [Rn, offset]! (Pre-indexed offset with update)

Rn and offset are added and used as address value. The new address value is written to Rn. STR{cond} Rd, label (Program-relative)

The assembler calculates the PC offset and generates STR{cond} Rd, [R15], offset. STR{cond} Rd, [Rn], offset (Post-indexed offset)

Rn is used as address value. After memory transfer, the offset is added to Rn. Example

LDR r8,[r10] //loads r8 from the address in r10.

LDRNE r2,[r5,#960]! //(conditionally) loads r2 from a word //960 bytes above the address in r5, and //increments r5 by 960.

STR r2,[r9,#consta-struc] //consta-struc is an expression evaluating

//to a constant in the range 0-4095. STRB r0,[r3,-r8,ASR #2] //stores the least significant byte from

//r0 to a byte at an address equal to //contents(r3) minus contents(r9)/4. //r3 and r8 are not altered.

STR r5,[r7],#-8 //stores a word from r5 to the address //in r7, and then decrements r7 by 8. LDR r0,localdata //loads a word located at label localdata

2.一般数据处理指令

ADD SUB ADC SBC

AND, ORR, EOR, CMP TST

UMULL, UMLAL, SMULL, and SMLAL MUL, MLA, and MLS

ADC

Add with Carry. Syntax Description

ADC{cond}{S} Rd, Rn, Op2

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

ADD

Add values and store result to register. Syntax Description Example

ADD{cond}{S} Rd, Rn, Op2

Add Rn and Op2 and store result to Rd.

Condition Flags If S is specified update flags: N, Z, C, V.

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

SUB

Subtract registers. Syntax Description Condition Flags Example

SUB{cond}{S} Rd, Rn, Op2

subtracts the value of Op2 from the value in Rn. If S is specified update flags: N, Z, C, V.

SUBS R8,R6,#240 //R8=R6-240

SBC

Subtract with carry. Syntax Description Condition Flags Example

SBC{cond}{S} Rd, Rn, Op2 synthesize multiword arithmetic. If S is specified update flags: N, Z, C, V.

ADDS R0,R2,R4

ADD R4,R4,#0xFF00

AND

Logical AND operation. Syntax Description

AND{cond}{S} Rd, Rn, Op2

Load Rd with logical AND of Rn with Op2. Rd := Rn AND Op2

Condition Flags If S is specified, N, Z flags are updated. C flag may be updated by calculation of Op2. Example

AND R9,R2,#0xFF00 // Load R9 with R2 and value in 0xFF00

ORR

Logical OR operation. Syntax Description

ORR{cond}{S} Rd, Rn, Op2

OR operations on the values in Rn and Op2.

Condition Flags If S is specified, N, Z flags are updated. C flag may be updated by calculation of Op2. Example

ORR R2, R0, R5 // Rd = R0 or R5

CMP

Compare. Used in combination with conditional branch instructions. Syntax Description

CMP {cond} Rn, Op2

subtracts the value of Op2 from the value in Rn (equals to the SUBS

instruction with a discarded result).

This instruction updates the condition flags, but do not place a result in a register. Condition Flags N, Z, C and V flags are updated. Example

CMP R2, R9 //Subtract value of R9 from R2

TST

Test.

搜索更多关于: ARM汇编语言程序设计总结 的文档
ARM汇编语言程序设计总结.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c8sqmk15tju35m4y30uui_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top