肺型p波是什么意思| 宜祭祀是什么意思| 什么是假性狐臭| 什么的笑| 发财树为什么叫发财树| 牙齿发炎吃什么消炎药| 白带是什么味道| 5岁属什么| 荷花象征着什么| 泰州有什么好玩的地方| 神器积分换什么最划算| 孕妇不能吃什么| 古代人用什么刷牙| 电销是什么工作| 94年什么命| 嗓子痒干咳是什么原因| 胃不好早餐吃什么好| 肝内胆管结石吃什么药好| 眼底检查主要查什么| 笨和蠢有什么区别| 脚气真菌最怕什么| 丝状疣是什么样子图片| 什么属相不能戴貔貅| 版心是什么| 明天是什么节日| 贪恋是什么意思| 100岁是什么之年| 2014年属什么生肖| 梦见花生是什么意思| 附件炎吃什么药效果好| 9.9是什么星座| 免疫是什么意思| 新诺明又叫什么| 淋巴肉为什么不能吃| 觉悟是什么意思| 一夜白头是什么原因| 6月6是什么星座| 6月20日什么星座| 医助是什么工作| 什么时候建档| 月亮发红是什么原因| 梦见相亲是什么意思| 黄花菜都凉了是什么意思| 眼底出血用什么眼药水| 喜鹊吃什么食物| 鱼肝油有什么功效| 鸡蛋白是什么| 什么是羊水栓塞| 右眉上方有痣代表什么| 狼图腾是什么意思| 牛肉和什么炒| 双鱼座是什么星象| 拔了尿管尿不出来有什么好办法| 雷诺综合征是什么病| 丰盈是什么意思| 莲子吃了有什么好处| 什么姿势睡觉最好| acer是什么牌子| 肚脐下三寸是什么位置| 贲门炎吃什么药| 位置是什么意思| 无极是什么意思| 被隐翅虫咬了用什么药| 世界最大的岛是什么岛| 匹马棉是什么面料| 狗皮肤溃烂用什么药| 常见的贫血一般是缺什么| 懋是什么意思| 轻生什么意思| 东风破是什么意思| 双脚踝浮肿是什么原因| 金达克宁和达克宁有什么区别| 扁平息肉属于什么性质| 什么鱼红烧最好吃| 天蝎座和什么座最配对| 吃什么容易胖起来| 吃什么能降尿酸| 什么是肉刺图片大全| 来大姨妈拉肚子是什么原因| 鸡米头是什么| 双头蛇是什么意思| 手掌脱皮是什么原因| 什么是低血糖| 什么是高纤维食物| 牛仔裤配什么鞋| 3.19号是什么星座| 刺梨什么时候成熟| 木瓜吃了有什么好处| 吐血是什么原因| 凤凰单丛茶属于什么茶| 苏州机场叫什么| 气管炎的症状吃什么药好得快| 为什么老虎头上有王字| 当逃兵会有什么后果| 经血是什么血| 扁桃体发炎有什么症状| 低血压吃什么可以补| 餐饮五行属什么| 好运连绵是什么意思| 脖子变粗了是什么原因| 临官是什么意思| 牙疼不能吃什么| 什么水果败火| 什么病| 属猴男和什么属相最配| 宫腔积液排出什么颜色| 滴虫性阴道炎用什么药好| 公务员是什么编制| 什么叫阳性率| 匈奴人是现在的什么人| 西红柿拌白糖又叫什么| 胆红素三个指标都高是什么原因| 勿误是什么意思| 翻江倒海是什么生肖| 拜观音菩萨有什么讲究| 月经不干净是什么原因| 旗袍配什么鞋| 骨质疏松吃什么钙片好| prp是什么| 无味是什么意思| 1月1日是什么星座| 墨蓝色是什么颜色| 眉毛有什么作用| 为什么阴道会排气| 尿常规红细胞高是什么原因| 10月28是什么星座| 什么人不能吃蜂蜜| 维生素d补什么| 花花世界是什么生肖| butterfly是什么意思| 中性粒细胞百分比偏低什么意思| 腹泻吃什么食物好| 脚趾头抽筋是什么原因| 牛的五行属什么| 做梦梦见狗是什么意思| 举的部首是什么| 玫瑰花泡水有什么功效| 肝脏的主要功能是什么| 吃什么可以让阴茎变硬| 结石是什么原因引起的| 2020属什么生肖| 懵懂少年是什么意思| 出圈什么意思| 血脂异常什么意思| 突然晕倒是什么原因造成的| 海龟吃什么| 武松打虎打的是什么虎| 打太极是什么意思| 低骨量是什么意思| 马云属什么| 川普是什么意思| 梦见和尚是什么预兆| 性欲是什么| 日柱华盖是什么意思| 重阳节是干什么的| 2012属什么生肖| 什么地移入| 宫颈hpv感染是什么病| 什么是热病| 缺金的人戴什么最旺| 血糖高喝什么稀饭好| 肝右叶低密度灶是什么意思| 牙龈出血是什么病的前兆| 肺阳虚吃什么中成药| 信保是什么| 阴道变黑是什么原因| 血糖高适合吃什么食物| 眼睛充血用什么眼药水好| 什么是编外人员| 女性解脲支原体阳性吃什么药| 木隶念什么| brush什么意思| 不是什么而是什么造句| 性欲什么意思| 乳腺小叶增生是什么意思| 阿奇霉素主治什么病| 时柱金舆是什么意思| 原本是什么意思| 在什么前面用英语怎么说| 妈祖叫什么名字| 公举是什么意思啊| 体型最大的恐龙是什么| 边缘心电图是什么意思| 李时珍的皮是什么意思| 上火了吃什么食物降火| 维c有什么功效和作用| 痛风为什么要禁欲| 一毛三是什么军衔| 左肺纤维灶什么意思| 梦见雪是什么征兆| 中指麻木是什么原因引起的| 富甲一方什么意思| 鹞是什么意思| 一句没事代表什么意思| 抱薪救火是什么意思| 病毒性感冒咳嗽吃什么药效果好| 骨质疏松有什么症状| 肌肉痉挛用什么药能治好| 属鸡的本命佛是什么佛| 头响脑鸣是什么原因引起的| 小狗发烧吃什么药| 小s和黄子佼为什么分手| kpi是什么| 小ck属于什么档次| 不孕吐的人说明什么| 什么叫蛇胆疮| 无期徒刑是什么意思| 手臂肌肉跳动是什么原因| 国籍填什么| 阴阳两虚用什么药| 吃什么通便| 肺部炎症用什么药最好| 宫颈炎吃什么药好| 面部提升紧致做什么效果最好| omega是什么意思| 虾吃什么| w是什么意思| 送呈是什么意思| 8朵玫瑰花代表什么意思| 蛇是什么动物| 细胞骨架是由什么构成| 田七煲汤配什么材料| 恐龙是什么时候灭绝的| 什么是飞蚊症| 自闭症是什么| 中度贫血吃什么补血快| 中午吃什么不会胖| 打嗝是什么原因| 头疼头晕是什么原因| mrv是什么检查| 菠萝蜜吃了有什么好处| 孕妇吃什么盐最好| 复方阿胶浆适合什么样的人喝| 杨梅有什么功效和作用| 性出血是什么原因造成的呢要怎么办| 吃甘草片有什么副作用| 手心经常出汗是什么原因| 硬度不够吃什么好| 鼻塞黄鼻涕吃什么药| 什么时候吃榴莲最好| 白玉兰奖是什么级别的| 落下帷幕什么意思| y谷氨酰基转移酶高是什么原因| birkin是什么意思| 北北是什么意思| pg是什么| 肾是干什么用的| 滑液是由什么分泌的| 伤口愈合为什么会痒| 独角仙吃什么| 肝属于五行中的什么| 什么是梨形身材| 空调外机不出水是什么原因| 微创是什么| 细菌感染用什么药| 尿检弱阳性是什么意思| 经常拉肚子是什么原因引起的| 什么产品祛斑效果最好| 投喂是什么意思| 一线炎是什么病严重吗| 总爱睡觉是什么原因| 打喷嚏流鼻涕吃什么药好| 什么车适合女生开| 透支是什么意思| 百度Jump to content

