Programming with Ophis
<<< Previous |  | Next >>>

# Labels and aliases

Labels are an important part of your code. However, since each label must normally be unique, this can lead to "namespace pollution," and you'll find yourself going through ever more contorted constructions to generate unique label names. Ophis offers two solutions to this: anonymous labels and temporary labels. This tutorial will cover both of these facilities, and also introduce the aliasing mechanism.

# Temporary labels

Temporary labels are the easiest to use. If a label begins with an underscore, it will only be reachable from inside the innermost enclosing scope. Scopes begin when a `.scope` statement is encountered. This produces a new, inner scope if there is another scope in use. The `.scend` command ends the innermost currently active scope.

We can thus rewrite our header data using temporary labels, thus allowing the main program to have a label named `next` if it wants.

    .word $0801
    .org  $0801

    .scope
            .word _next, 10      ; Next line and current line number
            .byte $9e," 2064",0  ; SYS 2064
    _next:  .word 0              ; End of program
    .scend

    .advance 2064

<<< Previous | Home | Next >>>
Assembling the code |  | Anonymous labels