LDR/STR指令学习
2010-12-04 17:35
225 查看
S3C2440A datasheet上关于这两条指令的说明如下:
SINGLE DATA TRANSFER (LDR, STR), The single data transfer instructions are used to load or store single bytes or words of data.
简单的理解就是数据的传送/存储指令。
接下来是datasheet上关于这两个指令格式的说明:
<LDR|STR>{cond}{B}{T} Rd,<Address>
where:
LDR --- Load from memory into a register
STR --- Store from a register into memory
{cond} ---Two-character condition mnemonic. See Table 3-2. (这个可以不用考虑)
{B} --- If B is present then byte transfer, otherwise word transfer. (这个也可以不用考虑)
{T} --- If T is present the W bit will be set in a post-indexed instruction, forcing non-privileged
mode for the transfer cycle. T is not allowed when a pre-indexed addressing mode is
specified or implied. (这个也可以不用考虑)
Rd --- An expression evaluating to a valid register number. (CPU一个寄存器的具体名字:R0~R15)
Rn and Rm --- Expressions evaluating to a register number. If Rn is R15 then the assembler will
subtract 8 from the offset value to allow for ARM920T pipelining.
In this case base write-back should not be specified.
<Address>can be: (以下是关于地址的几种表示方法)
1 An expression which generates an address: (立即寻址)
The assembler will attempt to generate an instruction using the PC as a base and a
corrected immediate offset to address the location given by evaluating the expression.
This will be a PC relative, pre-indexed address. If the address is out of range, an error
will be generated.
2 A pre-indexed addressing specification: (变址寻址)
[Rn] offset of zero
[Rn,<#expression>]{!} offset of <expression> bytes
[Rn,{+/-}Rm{,<shift>}]{!} offset of +/- contents of index register, shifted
by <shift>
3 A post-indexed addressing specification: (偏移寻址)
[Rn],<#expression> offset of <expression> bytes
[Rn],{+/-}Rm{,<shift>} offset of +/- contents of index register, shifted as
by <shift>.
<shift> General shift operation (see data processing instructions) but you cannot specify the shift
amount by a register.
{!} --- Writes back the base register (set the W bit) if! is present (是否会写基寄存器,这个一般很少用)
在ARM架构下, 数据从内存到CPU之间的移动只能通过LDR/STR指令来完成. 而MOV只能在寄存器之间移动数据,或者把立即数移动到寄存器中,并且数据的长度不能超过8位
以下是具体的应用例子:
1. LDR r0,=label 用于加载立即数或一个地址值到指定寄存器中
1.1 如果label是立即数: LDR r0,=0X123 ;将0X123存入r0中
1.2 如果name是个标识符: LDR r0,=label_1 ;将label_1所指向的地址值存入r0中
2. LDR r0,[r1] ;将R1中的值存到r0中
3. LDR r1,[r2,#16] ;将(r2+16)地址中的内容存到r1中
4. LDR r1,[r2],#4 ;将r2地址中的内容存到r1中,同时r2=r2+4
a. STR r1,[r2] ; 将r1中的值存到r2所指定的地址中
b. STR r1,[r2,#4] ;将r1中的值存到r2+4所指定的地址中
c. STR r1,[r2],#4 ;将r1中的值存到r2所指定的地址中, 同时r2=r2+4
SINGLE DATA TRANSFER (LDR, STR), The single data transfer instructions are used to load or store single bytes or words of data.
简单的理解就是数据的传送/存储指令。
接下来是datasheet上关于这两个指令格式的说明:
<LDR|STR>{cond}{B}{T} Rd,<Address>
where:
LDR --- Load from memory into a register
STR --- Store from a register into memory
{cond} ---Two-character condition mnemonic. See Table 3-2. (这个可以不用考虑)
{B} --- If B is present then byte transfer, otherwise word transfer. (这个也可以不用考虑)
{T} --- If T is present the W bit will be set in a post-indexed instruction, forcing non-privileged
mode for the transfer cycle. T is not allowed when a pre-indexed addressing mode is
specified or implied. (这个也可以不用考虑)
Rd --- An expression evaluating to a valid register number. (CPU一个寄存器的具体名字:R0~R15)
Rn and Rm --- Expressions evaluating to a register number. If Rn is R15 then the assembler will
subtract 8 from the offset value to allow for ARM920T pipelining.
In this case base write-back should not be specified.
<Address>can be: (以下是关于地址的几种表示方法)
1 An expression which generates an address: (立即寻址)
The assembler will attempt to generate an instruction using the PC as a base and a
corrected immediate offset to address the location given by evaluating the expression.
This will be a PC relative, pre-indexed address. If the address is out of range, an error
will be generated.
2 A pre-indexed addressing specification: (变址寻址)
[Rn] offset of zero
[Rn,<#expression>]{!} offset of <expression> bytes
[Rn,{+/-}Rm{,<shift>}]{!} offset of +/- contents of index register, shifted
by <shift>
3 A post-indexed addressing specification: (偏移寻址)
[Rn],<#expression> offset of <expression> bytes
[Rn],{+/-}Rm{,<shift>} offset of +/- contents of index register, shifted as
by <shift>.
<shift> General shift operation (see data processing instructions) but you cannot specify the shift
amount by a register.
{!} --- Writes back the base register (set the W bit) if! is present (是否会写基寄存器,这个一般很少用)
在ARM架构下, 数据从内存到CPU之间的移动只能通过LDR/STR指令来完成. 而MOV只能在寄存器之间移动数据,或者把立即数移动到寄存器中,并且数据的长度不能超过8位
以下是具体的应用例子:
1. LDR r0,=label 用于加载立即数或一个地址值到指定寄存器中
1.1 如果label是立即数: LDR r0,=0X123 ;将0X123存入r0中
1.2 如果name是个标识符: LDR r0,=label_1 ;将label_1所指向的地址值存入r0中
2. LDR r0,[r1] ;将R1中的值存到r0中
3. LDR r1,[r2,#16] ;将(r2+16)地址中的内容存到r1中
4. LDR r1,[r2],#4 ;将r2地址中的内容存到r1中,同时r2=r2+4
a. STR r1,[r2] ; 将r1中的值存到r2所指定的地址中
b. STR r1,[r2,#4] ;将r1中的值存到r2+4所指定的地址中
c. STR r1,[r2],#4 ;将r1中的值存到r2所指定的地址中, 同时r2=r2+4
相关文章推荐
- LDR伪指令和LDR指令学习
- LDR、STR指令
- 内存访问指令:ldr、str、ldm、stm
- arm 汇编指令:内存访问方式 、STR 、LDR 指令
- ARM LDR/STR, LDM/STM 指令
- ARM汇编-LDR指令学习
- arm汇编:ldr,str,ldm,stm,伪指令ldr
- arm汇编编写countnum加1的实现(LDR STR ADD 指令)
- 记录自已学习之ARM汇编语言ldr和str
- arm汇编ldr,str,b,bl指令
- LDR指令学习(指令与伪指令)
- 3. 加载/存储指令,LDR,STR
- LDR,STR指令的用法
- ARM指令集 mov指令,ldr=伪指令,地址访问指令ldr,str,位运算指令and,orr,eor,bic,逻辑位移指令lsl,lsr
- 学习AngularJs:Directive指令用法(完整版)
- 32位汇编语言学习笔记(3)--leal和算术运算指令
- Vue.js第一天学习笔记(数据的双向绑定、常用指令)
- make指令入门学习
- ios学习--RSA非对称加密的公私密钥对生成的mac终端指令
- nasm 指令学习