克利伯环球赛:西雅图号率先抵达青岛

From Wikipedia, the free encyclopedia
百度 作为一家扎根中国的德国企业,朗盛在中国市场的不断深耕给我们带来了回报。

A branch, jump or transfer is an instruction in a computer program that can cause a computer to begin executing a different instruction sequence and thus deviate from its default behavior of executing instructions in order.[a] Branch (or branching, branched) may also refer to the act of switching execution to a different instruction sequence as a result of executing a branch instruction. Branch instructions are used to implement control flow in program loops and conditionals (i.e., executing a particular sequence of instructions only if certain conditions are satisfied).

A branch instruction can be either an unconditional branch, which always results in branching, or a conditional branch, which may or may not cause branching depending on some condition. Also, depending on how it specifies the address of the new instruction sequence (the "target" address), a branch instruction is generally classified as direct, indirect or relative, meaning that the instruction contains the target address, or it specifies where the target address is to be found (e.g., a register or memory location), or it specifies the difference between the current and target addresses.

Implementation

[edit]

Branch instructions can alter the contents of the CPU's program counter (PC) (or instruction pointer on Intel microprocessors). The program counter maintains the memory address of the next machine instruction to be fetched and executed. Therefore, a branch, if executed, causes the CPU to execute code from a new memory address, changing the program logic according to the algorithm planned by the programmer.

