Learning a new language whether a human language or a computer language involves, at the outset, a large amount of new terminology. When we first introduced the SQUARES program (Figure 1-3), we left many details unexplained. Although we will now proceed somewhat more systematically, you still need to have some patience when we introduce several new concepts all at once and then return to discuss them individually at a later time. We can think of each line in an assembly language program as being a statement that may be imperative, declarative, or controlling:
Declarative statements, which usually have names beginning with a dot (.), are only directives to the assembler program; they do not generate machine instructions to be executed at runtime. Control statements may indirectly produce machine instructions (perhaps to save or restore register contents). 3.4.1 Statement FormatUnlike high-level languages, where the syntax for various statement types may differ sharply, assembly language uses the same general format for every line, with only a few elements in a standard order: label, predicate, operator, specifiers, comment. The style of assembly language statements differs from one architecture to another indeed sometimes from one programming environment to another. For example, the punctuation character to separate in-line comments varies, just as it does among high-level languages. For Itanium assembly language, the generic statement format is as follows: Label: (Predicate) Operator Specifier1, ... // Comment where
The label, predicate, and comment fields are syntactically optional. The number of specifiers depends on the statement type. With these few restrictions, the statement format is free form and not bound to specific columns (in contrast to COBOL). Spaces and tabs are generally interchangeable. We encourage keeping the fields neatly lined up for legibility. In this book we will introduce only some of the capabilities of assemblers available for the Itanium architecture. Additional details are given in the sources cited at the end of this and later chapters. 3.4.2 Symbolic AddressesLabels assign symbolic names to data locations like sq3 in SQUARES (Figure 1-3). The assembler and linker keep track of the numeric values corresponding to such symbolic names. We can also assign symbolic names to particular points in a program, such as the statement marked with the label done. Doing so defines logical flow and makes those names accessible during a debugging session. When symbolic names are referenced in other statements, such as branches or procedure calls, the assembler and linker keep track of the actual numeric addresses. We should perhaps emphasize that the labels that we assign to data locations represent the address of the storage location, not the value stored there. That is, the st8 instruction really means "store the specified quad word value into the specified quad word location in memory." 3.4.3 Classes of Assembly Language OperatorsOur sample program illustrates several of the particular items that can appear in the operator field of a line in an Itanium assembly language program. We organize these into various classes in Table 3-1, i.e., opcodes, pseudo-operations, and assembler directives. Names for opcodes like add are usually chosen as mnemonic references to the various fundamental instructions supported by an architecture. Assemblers also predefine certain pseudo-operation (pseudo-op) codes like mov which may resemble fundamental operations in other architectures, but which can be accomplished as special cases of certain Itanium machine instructions and thus need not be redundantly implemented at the hardware level. Directives to assemblers frequently have names that begin with a dot character. Some programming environments also provide system-defined macros whose names may conventionally begin with a dollar sign.
|