马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
branch causes a branch to a target address. The "B" mnemonic signifies an unconditional branch.
单个的B表现进入一个无条件的分支,而含条件的分支通常可以基于APSR 条件flag举行指令的实验。比如,基于condition flag z是否为1, 我们可以举行BEQ效果的判断。
如下面代码
- .global _start
- _start:
- mov r0, #4 ; Move the immediate value 4 into register r0
- mov r1, #5 ; Move the immediate value 5 into register r1
-
- cmp r0, r1 ; Compare the values in r0 and r1 (sets the APSR flags)
- bgt cond1 ; Branch to label 'cond1' if r0 is greater than r1
- b cond2 ; Unconditional branch to label 'cond2'
- cond1:
- mov r2, #1 ; If r0 > r1, move 1 into r2
-
- cond2:
- mov r3, #2 ; Always move 2 into r3
复制代码 下面是各种条件分支的触发机制和与condition flag的关系。【2】
参考链接【2】
参考链接:
|