| 1 |
\section{Labels} |
| 2 |
|
| 3 |
\newdef{Labels} are used as symbolic names for address. |
| 4 |
The structure \mlrischref{instructions/labels.sml}{Label} |
| 5 |
defines the label datatype. The following operations are defined |
| 6 |
on labels: |
| 7 |
\begin{itemize} |
| 8 |
\item \sml{newLabel : string -> label} -- Generate a new label with |
| 9 |
a given name. If the name is \sml{""}, a new name is generated. |
| 10 |
\item \sml{nameOf : label -> string} -- Returns the name of |
| 11 |
a label |
| 12 |
\item \sml{id : label -> int} -- Return the unique id of a label |
| 13 |
\item \sml{reset : unit -> unit} -- Return the label id counter to 0. |
| 14 |
\end{itemize} |
| 15 |
|
| 16 |
For machine code generation, the following two additional methods are |
| 17 |
defined. |
| 18 |
\begin{itemize} |
| 19 |
\item \sml{addrOf : label -> int} -- Return the address associated with |
| 20 |
a label |
| 21 |
\item \sml{setAddr : label * int -> unit} -- Set the address associated |
| 22 |
with a label |
| 23 |
\end{itemize} |
| 24 |
|
| 25 |
See also \href{labelexp.html}{Label Expressions}. |