汇编ARM指令说明

Assembly ARM Instruction Explanation

我需要有人详细解释以下指令:

.text:000084AC                 PUSH    {R3,LR}
.text:000084AE                 LDR     R0, =0x111C
.text:000084B0                 ADD     R0, PC
.text:000084B2                 BL      sub_9354
.text:000084B6                 MOVS    R0, #1
.text:000084B8                 POP     {R3,PC}

这组特定的指令代表主汇编程序中的子程序。让我们一一了解每条指令:

.text:000084AC PUSH {R3,LR}

PUSH <register_list>

Register_list可以来自r0-r7和LR。 PUSH 在 Thumb 状态下将多个寄存器压入堆栈。

PUSH- 将寄存器压入堆栈

通俗地说,你可以说 "Enter in subroutine"

.text:000084AE LDR R0, =0x111C

LDR - 从内存加载寄存器

LDR rd, =numeric constant
LDR     R0, =0x111C => generate LDR R0, #0x111c

ADD R0, PC

ADD op{S}{cond} {Rd,} Rn, Operand2

在你的例子中,此处省略了 Rd,因此此处 Rd=Rn。所以

R0=Program counter + R0

.text:000084B2 BL sub_9354

分支 Link (BL) 将旧 PC 写入当前组的 link 寄存器 (R14)。

B{L}{cond} <expression>

是目的地。汇编程序计算偏移量。 BL - link 分支 该指令强制程序计数器 pc 指向新地址

MOVS R0, #1

MOV<opcode>{cond}{S} Rd,<Op2>

MOV 移动寄存器或常量

如果 S 存在(暗示 CMP、CMN、TEQ、 TST) 然后将常数 1 移动到 R0

POP {R3,PC}

POP - 从堆栈弹出寄存器

通俗地说,你可以说 "return from subroutine"。

在 return R3 被弹出堆栈以及 return 地址被加载到 pc 中。这个 return 来自子程序。 参考资料取自

http://infocenter.arm.com/

http://bear.ces.cwru.edu/eecs_382/ARM7-TDMI-manual-pt2.pdf

ARM system Developer's Guide