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


5.5 Inspecting an Assembler Program

Use the following function to get the number of instructions contained in an assembler program.

Function: int qsmm_get_prg_ninstr (qsmm_prg_t prg)

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

Use the following function to get an instruction contained in an assembler program.

Function: qsmm_instr_t qsmm_get_prg_instr (qsmm_prg_t prg, int instr_idx)

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

If instr_idx is negative or greater than or equal to the number of instructions in the program, the function returns NULL.

The following enumeration specifies the type of an assembler instruction.

Enumeration: qsmm_instr_e

This enumeration represents the type of an assembler instruction. The enumeration 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 (in a choice instruction block).

QSMM_INSTR_CHOICE

A choice 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).

Use the following function to get the type of an assembler instruction.

Function: enum qsmm_instr_e qsmm_get_instr_type (qsmm_instr_t instr)

This function returns the type of an instruction instr.

The function qsmm_get_prg_instr does not return instructions with the types QSMM_INSTR_CASE and QSMM_INSTR_END. Instead, it can return an instruction with the type QSMM_INSTR_CHOICE representing a choice instruction block containing nested case instructions and a nested end choice instruction. Use the following function to get the number of instructions nested in a choice instruction block.

Function: size_t qsmm_get_instr_nnested (qsmm_instr_t instr)

This function returns the number of instructions nested in an instruction instr with the type QSMM_INSTR_CHOICE. For instructions with other types, the function returns 0.

Use the following function to get a nested case or end choice instruction.

Function: qsmm_instr_t qsmm_get_instr_nested (qsmm_instr_t instr, size_t nested_idx)

This function returns an instruction nested in an instruction instr with the type QSMM_INSTR_CHOICE. The argument nested_idx specifies zero-based index of a nested instruction.

If the instruction instr does not have the type QSMM_INSTR_CHOICE, or nested_idx is greater than or equal to the number of instructions nested in the instruction instr, the function returns NULL.

An instruction can have location labels placed to the left of this instruction or before it. You can use a location label assigned to a choice instruction block to refer to an output probabilities array containing elements corresponding to case instructions in the block (see Output Arrays). Use the following function to get the number of location labels assigned to an instruction.

Function: size_t qsmm_get_instr_nlabel (qsmm_instr_t instr)

This function returns the number of location labels assigned to an instruction instr normally placed to the left of this instruction or before it.

Use the following function to get a location label by its index.

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

This function returns a location label at zero-based index label_idx assigned to an instruction instr. If label_idx is greater than or equal to the number of location labels assigned to the instruction, the function returns NULL.


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