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 that start with the first character ‘;’ not within a string literal (such literal can be a part of parameters of an assembler instruction). For proper identification of continuation of multiline comments, align characters ‘;’ that start every line of a multiline comment one beneath the another.

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

If the line starts with at least one whitespace character, then these characters can be followed by an assembler instruction. It consists of an instruction name optionally followed by at least one whitespace character and instruction parameters. The assembler skips whitespace characters in instruction parameters not within string literals.

Below is a sample assembler program.

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

L2:     bar     r3, 5           ; a user instruction
        jmp     L1

There can be two sections in an assembler program: the section “data” and the section “code”. In the section “data” you can define probability variables and probabilities lists (see Using Probability Variables and Using Probabilities Lists); to every probability variable or a probabilities list a data label corresponds. In the section “code” there can be assembler instructions. The ‘.data’ and ‘.code’ directives mark the beginnings of blocks of the corresponding sections. 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 section “data” and a single section “code”. 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 the source file, the stack of include locations, and the stack of macro expansion locations tracked by the assembler. However, this manual does not document changing the stack of include locations and the stack of macro expansion locations, because the corresponding syntax of the ‘line’ directive will likely be different in future versions of the QSMM package.

The directive must be placed on a separate line (after at least one whitespace character at the beginning of the line) and should be in 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 value of file_name must be a (quoted) string literal.


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