arm 多寄存器存取使用
多寄存器和堆棧尋址的用法:
多寄存器尋址:LDMIA,LDMIB,STMIA,STMIB,LDMDA,LDMDB,STMDA,STMDB;
堆棧尋址:LDMFA,LDMFD,STMFA,STMFD,LDMEA,LDMED,STMEA,STMED;
指令后綴的解釋:
弄清堆棧尋址的SP的變化:LDMFA,LDMFD,STMFA,STMFD,LDMEA,LDMED,STMEA,STMED;
IA: 每次傳送后地址加4;
IB: 每次傳送前地址加4;
DA: 每次傳送后地址減4;
DB: 每次傳送前地址減4;
FD: 滿遞減堆棧;
ED: 空遞減堆棧;
FA: 滿遞增堆棧;
EA: 空遞增堆棧。
1、多寄存器尋址:
LDMIA R0!,{R1-R4}
;R1<----[R0]
;R2<----[R0+4]
;R3<----[R0+8]
;R4<----[R0+12]
例如:
所有的示例指令執(zhí)行前:
mem32[0x1000C] = 0x04
mem32[0x10008] = 0x03
mem32[0x10004] = 0x02
mem32[0x10000] = 0x01
r0 = 0x00010010
r1 = 0x00000000
r3 = 0x00000000
r4 = 0x00000000
1) ldmia r0!, {r1-r3} 2) ldmib r0!, {r1-r3}
執(zhí)行后: 執(zhí)行后:
r0 = 0x0010001C r0 = 0x0010001C
r1 = 0x01 r1 = 0x02
r2 = 0x02 r2 = 0x03
r3 = 0x03 r3 = 0x04
2、堆棧尋址:
STMFD入棧指令,相當(dāng)于STMDB
STMFD SP!,{R2-R4}
;[SP-4]<---R4
;[SP-8]<---R3
;[SP-12]<---R2
LDMFD出棧指令,相當(dāng)于LDMIA
LDMFD SP!,{R6-R8}
;R6<----[SP]
;R7<----[SP+4]
;R8<----[SP+8]
評(píng)論