作为加载指令
立即偏移:
使用立即偏移量,前置索引立即偏移量,或后置索引立即偏移量加载
语法:
1 2 3 4 5 6 | LDR{ type }{cond} Rt, [Rn {, #offset}] ; 立即偏移 LDR{ type }{cond} Rt, [Rn, #offset]! ; 前置索引 LDR{ type }{cond} Rt, [Rn], #offset ; 后置索引 LDRD{cond} Rt, Rt2, [Rn {, #offset}] ; immediate offset, doubleword LDRD{cond} Rt, Rt2, [Rn, #offset]! ; pre-indexed, doubleword LDRD{cond} Rt, Rt2, [Rn], #offset ; post-indexed, doubleword |
PC相对:
加载寄存器,地址是相对PC的一个偏移
语法:
1 2 | LDR{ type }{cond}{.W} Rt, label LDRD{cond} Rt, Rt2, label ; Doubleword |
label是PC相对的表达式
寄存器偏移:
使用寄存器偏移,前置索引寄存器偏移,后置索引寄存器偏移加载
语法:
1 2 3 4 5 6 | LDR{ type }{cond} Rt, [Rn, ±Rm {, shift }] ; register offset LDR{ type }{cond} Rt, [Rn, ±Rm {, shift }]! ; pre-indexed ; ARM only LDR{ type }{cond} Rt, [Rn], ±Rm {, shift } ; post-indexed ; ARM only LDRD{cond} Rt, Rt2, [Rn, ±Rm] ; register offset, doubleword ; ARM only LDRD{cond} Rt, Rt2, [Rn, ±Rm]! ; pre-indexed, doubleword ; ARM only LDRD{cond} Rt, Rt2, [Rn], ±Rm ; post-indexed, doubleword ; ARM only |
寄存器相对:
加载寄存器,地址是相对一个基寄存器的偏移
语法:
1 2 | LDR{ type }{cond}{.W} Rt, label LDRD{cond} Rt, Rt2, label ; Doubleword |
2.作为伪指令
使用一个32位立即数或地址加载寄存器
语法:
1 2 | LDR{cond}{.W} Rt, = expr LDR{cond}{.W} Rt, =label_expr |
使用LCR伪指令时,如果expr的值能被一个有效MOV或MVN指令加载,那么汇编器将使用这条指令;
如果有效MOV或MVN指令无法使用,或者label_expr语法使用了,那么汇编器将把值存放在一个文字池,并且生成一个PC相对的LDR指令从文字池里面读取值。
本文为Adamin90原创文章,转载无需和我联系,但请注明来自http://www.lixiaopeng.top