Label (computer science)

A label ( to German: jump label) in a source code of a computer program is a brand uniquely identified by an identifier, which usually serves as a jump destination.

Use

Assembler languages

Order in an assembly language, for example, To realize loops can usually be bound relative to the current command counter - example to 5 commands back. However, this is very inflexible: For example, if a command is inserted or removed, must all relative jumps, the jump over this point to be adjusted. Besides, this is hard to read, because it is then often necessary to count individual Programmsequelzen instruction by instruction.

To avoid these problems, there are labels. This provided some codes with a unique identifier. Thus, directly to that label, ie jump to this code without the problems described above occur.

For example in a pseudo - assembly language:

Mov $ v0, 0   My Label :; here a label is set to the identifier " My Label "     add $ v0, $ s0; Code in the " loop body "     subi $ t0, 1; Code in the " loop body "   bne $ t0, $ zero, My Label; conditional jump to label                             ; here it goes, if it is not bound high-level languages

Also, some high-level programming - particularly older ones - offer the option labels to put to (usually called goto ) to enter through direct jumps to specific codes. However, their use quickly leads to larger programs to visibility is poor, difficult to read and poorly wartbarem source code ( so-called spaghetti code).

Therefore Modern programming languages ​​provide appropriate control instructions that make the use of labels and direct jumps in the source code unnecessary, so that they no longer exist in many programming languages ​​or only to a very limited extent (eg in the case statements from C #).

Another construct that can replace jump instructions in many high-level languages ​​, is structured exception handling, mostly try with the instructions and catch.

Algorithms

The term can also be found in the German descriptions of algorithms equivalent identifier or attribute. Exemplary meaning pairs are

  • Marked and labeled =
  • Labels = attributes / labels.
494255
de