您好,欢迎来到易妖游戏网。
搜索
您的当前位置:首页arm push/pop/b/bl汇编指令

arm push/pop/b/bl汇编指令

来源:易妖游戏网



1. push指令

  • 功能描述:入栈
  • 语法

 要点:

  • push支持同时将多个寄存器入栈,格式:{xx,xx},如:push {r0, r1,r2} 
  • 入栈顺序是先入栈序号低的寄存器到最低地址,比如push {fp, lr}效果图:
  •  push {r0, r1}和push{r1, r0}效果是一样的,因为按照arm规范是按照寄存器序列号顺序开始入栈,且从小序列号开始入栈。比如这种总是将r0入栈到低地址。

2. pop指令

  • 功能描述:出栈

Pop Multiple Registers loads multiple registers from the stack, loading from consecutive memory locations starting at the address in SP, and updates SP to point just above the loaded data.

  • 语法

要点:

  • 如同push一样,pop也支持同时pop出栈多个寄存器。
  • 出栈顺序和入栈顺序相反。pop {fp, lr},先从sp指向栈低地址处出栈内容到fp,再从高地址处出栈内容到lr中。

3. b指令

  • 功能描述:

Branch causes a branch to a target address.

  • 语法:只是简单的跳转到label处

B{<c>}{<q>} <label>

4. bl指令

  • 功能描述:

Branch with Link calls a subroutine at a PC-relative address.
Branch with Link and Exchange Instruction Sets (immediate) calls a subroutine at a PC-relative address, and changes instruction set from ARM to Thumb, or from Thumb to ARM.

  • 语法:

BL{X}{<c>}{<q>} <label>

The label of the instruction that is to be branched to.
For BL (encodings T1, A1), the assembler calculates the required value of the offset from the PC value of the BL instruction to this label, then selects an encoding that sets imm32 to that offset. Permitted offsets are even numbers in the range –16777216 to 16777214 (Thumb) or multiples of 4 in the range –33554432 to 33554428 (ARM).

BL指令于B指令区别:

        BL函数条跳转前执行:LR = PC - 4; (armv7为例)

Note: bl指令会计算label和当前pc位置的offset,所以这是相对跳转 

5. bx指令

  • 功能描述:跳转到寄存器中的地址

Branch and Exchange causes a branch to an address and instruction set specified by a register.

  • 语法

BX{<c>}{<q>} <Rm>

The register that contains the branch target address and instruction set selection bit. The PC can be used. This register can be the SP in both ARM and Thumb instructions, but ARM deprecates this use of the SP.

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- vipyiyao.com 版权所有 湘ICP备2023022495号-8

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务