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


5.3.6 stt Instruction

This instruction has the following forms:

        stt
        stt     state_name

It marks the beginning of a state of an assembler program. The state biuniquely corresponds to a state of a node with that assembler program loaded. Both states can have a name specified by (quoted) string literal state_name. An assembler program must not contain states with duplicate names. See Loading a Parsed Program into a Node, for a description of functions that retrieve the name of a node state by its index and retrieve the index of a node state by its name.

The stt instruction designates the action emission matrix of a node for holding profile probabilities specified by certain other instructions in the assembler program. Without the stt instruction, those other instructions would specify profile probabilities held in the state transition matrix of the node.

An action emission matrix defined by the assembler program can have a restriction on profile probabilities it contains: the restriction to define only deterministic choices of assembler instructions for all node states. If the action emission matrix of a node has this restriction, all jprob, case, and casels instructions in the assembler program specify profile probabilities held only in the state transition matrix of the node. In this case, if there is no need to assign a name to a state, the stt instruction that marks the beginning of the state can be safely omitted.

If the action emission matrix of a node does not have the restriction that it must define deterministic choices of assembler instructions for all states of the node, then omitting stt instructions in the assembler program will cause the first unassembled instruction encountered while assembling to become the beginning of the next state taken as being defined by that assembler program. However, assembling a node may not always be possible by the processing of instructions of an assembler program consecutively from its beginning to the end. Therefore, in case of the absence of this restriction, to prevent unexpected places in an assembler program to become the beginnings of states, the best practice is to specify stt instructions for all states in the assembler program, so the programmer knows exactly where each state begins. To support this approach, the assembler can generate warnings for locations where it has to begin assembling states but encounters no stt instructions there. Note that inserting stt instructions into an assembler program may require rearranging the assembler program.

There are four possible places where you can insert the stt instruction.

  1. Before a user instruction or a mixed type instruction:
            stt     [state_name]
            user or mixed type instruction
    

    This instruction arrangement means that in a state marked by the stt instruction the state machine will invoke a specified user or mixed type instruction. The user or mixed type instruction must not have a location label assigned on condition that a jump from some place in the assembler program to this label exists.

    As a result of assembling the above instruction arrangement, the action emission matrix will define deterministic choice of that user or mixed type instruction in the state. This matrix will contain profile probability 1 for that state and that instruction and profile probability 0 for that state and all other user and mixed type instructions. If you need to mark the beginning of a state, but there is no effective user or a mixed type instruction to insert just after the stt instruction, then you may insert two instructions at the beginning of the state: stt and nop, or stt and nop1.

  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
            ...
    L1:     user or mixed type instruction 1
            ...
    L2:     user or mixed type instruction 2
            ...
    LN:     user or mixed type instruction N
            ...
    

    This instruction arrangement means that in a state marked by the stt instruction the state machine will invoke one of specified user or mixed type instructions. All those user and mixed type instructions must have different combinations of an instruction name and instruction parameters. None of jprob instructions just after the stt instruction must have location labels assigned with existing jumps from elsewhere in the assembler program to these labels.

    As a result of assembling the above instruction arrangement, the action emission matrix will contain the profile probability of invocation of every specified user or mixed type instruction in the state and will contain profile probability 0 for all other user and mixed type instructions and that state. However, in the general case, profile probabilities of invocation of specified user and mixed type instructions 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
            ...
    
    L1:     user or mixed type instruction 1
            ...
    L2:     user or mixed type instruction 2
            ...
    LN:     user or mixed type instruction N
            ...
    

    This instruction arrangement means that in a state marked by the stt instruction the state machine will invoke one of specified user or mixed type instructions. All those user and mixed type instructions must have different combinations of an instruction name and instruction parameters. The choice instruction after the stt instruction must not have a location label assigned on condition that a jump from some place in the assembler program to this label exists.

    As a result of assembling the above instruction arrangement, the action emission matrix will contain the profile probability of invocation of every specified user or mixed type instruction in the state and will contain profile probability 0 for all other user and mixed type instructions and that state. Profile probabilities of invocation of specified user and mixed type instructions, excluding the profile probability of invocation of a user or mixed type instruction just after the choice instruction block, will be equal to profile probabilities indicated in the corresponding case instructions.

  4. Before a casels instruction:
            stt     [state_name]
            casels  list_name, L1, L2, ..., LN
            user or mixed type instruction 0
            ...
    
    L1:     user or mixed type instruction 1
            ...
    L2:     user or mixed type instruction 2
            ...
    LN:     user or mixed type instruction N
            ...
    

    This instruction arrangement means that in a state marked by the stt instruction the state machine will invoke one of specified user or mixed type instructions. All those user and mixed type instructions must have different combinations of an instruction name and instruction parameters. A casels instruction after the stt instruction must not have a location label assigned on condition that a jump from some place in the assembler program to this label exists.

    As a result of assembling the above instruction arrangement, the action emission matrix will contain the profile probability of invocation of every specified user or mixed type instruction in the state and will contain profile probability 0 for all other user and mixed type instructions and that state. Profile probabilities of invocation of specified user and mixed type instructions, excluding the profile probability of invocation of a user or mixed type instruction just after the casels instruction, will be equal to corresponding profile probabilities contained in probabilities list list_name.

