Probability variables must be defined in the section “data” of an assembler program. Every definition of a probability variable must be on a separate line. Such line must begin with a data label followed by at least one whitespace character, the ‘prob’ keyword, at least one whitespace character, and the initial value of a probability variable in the range 0 to 1 inclusive. The data label is the name of the probability variable. The assembler supports fixed-point and exponential notations of specifying initial values of probability variables. The section “data” followed by the section “code” may look like this:
.data var_name_1 prob val1 var_name_2 prob val2 ... var_name_N prob valN .code
The program can contain multiple ‘.data’ and ‘.code’ blocks, e.g. within macros later expanded by the assembler preprocessor. The parser merges those blocks into a single section “data” and a single section “code”.
Names of probability variables previously defined in the section “data” can be used in
case instructions instead of fixed probability values:
jprob var_name, loc_label
case var_name, loc_label
For example, a
choice instruction block may look like this:
choice case var1, L1 case var2, L2 case 0.25, L3 case var1, L4 end choice
Names of probability variables can also be used in ‘probeq’ and ‘probls’ directives that define probabilities lists. See Using Probabilities Lists, for more information on probabilities lists.
In a ‘probeq’ directive, which defines a probabilities list that contains equal elements, a probability variable can be used as a second argument:
ls_name probeq length, var_name
In a ‘probls’ directive, which defines a probabilities list that contains specific elements, probability variables can be used as the elements of the list. An example ‘probls’ directive with some list elements equal to values of probability variables may look like this:
ls1 probls var1, var1, var2, var2, var3, var3, 0.05, 0.05
After converting the text of an assembler program to a memory representation of the program, the number of probability variables defined in the program can be obtained using the following function.
This function returns the number of probability variables defined in program prg using ‘prob’ directives. The returned value is always non-negative.
To get the name of a probability variable by its index in the memory representation of an assembler program, the following function can be used.
This function returns the name of a probability variable with index var_idx in program prg. If var_idx is negative or is greater than or equal to the number of probability variables defined in the program using ‘prob’ directives, then 0 will be returned.