One type of machine level branch is the jump instruction. These may or may not result in the PC being loaded or modified with some new, different value other than what it ordinarily would have been (being incremented past the current instruction to point to the following, next instruction). Jumps typically have unconditional and conditional forms where the latter may be taken or not taken (the PC is modified or not) depending on some condition.

The second type of machine level branch is the call instruction which is used to implement subroutines. Like jump instructions, calls may or may not modify the PC according to condition codes, however, additionally a return address is saved in a secure place in memory (usually in a memory resident data structure called a stack). Upon completion of the subroutine, this return address is restored to the PC, and so program execution resumes with the instruction following the call instruction.

The third type of machine level branch is the return instruction. This "pops" a return address off the stack and loads it into the PC register, thus returning control to the calling routine. Return instructions may also be conditionally executed. This description pertains to ordinary practice; however, the machine programmer has considerable powers to manipulate the return address on the stack, and so redirect program execution in any number of different ways.

Depending on the processor, jump and call instructions may alter the contents of the PC register in different ways. An absolute address may be loaded, or the current contents of the PC may have some value (or displacement) added or subtracted from its current value, making the destination address relative to the current place in the program. The source of the displacement value may vary, such as an immediate value embedded within the instruction, or the contents of a processor register or memory location, or the contents of some location added to an index value.

The term branch can also be used when referring to programs in high-level programming languages. In these branches usually take the form of conditional statements of various forms that encapsulate the instruction sequence that will be executed if the conditions are satisfied. Unconditional branch instructions such as GOTO are used to unconditionally jump to a different instruction sequence. If the algorithm requires a conditional branch, the GOTO (or GOSUB subroutine call) is preceded by an IF-THEN statement specifying the condition(s). All high level languages support algorithms that can re-use code as a loop, a control structure that repeats a sequence of instructions until some condition is satisfied that causes the loop to terminate. Loops also qualify as branch instructions. At the machine level, loops are implemented as ordinary conditional jumps that redirect execution to repeating code.

