当前位置:网站首页>ARM指令集之Load/Store指令寻址方式(一)
ARM指令集之Load/Store指令寻址方式(一)
2022-06-12 11:37:00 【fanxiaoyu321】
这篇笔记记录的是操作32位子类型和无符号字节数据的Load/Store指令所使用的寻址方式。
所有类型的Load/Store指令的寻址方式都是由基址加偏移量组成的,基址用任意的通用寄存器指定,偏移量的指定方式有如下三种:
- 立即数;
- 寄存器;
- 寄存器和一个移位常数;
寻址方式的计算又有如下三种方式:
- 偏移量方法;
- 事先更新方法:先计算访存地址,然后访存,最后用访存地址更新基址寄存器,也叫事后访问方式(事后指的是访存操作后于更新地址);
- 事后更新方法:先用基址寄存器值访存,然后计算新的访存地址,最后用新的访存地址更新基址寄存器,也叫事先访问方式(事先指的是访存操作先于更新地址);
注意:上述内容适用于所有类型的Load/Store指令。
语法格式
操作32位子类型和无符号字节数据的Load/Store指令的语法格式如下:
LDR{<cond>}{B} {T}<Rd>, <address_mode>
- B表示操作的是无符号字节;
- T表示以用户模式权限执行指令,具体见指令介绍。
寻址方式
操作32位子类型和无符号字节数据的Load/Store指令共有9种寻址方式,下面一一介绍。
| 语法 | 说明 | |
|---|---|---|
| 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> | 寄存器移位事后更新寻址 |
立即数偏移量寻址
[<Rn>, #+/-<offset_12>]
if U == 1 then
address = Rn + offset_12
else
address = Rn - offset_12
寄存器偏移量寻址
[<Rn>, +/-<Rm>]
if U == 1 then
address = Rn + Rm
else
address = Rn - Rm
寄存器移位偏移量寻址
[<Rn>, +/-<Rm>, <shift>#<shift_imm>]
根据<shift>的不同,总共有如下几种移位偏移量寻址方式:
逻辑左移:[<Rn>, +/-<Rm>, LSL #<shift_imm>]
逻辑右移:[<Rn>, +/-<Rm>, LSR #<shift_imm>]
算数右移:[<Rn>, +/-<Rm>, ASR #<shift_imm>]
循环右移:[<Rn>, +/-<Rm>, ROR #<shift_imm>]
扩展循环右移:[<Rn>, +/-<Rm>, RRX]
case LSL:
index = Rm LSL shift_imm
case LSR:
if shift_imm == 0 then // 右移32位
index = 0
else
index = Rm LSR shift_imm
case ASR:
if shift_imm == 0 then // 右移32位
if Rm[31] == 1 then
index = 0xFFF_FFFF
else
index = 0
else
index = Rm ASR shift_imm
case ROR | RRX
if shift_imm == 0 then // RRX
index = (C Flag LSL 31) OR (Rm LSR 1)
else // ROR
index = Rm ROR shift_imm
if U == 1 then
address = Rn + index
else
address = Rn - index
立即数事先更新寻址
[<Rn>, #+/-<offset_12>]!
if U == 1 then
address = Rn + offset_12
else
address = Rn - offset_12
if CondPassed then
Rn = address
寄存器事先更新寻址
[<Rn>, #+/-<Rm>]!
if U == 1 then
address = Rn + Rm
else
address = Rn - Rm
if CondPassed then
Rn = address
寄存器移位事先更新寻址
[<Rn>, +/-<Rm>, <shift>#<shift_imm>]!
类似的,根据<shift>的不同,总共有如下几种移位偏移量寻址方式:
逻辑左移:[<Rn>, +/-<Rm>, LSL #<shift_imm>]!
逻辑右移:[<Rn>, +/-<Rm>, LSR #<shift_imm>]!
算数右移:[<Rn>, +/-<Rm>, ASR #<shift_imm>]!
循环右移:[<Rn>, +/-<Rm>, ROR #<shift_imm>]!
扩展循环右移:[<Rn>, +/-<Rm>, RRX]!
case LSL:
index = Rm LSL shift_imm
case LSR:
if shift_imm == 0 then // 右移32位
index = 0
else
index = Rm LSR shift_imm
case ASR:
if shift_imm == 0 then // 右移32位
if Rm[31] == 1 then
index = 0xFFF_FFFF
else
index = 0
else
index = Rm ASR shift_imm
case ROR | RRX
if shift_imm == 0 then // RRX
index = (C Flag LSL 31) OR (Rm LSR 1)
else // ROR
index = Rm ROR shift_imm
if U == 1 then
address = Rn + index
else
address = Rn - index
if CondPassed then
Rn = address
立即数事后更新寻址
[<Rn>], #+/-<offset_12>
address = Rn
if CondPassed then
if U == 1 then
Rn = Rn + offset_12
else
Rn = Rn - offset_12
寄存器事后更新寻址
[<Rn>], +/-<Rm>
address = Rn
if CondPassed then
if U == 1 then
Rn = Rn + Rm
else
Rn = Rn - Rm
寄存器移位事后更新寻址
[<Rm>], +/-<Rn>, <shift>#<shift_imm>
类似的,根据<shift>的不同,总共有如下几种移位偏移量寻址方式:
逻辑左移:[<Rn>], +/-<Rm>, LSL #<shift_imm>
逻辑右移:[<Rn>], +/-<Rm>, LSR #<shift_imm>
算数右移:[<Rn>], +/-<Rm>, ASR #<shift_imm>
循环右移:[<Rn>], +/-<Rm>, ROR #<shift_imm>
扩展循环右移:[<Rn>], +/-<Rm>, RRX
address = Rn
case LSL:
index = Rm LSL shift_imm
case LSR:
if shift_imm == 0 then // 右移32位
index = 0
else
index = Rm LSR shift_imm
case ASR:
if shift_imm == 0 then // 右移32位
if Rm[31] == 1 then
index = 0xFFF_FFFF
else
index = 0
else
index = Rm ASR shift_imm
case ROR | RRX
if shift_imm == 0 then // RRX
index = (C Flag LSL 31) OR (Rm LSR 1)
else // ROR
index = Rm ROR shift_imm
if CondPassed then
if U == 1 then
Rn = Rn + index
else
Rn = Rn - index
边栏推荐
- One must keep writing, so as not to be submerged by the vast crowd.
- How to view glibc version
- Lambda表达式 | 浅解
- Unity 连接 Microsoft SQLSERVER 数据库
- 单元测试用例框架--unittest
- Golang基础(6)
- 視頻分類的類間和類內關系——正則化
- 字节序(网络/主机)转换
- Unlimited growth, we will all go to the future | the 15th anniversary of the founding of InfoQ China
- Construction and construction of meta Universe System
猜你喜欢

人类想要拥有金钱、权力、美丽、永生、幸福……但海龟只想做一只海龟

C# 37. Textbox scroll bar and multiline

Unity connect to Microsoft SQLSERVER database
![[Blue Bridge Cup SCM 11th National race]](/img/da/3c8a9efd5b28f67816f239531a0339.png)
[Blue Bridge Cup SCM 11th National race]

Deep learning and CV tutorial (14) | image segmentation (FCN, segnet, u-net, pspnet, deeplab, refinenet)

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

【蓝桥杯单片机 国赛 第十一届】

DS18B20 digital thermometer (I) electrical characteristics, parasitic power supply mode and remote wiring

CLJ3-100ALH30剩余电流继电器

Unity 连接 Microsoft SQLSERVER 数据库
随机推荐
Design of secure chat tool based on C #
35. 搜索插入位置
Golang基础(6)
信号继电器RXSF1-RK271018DC110V
Mysql45 lecture 01 | infrastructure: how is an SQL query executed?
35. search insertion position
Drqueueonrails integrated LDAP authentication
套接字编程TCP篇
Lambda expression | shallow solution
The difference between meta universe chain games and traditional games
无限生长,我们都将奔赴未来 | InfoQ中国成立15周年
mysql的悲观锁和乐观锁
网络的拓扑结构
程序分析与优化 - 6 循环优化
UI自动化测试中比较少见的异常记录
manuscript手稿格式准备
Record the pits encountered when using JPA
C# 35. Select default network card
MCUXpresso开发NXP RT1060(3)——移植LVGL到NXP RT1060
Sendmail dovecot mail server