ARM Assembly: 第8课 branching
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】
参考链接:
【1】Documentation – Arm Developer
【2】Documentation – Arm Developer
原文地址:https://blog.csdn.net/qq_19859865/article/details/142665360
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!