Next: Controlled Variables, Up: Using Probability Variables [Contents][Index]

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:

.datavar_name_1probval1var_name_2probval2...var_name_NprobvalN.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 `jprob`

and `case`

instructions instead of fixed probability values:

jprobvar_name,loc_label

casevar_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_nameprobeqlength,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.

- Function:
*int***qsmm_get_prg_nvar***(qsmm_prg_t*`prg`) 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.

- Function:
*const char ****qsmm_get_prg_var_name***(qsmm_prg_t*`prg`, int`var_idx`) 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.

Next: Controlled Variables, Up: Using Probability Variables [Contents][Index]