Symbolic Labels

A label is a symbolic alias that is assigned a value that is equal to the current address within the current psect. Labels are not assigned a value until link time.

A label definition consists of any valid assembly identifier that must be followed by a colon, :. The definition can appear on a line by itself or it can be positioned to the left of an instruction or assembler directive. Here are two examples of legitimate labels interspersed with assembly code.

frank:
  movlw   1
  goto	    fin
simon44: clrf _input

Here, the label frank will ultimately be assigned the address of the movlw instruction and simon44 the address of the clrf instruction. Regardless of how they are defined, the assembler list file produced by the assembler will always show labels on a line by themselves.

Labels can be used (and are preferred) in assembly code, rather than using an absolute address with other instructions. In this way, they can be used as the target location for jump-type instructions or to load an address into a register.

Like variables, labels have scope. By default, they can be used anywhere in the module in which they are defined. They can be used by code located before their definition. To make a label accessible in other modules, use the GLOBAL directive (see Global Directive for more information).