ARM Assembly: 第8课 branching

[复制链接]
发表于 2026-1-14 20:51:59 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
branch causes a branch to a target address.  The "B" mnemonic signifies an unconditional branch.
  单个的B表现进入一个无条件的分支,而含条件的分支通常可以基于APSR 条件flag举行指令的实验。比如,基于condition flag z是否为1, 我们可以举行BEQ效果的判断。
如下面代码
  1. .global _start
  2. _start:
  3.     mov r0, #4         ; Move the immediate value 4 into register r0
  4.     mov r1, #5         ; Move the immediate value 5 into register r1
  5.    
  6.     cmp r0, r1         ; Compare the values in r0 and r1 (sets the APSR flags)
  7.     bgt cond1          ; Branch to label 'cond1' if r0 is greater than r1
  8.     b   cond2          ; Unconditional branch to label 'cond2'
  9. cond1:
  10.     mov r2, #1         ; If r0 > r1, move 1 into r2
  11.    
  12. cond2:
  13.     mov r3, #2         ; Always move 2 into r3
复制代码
下面是各种条件分支的触发机制和与condition flag的关系。【2】

参考链接【2】



参考链接:
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表