2

Program Structure

An assembly language program is a sequence of statements. There are three classes of statements:

Instructions

Pseudo-operations

Directives

Instructions represent a single machine instruction in symbolic form. Pseudo-operations cause the Assembler to initialize or reserve one or more words of storage for data, rather than machine instructions.

Directives communicate information about the program to the Assembler, but do not generally cause the Assembler to output any machine instructions.

An assembly statement contains four fields:

Label

Opcode

Operands

Comments

Each of these fields is optional. However the operands field cannot appear without an opcode field.The label field is used to associate a symbolic address with an instruction or data location, or to define a symbolic constant using the .EQU, .REG, or .MACRO directives. This field is optional for all but a few statement types; if present, the label must begin in column one of a source program line. If a label appears on a line by itself, or with a comment only, the label is associated with the next address within the same subspace and location counter.

When the label field begins with the pound sign (#) character, it is not treated as a label. If # is followed by white space and an integer, the Assembler's line number counter, used when reporting errors, is reset to the value of the integer. Otherwise, the line beginning with # is ignored. This feature is for the use of the C language preprocessor cpp.

The opcode field contains either a mnemonic machine instruction, a pseudo-operation code, or the name of an Assembler directive. It must be separated from the label field by a blank or tab. For certain machine instructions, the opcode field can also contain completers, separated from the instruction mnemonic by commas.

19

Page 19
Image 19
HP UX Developer Tools manual Program Structure