Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 2.07 KB

ii.5.4-labels-and-lists-of-labels.md

File metadata and controls

37 lines (24 loc) · 2.07 KB

II.5.4 Labels and lists of labels

Labels are provided as a programming convenience; they represent a number that is encoded in the metadata. The value represented by a label is typically an offset in bytes from the beginning of the current method, although the precise encoding differs depending on where in the logical metadata structure or CIL stream the label occurs. For details of how labels are encoded in the metadata, see clauses §II.22 through §II.25; for their encoding in CIL instructions see Partition III.

A simple label is a special name that represents an address. Syntactically, a label is equivalent to an Id. Thus, labels can be single quoted and can contain Unicode characters.

A list of labels is comma separated, and can be any combination of simple labels.

LabelOrOffset ::=
Id
Labels ::=
LabelOrOffset [ ',' LabelOrOffset ]*

[Note: In a real assembler the syntax for LabelOrOffset might allow the direct specification of a number rather than requiring symbolic labels. end note]

ILAsm distinguishes between two kinds of labels: code labels and data labels. Code labels are followed by a colon (":") and represent the address of an instruction to be executed. Code labels appear before an instruction and they represent the address of the instruction that immediately follows the label. A particular code label name shall not be declared more than once in a method.

In contrast to code labels, data labels specify the location of a piece of data and do not include the colon character. A data label shall not be used as a code label, and a code label shall not be used as a data label. A particular data label name shall not be declared more than once in a module.

CodeLabel ::=
Id ':'
DataLabel ::=
Id

[Example: The following defines a code label, ldstr_label, that represents the address of the ldstr instruction:

ldstr_label: ldstr "A label"

end example]