In CPUs with flag registers, an earlier instruction sets a condition in the flag register. The earlier instruction may be arithmetic, or a logic instruction. It is often close to the branch, though not necessarily the instruction immediately before the branch. The stored condition is then used in a branch such as jump if overflow-flag set. This temporary information is often stored in a flag register but may also be located elsewhere. A flag register design is simple in slower, simple computers. In fast computers a flag register can place a bottleneck on speed, because instructions that could otherwise operate in parallel (in several execution units) need to set the flag bits in a particular sequence.

There are also machines (or particular instructions) where the condition may be checked by the jump instruction itself, such as branch <label> if register X negative. In simple computer designs, comparison branches execute more arithmetic and can use more power than flag register branches. In fast computer designs comparison branches can run faster than flag register branches, because comparison branches can access the registers with more parallelism, using the same CPU mechanisms as a calculation.

Some early and simple CPU architectures, still found in microcontrollers, may not implement a conditional jump, but rather only a conditional "skip the next instruction" operation. A conditional jump or call is thus implemented as a conditional skip of an unconditional jump or call instruction.

Examples

[edit]

Depending on the computer architecture, the assembly language mnemonic for a jump instruction is typically some shortened form of the word jump or the word branch, often along with other informative letters (or an extra parameter) representing the condition. Sometimes other details are included as well, such as the range of the jump (the offset size) or a special addressing mode that should be used to locate the actual effective offset.

This table lists the machine level branch or jump instructions found in several well-known architectures:

condition or result x86 PDP-11, VAX ARM (partly 6502) equation
zero (implies equal for sub/cmp) JZ; JNZ BEQ; BNE BEQ; BNE zero; not zero
negative (N), sign (S), or minus (M) JS; JNS BMI; BPL BMI; BPL negative; not negative
arithmetic overflow (flag called O or V) JO; JNO BVS; BVC BVS; BVC overflow; not overflow
carry (from add, cmp, shift, etc.) JC; JNC BCS; BCC BCS; BCC carry; not carry
unsigned below (lower) JB BLO BLO * borrow
unsigned below or equal (lower or same) JBE BLOS BLS * borrow or zero
unsigned above or equal (higher or same) JAE BHIS BHS * not borrow
unsigned above (higher) JA BHI BHI * not borrow and not zero
signed less than JL BLT BLT sign≠overflow
signed less or equal JLE BLE BLE (sign≠overflow) or zero
signed greater or equal JGE BGE BGE sign=overflow
signed greater than JG BGT BGT (sign=overflow) and not zero

* x86, the PDP-11, VAX, and some others, set the carry-flag to signal borrow and clear the carry-flag to signal no borrow. ARM, 6502, the PIC, and some others, do the opposite for subtractive operations. This inverted function of the carry flag for certain instructions is marked by (*), that is, borrow=not carry in some parts of the table, but if not otherwise noted, borrow≡carry. However, carry on additive operations are handled the same way by most architectures.

Performance problems with branch instructions

[edit]

To achieve high performance, modern processors are pipelined. They consist of multiple parts that each partially process an instruction, feed their results to the next stage in the pipeline, and start working on the next instruction in the program. This design expects instructions to execute in a particular unchanging sequence. Conditional branch instructions make it impossible to know this sequence. So conditional branches can cause "stalls" in which the pipeline has to be restarted on a different part of the program.

Improving performance by reducing stalls from branches

[edit]

Several techniques improve speed by reducing stalls from conditional branches.

Branch prediction hints

[edit]

Historically, branch prediction took statistics, and used the result to optimize code. A programmer would compile a test version of a program, and run it with test data. The test code counted how the branches were actually taken. The statistics from the test code were then used by the compiler to optimize the branches of released code. The optimization would arrange that the fastest branch direction (taken or not) would always be the most frequently taken control flow path. To permit this, CPUs must be designed with (or at least have) predictable branch timing. Some CPUs have instruction sets (such as the Power ISA) that were designed with "branch hints" so that a compiler can tell a CPU how each branch is to be taken.

