5.8.1 Variables in an Assembler Program

The prob instruction declares a probability variable and sets it equal to a specific value:

var_name prob    val

A jprob or case instruction can declare a probability variable too:

var_name_1 jprob   val1, loc_label_1

           choice
           ...
var_name_2 case    val2, loc_label_2
           ...
var_name_3 case    val3, loc_label_3
           ...
           case    val4, loc_label_4
           ...
           end     choice

A declared probability variable takes a value specified by the first argument of jprob or case instruction.

The name of a declared probability variable is available for use in jprob and case instructions on subsequent lines of a plain assembler program or assembler procedure:

           jprob   var_name, loc_label_5

           choice
           ...
           case    var_name_1, loc_label_6
           ...
           case    var_name_2, loc_label_7
           ...
           case    var_name_3, loc_label_8
           ...
           case    val9, loc_label_9
           ...
           end     choice

A jprob or case instruction cannot simultaneously declare a probability variable (via a data label) and use a probability variable specified in the first instruction argument.

After parsing an assembler program, you can obtain the number of probability variables declared in it by the following function.

Function: size_t qsmm_get_prg_nvar (qsmm_prg_t prg)

This function returns the number of probability variables declared in a program prg using data labels of prob, jprob, and case instructions.

Use the following function to get the name of a probability variable by its index.

Function: const char * qsmm_get_prg_var_name (qsmm_prg_t prg, size_t var_idx)

This function returns the name of a probability variable with index var_idx in a program prg. If var_idx is greater than or equal to the number of probability variables declared in the program using data labels of prob, jprob, and case instructions, the function returns NULL.

See Output Arrays, for how to declare output probabilities arrays in an assembler program.