In the above four instruction arrangement schemes, adhere to the following assembler program structure after every line with a user or mixed type instruction:

  1. Locations of joe instruction blocks. Every user or a mixed type instruction can be followed by a contiguous block of joe instructions. Those joe instructions analyze the outcome of that user or mixed type instruction.
  2. Jump targets of joe instructions. Every joe instruction should specify a (conditional) jump to a contiguous block of jprob instructions or to a choice instruction block or to a casels instruction or to the beginning of another state.
  3. Instructions after a joe instruction block. Every contiguous block of joe instructions should be followed by a contiguous block of jprob instructions or by a choice instruction block or by a casels instruction or by a jmp instruction that transfers control to another state or by the beginning of another state directly.
  4. Specifying state transition probabilities. If a contiguous block of jprob instructions or a block of case instructions (taken together with the enclosing choice and end choice instructions) or a casels instruction is the jump target of a joe instruction or follows a contiguous block of joe instructions, then those jprob or case instructions or the casels instruction specify probabilities of transitions to other states stored in the state transition matrix.
  5. What follows blocks specifying state transition probabilities. Every contiguous block of jprob instructions or a choice instruction block or a casels instruction, if they specify state transition probabilities, shall be followed by a jmp instruction that transfers control to another state or shall be followed by the beginning of another state directly.

The following example illustrates the described assembler program structure.

        user or mixed type instruction X

        ; A contiguous block of `joe' instructions. They analyze the
        ; outcome of user or mixed type instruction X.
        ;
        ; Each of labels L1, L2, ..., LN should point at:
        ; - the beginning of a contiguous block of `jprob' instructions;
        ; - the beginning of a `choice' instruction block;
        ; - a `casels' instruction;
        ; - the beginning of a state.

        joe     outcome1, L1
        joe     outcome2, L2
        ...
        joe     outcomeN, LN
        joe     outcomeN1, LN1          ; The conditional jump to a sample
                                        ; `casels' instruction.

        joe     outcomeN2, LN2          ; The conditional jump to a sample
                                        ; `choice' instruction block.

        joe     outcomeN3, LN3          ; The conditional jump to a sample
                                        ; contiguous block of `jprob'
                                        ; instructions.

        ; An optional contiguous block of `jprob' instructions (may also be
        ; a `choice' instruction block or a `casels' instruction). They
        ; specify probabilities of transitions to states for the source
        ; state, for user or mixed type instruction X invoked in that
        ; source state, and for any outcome of user or mixed type
        ; instruction X other than outcome1, outcome2, ..., outcomeN,
        ; outcomeN1, outcomeN2, outcomeN3.
        ;
        ; Labels SA1, SA2, ..., SAN, SANN should point at the beginnings
        ; of states.

        jprob   probA1, SA1
        jprob   probA2, SA2
        ...
        jprob   probAN, SAN
        jmp     SANN

        ; A sample `casels' instruction. It specifies probabilities of
        ; transitions to states for the source state, for user or mixed
        ; type instruction X invoked in that source state, and for outcome
        ; outcomeN1 of user or mixed type instruction X.
        ;
        ; The "data" section of the assembler program should contain the
        ; definition of probabilities list list_name holding
        ; N probabilities.
        ;
        ; Labels SB1, SB2, ..., SBN, SBNN should point at the beginnings
        ; of states.

LN1:    casels  list_name, SB1, SB2, ..., SBN
        jmp     SBNN

        ; A sample `choice' instruction block. It specifies probabilities
        ; of transitions to states for the source state, for user or mixed
        ; type instruction X invoked in that source state, and for outcome
        ; outcomeN2 of user or mixed type instruction X.
        ;
        ; Labels SC1, SC2, ..., SCN, SCNN should point at the beginnings
        ; of states.

LN2:    choice
        case    probC1, SC1
        case    probC2, SC2
        ...
        case    probCN, SCN
        end     choice

        jmp     SCNN

        ; A sample contiguous block of `jprob' instructions. They specify
        ; probabilities of transitions to states for the source state, for
        ; user or mixed type instruction X invoked in that source state,
        ; and for outcome outcomeN3 of user or mixed type instruction X.
        ;
        ; Labels SD1, SD2, ..., SDN, SDNN should point at the beginnings
        ; of states.

LN3:    jprob   probD1, SD1
        jprob   probD2, SD2
        ...
        jprob   probDN, SDN
        jmp     SDNN                    ; This instruction is not needed
                                        ; if it specifies the jump to a
                                        ; state that goes just after
                                        ; this line.

        ; The beginning of another state.

After a user instruction or a mixed type instruction there can be no joe instructions at all. In this case, such instruction should be immediately followed by a contiguous block of jprob instructions or by a choice instruction block or by a casels instruction or by a jmp instruction that transfers control to another state or should be followed by another state directly. The following example illustrates this instruction arrangement.

        user or mixed type instruction Y

        ; An optional contiguous block of `jprob' instructions (may also
        ; be a `choice' instruction block or a `casels' instruction). They
        ; specify probabilities of transitions to states for the source
        ; state, for user or mixed type instruction Y invoked in that
        ; source state, and for any possible outcome of user or mixed type
        ; instruction Y.
        ;
        ; Labels S1, S2, ..., SN, SNN should point at the beginnings
        ; of states.

        jprob   prob1, S1
        jprob   prob2, S2
        ...
        jprob   probN, SN
        jmp     SNN                     ; This instruction is not needed
                                        ; if it specifies the jump to a
                                        ; state that goes just after
                                        ; this line.

        ; The beginning of another state.

Adherence to the described assembler program structure will simplify understanding how the assembler converts your assembler program to a probability profile stored in the state transition matrix and the action emission matrix of a node. This understanding may be necessary to develop an assembler program for the state machine capable of efficient training.


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