The problem with software branch prediction is that it requires a complex software development process.

Hardware branch predictors

[edit]

To run any software, hardware branch predictors moved the statistics into the electronics. Branch predictors are parts of a processor that guess the outcome of a conditional branch. Then the processor's logic gambles on the guess by beginning to execute the expected instruction flow. An example of a simple hardware branch prediction scheme is to assume that all backward branches (i.e. to a smaller program counter) are taken (because they are part of a loop), and all forward branches (to a larger program counter) are not taken (because they leave a loop). Better branch predictors are developed and validated statistically by running them in simulation on a variety of test programs. Good predictors usually count the outcomes of previous executions of a branch. Faster, more expensive computers can then run faster by investing in better branch prediction electronics. In a CPU with hardware branch prediction, branch hints let the compiler's presumably superior branch prediction override the hardware's more simplistic branch prediction.

Branch-free code

[edit]

Some logic can be written without branches or with fewer branches. It is often possible to use bitwise operations, conditional moves or other predication instead of branches.[1][2] In fact, branch-free code is a must for cryptography due to timing attacks.[3]

Delay slot

[edit]

Another technique is a branch delay slot. In this approach, at least one instruction following a branch is always executed, with some exceptions such like the legacy MIPS architecture likely/unlikely branch instruction. Therefore, the computer can use this instruction to do useful work whether or not its pipeline stalls. This approach was historically popular in RISC computers. In a family of compatible CPUs, it complicates multicycle CPUs (with no pipeline), faster CPUs with longer-than-expected pipelines, and superscalar CPUs (which can execute instructions out of order.)

See also

[edit]

Notes

[edit]
  1. ^ At least conceptually; see out-of-order execution.

References

[edit]
  1. ^ Knuth, Donald (2008). The Art of Computer Programming. Vol. 4, Pre-fascicle 1A (Revision 6 ed.). pp. 48–49.
  2. ^ "Avoiding Branches". Chessprogramming wiki.
  3. ^ "Constant-Time Crypto". BearSSL.
[edit]
什么路人不能走 叶酸什么时间段吃最好 梦见自己梳头发是什么意思 养兰花用什么土最好 尿中泡沫多是什么原因
什么品牌的奶粉最好 为什么过敏反复发作 总是感觉口渴是什么原因 fomo是什么意思 姨妈期间可以吃什么水果
广西属于什么地区 女生私密部位长什么样 芳菲的意思是什么 狼吞虎咽什么意思 什么叫原研药
mint什么颜色 什么是斜视 zara是什么牌子 胆囊炎挂什么科 八月一日是什么日子
授人以鱼不如授人以渔什么意思hcv8jop1ns2r.cn 什么人不宜吃海参hcv8jop6ns5r.cn 尖锐湿疣是什么病bjhyzcsm.com 衣钵是什么意思ff14chat.com 山药炒什么好吃hcv8jop2ns0r.cn
浙江大学什么专业最好hcv8jop3ns8r.cn 脊髓病变是什么病hcv8jop7ns1r.cn 阑尾在什么位置hcv9jop5ns9r.cn 马克定食是什么意思hcv9jop4ns8r.cn 五十八岁属什么生肖hcv9jop0ns7r.cn
全血细胞减少是什么意思dayuxmw.com 蜈蚣怕什么hcv8jop8ns9r.cn 1987年什么命hcv9jop5ns3r.cn 胸前出汗多是什么原因hcv8jop0ns3r.cn 军校毕业是什么军衔hcv9jop7ns2r.cn
支原体衣原体是什么病hcv9jop8ns1r.cn 什么是调和油hcv8jop6ns1r.cn 如来佛祖和释迦牟尼是什么关系hcv8jop1ns1r.cn 什么地躺着hcv8jop0ns5r.cn 男人什么脸型最有福气hcv8jop8ns9r.cn
百度