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


5.5 Inspecting an Assembler Program

To get the number of instructions contained in an assembler program, the following function can be used.

Function: int qsmm_get_prg_ninstr (qsmm_prg_t prg)

This function returns the number of instructions contained in program prg. The returned value is always non-negative.

To get an instruction contained in an assembler program, the following function can be used.

Function: qsmm_instr_t qsmm_get_prg_instr (qsmm_prg_t prg, int instr_idx)

This function returns the handle of an instruction contained in program prg at zero-based index instr_idx.

If instr_idx is negative or is greater than or equal to the number of instructions in the program, then 0 will be returned.

A type of an assembler instruction is specified using the following enumeration.

Enumeration: qsmm_instr_e

This enumeration specifies a type of an assembler instruction. It contains the following elements.

QSMM_INSTR_USER

A user or mixed type instruction.

QSMM_INSTR_JMP

A jmp instruction.

QSMM_INSTR_JPROB

A jprob instruction.

QSMM_INSTR_CASE

A case instruction (within a choice instruction block).

QSMM_INSTR_CHOICE

A choice instruction.

QSMM_INSTR_CASELS

A casels instruction.

QSMM_INSTR_JOE

A joe instruction.

QSMM_INSTR_STT

An stt instruction.

QSMM_INSTR_END

An end choice instruction (at the end of a choice instruction block).

To get the type of an assembler instruction, the following function can be used.

Function: enum qsmm_instr_e qsmm_get_instr_type (qsmm_instr_t instr)

This function returns the type of instruction instr.

The function qsmm_get_prg_instr does not return instructions of types QSMM_INSTR_CASE and QSMM_INSTR_END. It can return an instruction of type QSMM_INSTR_CHOICE instead, which represents a choice instruction block that contains nested case and end choice instructions. To get the number of instructions, nested in a choice instruction block, the following function can be used.

Function: int qsmm_get_instr_nnested (qsmm_instr_t instr)

This function returns the number of instructions nested in instruction instr of type QSMM_INSTR_CHOICE. For instructions of other types, the function returns 0. The returned value is always non-negative.

To get the handle of a nested case or end choice instruction, the following function can be used.

Function: qsmm_instr_t qsmm_get_instr_nested (qsmm_instr_t instr, int nested_idx)

This function returns the handle of an instruction nested in instruction instr of type QSMM_INSTR_CHOICE. A zero-based index of nested instruction is specified by nested_idx.

If instruction instr is not of type QSMM_INSTR_CHOICE, or nested_idx is negative or is greater than or equal to the number of instructions nested in instruction instr, then 0 will be returned.

An instruction can have location labels assigned to it, which are normally placed to the left of the instruction. A location label assigned to a casels instruction can be used to fetch probabilities, which correspond to jump labels specified in arguments of that instruction. A location label assigned to a choice instruction block can be used to fetch probabilities that correspond to case instructions within the block. The fetched probabilities could be learned during the node training. To get the number of location labels assigned to an instruction, the following function can be used.

Function: int qsmm_get_instr_nlabel (qsmm_instr_t instr)

This function returns the number of location labels assigned to instruction instr, which are normally placed to the left of instruction. The returned value is always non-negative.

To get a location label by a location label index, the following function can be used.

Function: const char * qsmm_get_instr_label (qsmm_instr_t instr, int label_idx)

This function returns a location label at zero-based index label_idx assigned to instruction instr. That label is normally placed to the left of instruction. If label_idx is negative or is greater than or equal to the number of location labels assigned to the instruction, then 0 will be returned.

To get the name of a probabilities list associated with an instruction, a function described below can be used. See Using Probabilities Lists, for more information on probabilities lists.

Function: const char * qsmm_get_instr_ls_name (qsmm_instr_t instr)

This function returns the name of a probabilities list associated with instruction instr of type QSMM_INSTR_CASELS. If instruction instr has a type other than QSMM_INSTR_CASELS, then 0 will be returned.

The purpose of the function described below is to get the number of elements in a probabilities list defined in an assembler program. The retrieved number of elements can be used to allocate an array for fetching probabilities learned during the node training that correspond to jump labels specified in arguments of a casels instruction.

Function: int qsmm_get_prg_ls_nprob (qsmm_prg_t prg, const char *ls_name)

This function returns the number of elements in probabilities list ls_name defined in program prg.

On success, a positive value is returned. If program prg does not contain probabilities list ls_name, then negative error code QSMM_ERR_NOTFOUND will be returned.


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