Английская Википедия:Indirect branch

Материал из Онлайн справочника
Перейти к навигацииПерейти к поиску

Шаблон:Refimprove

Шаблон:Machine code

An indirect branch (also known as a computed jump, indirect jump and register-indirect jump) is a type of program control instruction present in some machine language instruction sets. Rather than specifying the address of the next instruction to execute, as in a direct branch, the argument specifies where the address is located. An example is 'jump indirect on the r1 register', which means that the next instruction to be executed is at the address in register r1. The address to be jumped to is not known until the instruction is executed. Indirect branches can also depend on the value of a memory location.

An indirect branch can be useful to make a conditional branch, especially a multiway branch. For instance, based on program input, a value could be looked up in a jump table of pointers to code for handling the various cases implied by the data value. The data value could be added to the address of the table, with the result stored in a register. An indirect jump could then be made based on the value of that register, efficiently dispatching program control to the code appropriate to the input.

In a similar manner, subroutine call instructions can be indirect, with the address of the subroutine to be called specified in memory. Function Pointers are typically implemented with indirect subroutine calls.

Indirect branches were one of the attack surfaces of Spectre. To mitigate the attack GCC 8.1 introduced the following new options: -mindirect-branch=, -mfunction-return= and -mindirect-branch-register.[1][nb 1]

Example assembler syntax

MSP430:   br r15
SPARC:   jmpl %o7
MIPS:    Шаблон:Code
x86 (AT&T Syntax):      Шаблон:Code
x86 (Intel Syntax):      Шаблон:Code
ARM:     Шаблон:Code, Шаблон:Code
Itanium (x86 family):    br.ret.sptk.few rp
6502:    Шаблон:Code
65C816 Шаблон:Code
6809 jmp [$0DEA], jmp B,X, jmp [B,X]
6800 jmp 0,X
Z80 jp (hl)
Intel 8080 pchl
IBM System z bcr cond,r1[2]
RISC-V: jalr x0, 0(x1)

See also

Notes

Шаблон:Reflist

References

Шаблон:Reflist Шаблон:Compu-prog-stub

  1. Ошибка цитирования Неверный тег <ref>; для сносок GCC_2018_Spectre не указан текст
  2. Ошибка цитирования Неверный тег <ref>; для сносок IBM не указан текст


Ошибка цитирования Для существующих тегов <ref> группы «nb» не найдено соответствующего тега <references group="nb"/>