当前位置:网站首页>ARM指令集之Load/Store访存指令(一)
ARM指令集之Load/Store访存指令(一)
2022-06-12 11:37:00 【fanxiaoyu321】
文章目录
ARM有三类Load/Store指令:
- 操作数为32位字和无符号字节数据的Load/Store指令;
- 操作数为16位半字和有符号字节数据的Load/Store指令;
- 批量操作的Load/Store指令;
这篇笔记记录了第一类Load/Store指令的语法,这些指令包括如下:
| 助记符 | 说明 |
|---|---|
| LDR | 字数据读取指令 |
| STR | 字数据写入指令 |
| LDRB | 字节数据读取指令 |
| STRB | 字节数据写入指令 |
| LDRT | 用户模式的字数据读取指令 |
| STRT | 用户模式的字数据写入指令 |
| LDRBT | 用户模式的字节数据读取指令 |
| STRBT | 用户模式的字节数据写入指令 |
所谓用户模式指令,意思是当在特权模式下执行该指令时,那么内存系统会将本次访存操作按照用户模式的权限进行判断,除此之外,和普通的对应指令并无不同。
寻址方式
上述指令遵循相同的寻址方式,如下,这些寻址方式的详细介绍见这里。
| 语法 | 说明 | |
|---|---|---|
| 1 | [<Rn>, #+/-<offset_12>] | 立即数偏移量寻址 |
| 2 | [<Rn>, +/-<Rm>] | 寄存器偏移量寻址 |
| 3 | [<Rn>, +/-<Rm>, <shift>#<shift_imm>] | 寄存器移位偏移量寻址 |
| 4 | [<Rn>, #+/-<offset_12>]! | 立即数事先更新寻址 |
| 5 | [<Rn>, #+/-<Rm>]! | 寄存器事先更新寻址 |
| 6 | [<Rn>, +/-<Rm>, <shift>#<shift_imm>]! | 寄存器移位事先更新寻址 |
| 7 | [<Rn>], #+/-<offset_12> | 立即数事后更新寻址 |
| 8 | [<Rn>], +/- | 寄存器事后更新寻址 |
| 9 | [<Rm>], +/-<Rn>, <shift>#<shift_imm> | 寄存器移位事后更新寻址 |
LDR(字数据读取指令)
LDR从内存中读取一个字数据到寄存器中,如果寻址方式指定的内存地址不是字对齐的,那么从内存中读取数据后会对读取的值进行右移操作(一般要字对齐,以避免指令做移位操作,使得代码可读性降低)。
LDR{cond} <Rd>, <address_mode>
if CondPassed(cond) then
if address[1:0] == 0b00 then
value = Mem[address, 4]
elif address[1:0] == 0b01 then
value = Mem[address, 4] >> 8
elif address[1:0] == 0b10 then
value = Mem[address, 4] >> 16
else
value = Mem[address, 4] >> 24
if Rd == PC then
if (arch version 5 or above) then
PC = value && 0xFFFF_FFFE
T Bit = value[0]
else
PC = value && 0xFFFF_FFFC
else
Rd = value
STR(字数据写入指令)
STR将一个字数据从寄存器写入到内存中。
STR{cond} <Rd>, <address_mode>
if CondPassed(cond) then
Mem[address, 4] = Rd
LDRB(字节数据读取指令)
LDRB会将内存单元中读取一个字节的数据到目标寄存器的低8位,同时将目标寄存器的高24位清零。
LDR{cond}B <Rd>, <address_mode>
if CondPassed(cond) then
Rd = Mem[address, 1]
STRB(字节数据写入指令)
STRB将一个寄存器的低8位写入到指定内存单元中。
STR{cond}B <Rd>, <address_mode>
if CondPassed(cond) then
Mem[address, 1] = Rd[7:0]
LDRT(用户模式字数据读取指令)
LDR{cond}T <Rd>, <address_mode>
if CondPassed(cond) then
if address[1:0] == 0b00 then
Rd = Mem[address, 4]
elif address[1:0] == 0b01 then
Rd = Mem[address, 4] >> 8
elif address[1:0] == 0b10 then
Rd = Mem[address, 4] >> 16
else
Rd = Mem[address, 4] >> 24
STRT(用户模式字数据写入指令)
STR{cond}T <Rd>, <address_mode>
if CondPassed(cond) then
Mem[address, 4] = Rd
LDRBT(用户模式字节数据读取指令)
LDR{cond}BT <Rd>, <address_mode>
if CondPassed(cond) then
Rd = Mem[address, 1]
STRBT(用户模式字节数据写入指令)
STR{cond}BT <Rd>, <address_mode>
if CondPassed(cond) then
Mem[address, 1] = Rd[7:0]
边栏推荐
- Socket programming UDP
- AcWing 1995. 见面与问候(模拟)
- Lambda and filter, List 和 numpy array的索引,以及各种距离指标distance-metrics,拼接数组以及axis=0 and axis=1的区分
- Record the pits encountered when using JPA
- Construction and construction of meta Universe System
- 35. 搜索插入位置
- Golang基础(7)
- VirtualBox virtual machine shut down due to abnormal system. The virtual machine startup item is missing
- ReentrantLock源码分析
- Lambda and filter, index of list and numpy array, as well as various distance metrics, concatenated array and distinction between axis=0 and axis=1
猜你喜欢

你需要社交媒体二维码的21个理由

Blue Bridge Cup 2015 CA provincial competition (filling the pit)

程序分析与优化 - 6 循环优化

Doris记录服务接口调用情况

6.6 Convolution de séparation

网络的拓扑结构

Les humains veulent de l'argent, du pouvoir, de la beauté, de l'immortalité, du bonheur... Mais les tortues ne veulent être qu'une tortue.

C# 37. textbox滚动条与多行

Selenium uses proxy IP

正则表达式 | 浅解
随机推荐
redis 總結
多普勒效应的基本原理
Construction and construction of meta Universe System
C# 37. textbox滚动条与多行
Design of tablewithpage
The evil 203 in systemctl
go基于阿里云实现发送短信
Humans want to have money, power, beauty, eternal life and happiness... But turtles only want to be a turtle
Redis keys in PHP
UI自动化测试中比较少见的异常记录
Byte order - how to judge the big end and the small end
Byte order (network / host) conversion
21 reasons why you need social media QR code
conda环境下pip install 无法安装到指定conda环境中(conda环境的默认pip安装位置)
Golang基础(7)
MySQL锁查漏补缺
进程的创建和回收
UML系列文章(30)体系结构建模---制品图
Clj3-100alh30 residual current relay
Epidemic home office experience | community essay solicitation