因为ARM的算术运算不支持直接操作内存地址,所以要把内存里的数据先加载进寄存器。ldr指令就是干这事的,称为间接取址模式。

一共有3*3九种模式,先是直接偏移,先偏移,后偏移三大类,指的是如何对源操作数操作,是直接使用,还是在加载前对源操作数操作(比如地址加个数值),还是在加载后对操作数操作

每个大类里分三个小类,分别指源操作数是立即数,寄存器,还是标量寄存器(比如对寄存器里的数向左偏移两位,即乘4)

汇编指令和对应的C代码如下

 Immediate offset:

   LDR    R0, [R1, #]
r0 = r1[]; Remember, again, the offset is in bytes, so # would point to the second word (long int) in our array, thus in C the array indice [] would provide the correct data. Register offset: LDR R0, [R1, R2]
r0 = r1[r2]; Scaled register offset: LDR R0, [R1, R2, LSL #]
r0 = r1[(r2 << )]; Immediate pre-indexed: LDR R0, [R1, #]!
r1 += ; r0 = *r1; Register pre-indexed: LDR R0, [R1, R2]!
r1 += r2; r0 = *r1; Scaled register pre-indexed: LDR R0, [R1, R2, LSL #]!
r1 += (r2 << #); r0 = *r1; Immediate post-indexed: LDR R0, [R1], #
r0 = *r1; r1 += 4; Register post-indexed: LDR R0, [R1], R2
r0 = *r1; r1 += r2; Scaled register post-indexed: LDR R0, [R1, R2, LSL #]!
r0 = *r1; r1 += (r2 << #2);

str指令是把寄存器里的数存到内存里,目标地址的计算方式与操作与ldr指令中源地址的计算方法与操作一样

Immediate offset:
  LDR    R0, [R1, #4]  r0 = r1[1];
    Remember, again, the offset is in bytes, so #4 would point to the second word (long int) in our array, thus in C the array indice [1] would provide the correct data. 
Register offset:
  LDR    R0, [R1, R2]  r0 = r1[r2];
Scaled register offset:
  LDR    R0, [R1, R2, LSL #4]  r0 = r1[(r2 << 4)];
Immediate pre-indexed:
  LDR    R0, [R1, #4]!  r1 += 4; r0 = *r1;
Register pre-indexed:
  LDR    R0, [R1, R2]!  r1 += r2; r0 = *r1;
Scaled register pre-indexed:
  LDR    R0, [R1, R2, LSL #2]!  r1 += (r2 << #2); r0 = *r1;
Immediate post-indexed:
  LDR    R0, [R1], #4]  r0 = *r1; r1 += 4;
Register post-indexed:
  LDR    R0, [R1], R2  r0 = *r1; r1 += r2;
Scaled register post-indexed:
  LDR    R0, [R1, R2, LSL #2]!  r0 = *r1; r1 += (r2 << #2);

ARMv7 ldr/str指令详解的更多相关文章

  1. [转]JVM指令详解(上)

    作者:禅楼望月(http://www.cnblogs.com/yaoyinglong) 本文主要记录一些JVM指令,便于记忆与查阅. 一.未归类系列A 此系列暂未归类. 指令码    助记符      ...

  2. LDM与STM指令详解

    title: LDM与STM指令详解 date: 2019/2/26 17:58:00 toc: true --- LDM与STM指令详解 指令形式如下,这里的存储方向是针对寄存器的 Load Mul ...

  3. C#中的预处理器指令详解

    这篇文章主要介绍了C#中的预处理器指令详解,本文讲解了#define 和 #undef.#if.#elif.#else和#endif.#warning和#error.#region和#endregio ...

  4. rsync指令详解

    rsync指令详解(更详细的看官方文档http://rsync.samba.org/ftp/rsync/rsync.html) [root@Centos epel]# rsync --help rsy ...

  5. #pragma 预处理指令详解

    源地址:http://blog.csdn.net/jx_kingwei/article/details/367312 #pragma  预处理指令详解              在所有的预处理指令中, ...

  6. 迈向angularjs2系列(2):angular2指令详解

    一:angular2 helloworld! 为了简单快速的运行一个ng2的app,那么通过script引入预先编译好的angular2版本和页面的基本框架. index.html: <!DOC ...

  7. C#中的预处理指令详解

    这篇文章主要介绍了C#中的预处理指令详解,本文讲解了#define 和 #undef.#if.#elif.#else和#endif.#warning和#error.#region和#endregion ...

  8. pragma comment的使用 pragma预处理指令详解

    pragma comment的使用 pragma预处理指令详解   #pragma comment( comment-type [,"commentstring"] ) 该宏放置一 ...

  9. Docker技术入门与实战 第二版-学习笔记-3-Dockerfile 指令详解

    前面已经讲解了FROM.RUN指令,还提及了COPY.ADD,接下来学习其他的指令 5.Dockerfile 指令详解 1> COPY 复制文件 格式: COPY  <源路径> .. ...

随机推荐

  1. C语言函数参数既做出参又做入参的代表

    //使用fcntl对文件进行加锁 #include "stdio.h"#include "unistd.h"#include "fcntl.h&quo ...

  2. 转 Linux命令及Linux终端的20个趣事

    https://linux.cn/article-2831-1.html 1. 命令:sl (蒸汽机车) 你可能了解 ‘ls’ 命令,并经常使用它来查看文件夹的内容.但是,有些时候你可能会拼写成 ‘s ...

  3. 思道OA PK 通达OA 同场竞技 谁与争锋

    技术架构 思道OA 通达OA 开发语言 微软ASP.NET 4.0 PHP开源脚本语言 64位平台 64位 32位 数据库 SQL Server大数据库 MySQL开源数据库 官网下载 下载地址 下载 ...

  4. 1065. A+B and C (64bit)

    #include<stdio.h> #include <math.h> int main() { long long a,b,c,sum; int n,i; while(sca ...

  5. Hello,iOS

    xcode 6.1 File-New-Project.. iOs-Application-Simple View Application Main.storyboard ==> 拖一个TextV ...

  6. Mysql grant权限管理

    MySQL 赋予用户权限命令的简单格式可概括为: grant 权限 on 数据库对象 to 用户 [identified by '密码'] 最常用的,弄主从同步的时候,给从库的slave用户设置拥有所 ...

  7. Windows.Andy.Code4App.dll Win8.1/WP8.1通用类库@ver1.0.0

    直接入题! Win8.1和WP8.1眼下已经渐渐融为一体,WP8.1不断向Win8.1靠拢,虽然一些方法上WP8.1和Win8.1不同(ps:WP8.1和Win8.1的不同之处),但大部分还是相同的. ...

  8. Oracle创建序列

    CREATE SEQUENCE IF NOT EXISTS seq_fund_execute

  9. iPhone手机屏幕的尺寸

    以下是 iPhone的型号和对应的屏幕宽高 英寸  宽 高  厚度 3.5   320 480 4s      ipad   系列   4   320 568 5   5s   4.7  375 66 ...

  10. bnuoj 20838 Item-Based Recommendation (模拟)

    http://www.bnuoj.com/bnuoj/problem_show.php?pid=20838 [题意]: 有点长,略. [code]: #include <iostream> ...