Next: , Previous: , Up: Assembler Programs   [Contents][Index]


5.2 Assembler Program Syntax

An assembler program consists of lines. You can use empty lines to decorate the program. Comments are line characters starting with the first character ‘;’ outside a string literal; such literals can be parts of parameters of an assembler instruction (see Setting Text Instruction Parameters, for more information on string literals). For proper identification of continuation of multi-line comments, align the characters ‘;’ starting every line of a multi-line comment one beneath the another.

If the first character on a line is not a whitespace character and not ‘;’, then that first character must be the start of a label definition. There are two possible types of labels: location labels and data labels. The definitions of location labels end with the character ‘:’. The definitions of data labels do not end with that character. The first character of a label must be an English letter or the character ‘_’. Every subsequent character of the label (except for the last character ‘:’ in the definition of a location label) must be an English letter, digit, or ‘_’. The definition of a location label can be on a separate line, or at least one whitespace character and an assembler instruction can follow that definition. At least one whitespace character and the ‘prob’ keyword (see Variables in an Assembler Program, for more information on that keyword) must follow the definition of a data label.

If a line starts with at least one whitespace character, then an assembler instruction can follow these whitespace characters. The assembler instruction consists of an instruction name optionally followed by at least one whitespace character and instruction parameters. The assembler ignores whitespace characters in instruction parameters outside string literals.

A sample assembler program is below:

L1:     stt
        jprob   0.5, L2         ; jump with probability 0.5
        foo     4               ; user instruction
        jmp     L1

L2:     bar     r3, 5           ; user instruction
        jmp     L1

At present, an assembler program can contain “data” and “code” sections. The “data” sections can define probability variables using the ‘prob’ keyword following a data label and at least one whitespace character. The “code” sections can contain assembler instructions. The ‘.data’ and ‘.code’ directives mark the beginnings of blocks of “data” and “code” sections respectively. Those directives must be on lines of their own (after at least one whitespace character at the beginning of a line). If an assembler program contains multiple ‘.data’ and ‘.code’ directives, the assembler merges the corresponding blocks into a single “data” section and a single “code” section. By default, the assembler assumes that an assembler program starts with a ‘.code’ block.

The assembler supports the ‘line’ directive and uses information changed by it when printing error, warning, and note messages. You can put that directive in an assembler program explicitly, or the assembler preprocessor (see Using the Assembler Preprocessor) may generate it. The ‘line’ directive can change the current line number in the source file, the name of that source file, the stack of include locations, and the stack of macro expansion locations tracked by the assembler. This manual does not document changing the stack of include locations and the stack of macro expansion locations, because the corresponding syntax of ‘line’ directive will likely be different in future QSMM versions.

The directive must be on a separate line (after at least one whitespace character at the beginning of the line) and should have one of the following formats:

        line    line_number
        line    line_number, file_name

In the first case, the directive changes the tracked number of the next line in the current source file to line_number. In the second case, the directive changes the tracked number of the next line to line_number and the tracked name of the current source file to file_name. The parameter file_name must be a (quoted) string literal.


Next: , Previous: , Up: Assembler Programs   [Contents][Index]