5.1.2.6 stt Instruction

This instruction has the forms

        stt
        stt     state_name

equivalent to the notation

        stt     [state_name]

The instruction marks the beginning of a state of a plain assembler program. The state biuniquely corresponds to a state of a node with the assembler program loaded. The former state and the latter state can have a name specified by a (quoted) string literal state_name. A plain assembler program must not contain states with duplicate names. See Loading a Parsed Program into a Node, for the description of qsmm_get_node_state_name and qsmm_get_node_state_by_name functions retrieving the name of a node state by its index and retrieving the index of a node state by its name.

The stt instruction selects the action emission matrix to hold profile probabilities specified by subsequent jprob or case instructions in a plain assembler program. Without the stt instruction, the subsequent jprob or case instructions would specify profile probabilities held in the state transition matrix on condition that it did not have the restriction to define only deterministic state transitions.

If the state transition matrix has the restriction to define only deterministic state transitions, or the action emission matrix has the restriction to define only deterministic action emissions, specifying stt instructions to mark beginnings of states is not necessary unless stt instructions assign names to states. If the state transition matrix has the restriction to define only deterministic state transitions, all jprob and case instructions in a plain assembler program specify profile probabilities held in the action emission matrix. If the action emission matrix has the restriction to define only deterministic action emissions, all jprob and case instructions in a plain assembler program specify profile probabilities held in the state transition matrix. If both matrices have the mentioned restrictions, a plain assembler program must not contain jprob and case instructions at all.

If both matrices do not have the mentioned restrictions, the best practice is to specify stt instructions for all states in a plain assembler program to know exactly where each state begins. To support this approach, the assembler generates a warning for every location where a state begins, but an stt instruction is missing there. Note that inserting stt instructions into a plain assembler program may require rearranging it.

There are three types of places where you can insert an stt instruction.

  1. Before a user or mixed-type instruction or a sequence of such instructions:
            stt     [state_name]
            user or mixed-type instruction 1
            user or mixed-type instruction 2
            ...
            user or mixed-type instruction N
    

    This instruction arrangement means that in a state marked by the stt instruction the instruction emitting engine emits a specified individual user or mixed-type instruction or a specified sequence of user or mixed-type instructions.

    As a result of assembling the instruction arrangement, the action emission matrix defines deterministic choice of the individual user or mixed-type instruction or the sequence of user or mixed-type instructions in the state. The action emission matrix contains profile probability 1 for the state and the individual instruction or instruction sequence and profile probability 0 for the state and all other individual instructions and instruction sequences.

    If you need to mark the beginning of a state, but there is no effective user or mixed-type instruction to insert beneath the stt instruction, you can insert the nop1 instruction there (see nop1 Instruction).

  2. Before a block of jprob instructions:
            stt     [state_name]
            jprob   prob1, L1
            jprob   prob2, L2
            ...
            jprob   probN, LN
            user or mixed-type instruction 0/1
            user or mixed-type instruction 0/2
            ...
            user or mixed-type instruction 0/M0
            ...
    
    L1:     user or mixed-type instruction 1/1
            user or mixed-type instruction 1/2
            ...
            user or mixed-type instruction 1/M1
            ...
    L2:     user or mixed-type instruction 2/1
            user or mixed-type instruction 2/2
            ...
            user or mixed-type instruction 2/M2
            ...
    LN:     user or mixed-type instruction N/1
            user or mixed-type instruction N/2
            ...
            user or mixed-type instruction N/MN
            ...
    

    This instruction arrangement means that in a state marked by the stt instruction the instruction emitting engine emits one of specified individual instructions or instruction sequences. The individual instructions must belong to different instruction classes, that is, have different combinations of an instruction name and instruction parameters. The instruction sequences must be different too.

    As a result of assembling the instruction arrangement, the action emission matrix contains profile probabilities of emitting all specified individual instructions and instruction sequences in the state and contains profile probability 0 for emitting all other individual instructions and instruction sequences in the state. However, in the general case, the profile probabilities of emitting specified individual instructions and instruction sequences will be different from profile probabilities indicated in the corresponding jprob instructions. For more information, see an example block of jprob instructions in jprob Instruction.

  3. Before a choice instruction block:
            stt     [state_name]
    
            choice
            case    prob1, L1
            case    prob2, L2
            ...
            case    probN, LN
            end     choice
    
            user or mixed-type instruction 0/1
            user or mixed-type instruction 0/2
            ...
            user or mixed-type instruction 0/M0
            ...
    
    L1:     user or mixed-type instruction 1/1
            user or mixed-type instruction 1/2
            ...
            user or mixed-type instruction 1/M1
            ...
    L2:     user or mixed-type instruction 2/1
            user or mixed-type instruction 2/2
            ...
            user or mixed-type instruction 2/M2
            ...
    LN:     user or mixed-type instruction N/1
            user or mixed-type instruction N/2
            ...
            user or mixed-type instruction N/MN
            ...
    

    This instruction arrangement means that in a state marked by the stt instruction the instruction emitting engine emits one of specified individual instructions or instruction sequences. The individual instructions must belong to different instruction classes, that is, have different combinations of an instruction name and instruction parameters. The instruction sequences must be different too.

    As a result of assembling the instruction arrangement, the action emission matrix contains profile probabilities of emitting all specified individual instructions and instruction sequences in the state and contains profile probability 0 for emitting all other individual instructions and instruction sequences in the state. The profile probabilities of emitting specified individual instructions and instruction sequences excluding the profile probability of emitting an individual instruction or instruction sequence beneath the choice instruction block are equal to profile probabilities indicated in the corresponding case instructions.

See Recommended Assembler Program Structure, for recommended program structure after individual user or mixed-type instructions and sequences of user or mixed-type instructions in the stt instruction arrangements listed above.