5.4 Inspecting an Assembler Program

An assembler program can have a name. If an assembler program is a procedure in a compound assembler program, the assembler program and the procedure have the same name.

Use the following function to get the name of an assembler program.

Function: const char * qsmm_get_prg_name (qsmm_prg_t prg)

This function returns the name of a program prg. That name is the name of an assembler procedure contained in a compound assembler program. If prg does not represent a plain assembler program contained in a compound assembler program, the function returns NULL.

The function qsmm_prg_add_nested adds a plain assembler program to a compound assembler program as an assembler procedure. Use the following function to get the number of procedures contained in a compound assembler program.

Function: size_t qsmm_get_prg_nnested (qsmm_prg_t prg)

This function returns the number of plain assembler programs contained in a program prg (as procedures). If prg is not a compound assembler program, the function returns 0.

Use the following function to fetch a plain assembler program from a compound assembler program. The function qsmm_get_prg_name described earlier in this section returns the name of a procedure for the plain assembler program.

Function: qsmm_prg_t qsmm_get_prg_nested (qsmm_prg_t prg, size_t nested_idx)

This function returns a procedure contained in a program prg at zero-based index nested_idx. If prg is not a compound assembler program, or nested_idx is greater than or equal to the number of procedures in prg, the function returns NULL.

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

Function: size_t qsmm_get_prg_ninstr (qsmm_prg_t prg)

This function returns the number of instructions contained in a program prg. If prg is not a plain assembler program, the function returns 0.

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, size_t instr_idx)

This function returns an instruction contained in a program prg at zero-based index instr_idx. If prg is not a plain assembler program, or instr_idx is greater than or equal to the number of instructions in prg, 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_PROB

A prob 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 of QSMM_INSTR_CHOICE type. For instructions of 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 the instruction or before it. 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.

Use the following function to get a data label or location label.

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

This function returns a data label or location label assigned to an instruction instr. If label_idx is (size_t) -1, the function returns a data label. If label_idx is not (size_t) -1, the function returns a location label at zero-based index label_idx. If the instruction does not have the data label or location label, the function returns NULL.