当前位置:编程学习 > 网站相关 >>

Branch instructions(Armv6分支指令)

Thumb 支持六种跳转至零
1.  条件跳转,可以向前或向后跳转256个偏移(-256 到 +254)

2.  无条件跳转可以向前或向后跳转2KB的偏移(-2048到+2048)

3.  连接分支(子模块调用) 支持一对指令(32位指令),可以向前或向后跳转4MB.

4.  连接分支和切换都是双指令集,类似与连接分支,但是不能转换到ARM代码处执行;

5.  连接分支和切换指令可以跳转到保存在寄存器中的一个地址,可以选择切换到Arm代码处执行

6.  另外一种连接分支和交换指令可以调用在寄存在中的一个子模块的地址,并且可以选择切换到Arm代码处执行

A6.3.1 条件跳转

B<条件>  <目标地址>


A6.3.2 无条件跳转

B <目标地址>

BL <目标地址>
:处理两个16位指令

BLX  <目标地址> :处理两个16位指令


A6.3.3 交换分支

BX <Rm>
 

BLX  <Rm>


A6.3.4 实例

B label
: 无条件跳转

BCC  label : 如果进位标志被清空,跳转到label

BEQ  label : 如果零标志位被设置,则跳转到label

BL func
: 调用子模块

func

...

...

MOV  RC, LR : 返回到BL的下一条指令

BX R12
:  跳转到R12中的地址,如果R12的第0位为0; 则开始执行Arm指令,否则继续执行Thumb指令


Thumb supports six types of branch instruction.

1.a conditional branch to allow forward and backward branches of up to 256 bytes (-256 to +254)

2.an unconditional branch that allows a forward or backward branch of up to 2KB (-2048  to +248)

3.a Branch with Link (subroutine call) is supported with a pair of instructions that allow forward and backward branches of up to 4MB (-222 <= offset <= +222 -2)

4.a Branch with Link  and Exchange uses a pair of instructions , similar to Branch with Link, but additionally switches to ARM code execution.

5.a Branch and Exchange instruction branches to an address in a register and optionally switches to ARM code execution

6.a second form of Branch with Link and Exchange instruction performs a subroutine call to an address in a register and optionally switches to ARM code execution

A6.3.1 Conditional branch

B<cond>  <target_address>


A6.3.2 Unconditional branch

B <target_address>

BL <target_address>
: Produces two 16-bit instructions

BLX  <target_address> :
Produces two 16-bit instructions


A6.3.3 Branch with exchange

BX <Rm>
 

BLX  <Rm>


A6.3.4 Examples

B label
: unconditionally branch to label

BCC  label : branch to label if carry flag is clear

BEQ  label : branch to label if zero flag is set

BL func
: subroutine call to function

func

...

...

MOV PC, LR
: R15 = R14, return to instruction after the BL

BX   R12 : branch to address in R12; begin ARM execution if bit 0 of R12; otherwise continue executing Thumb code

 

补充:综合编程 , 其他综合 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,