[Return to Library] [Contents] [Previous Chapter] [Next Section] [Next Chapter] [Index] [Help]


1    Architecture-Based Considerations

This chapter describes programming considerations that are determined by the Alpha system architecture. It addresses the following topics:


[Return to Library] [Contents] [Previous Chapter] [Next Section] [Next Chapter] [Index] [Help]


1.1    Registers

This section discusses the registers that are available on Alpha systems and describes how memory organization affects them. Refer to Section 6.3 for information on register use and linkage.

Alpha systems have the following types of registers:

You must use integer registers where the assembly instructions expect integer registers and floating-point registers where the assembly instructions expect floating-point registers. If you confuse the two, the assembler issues an error message.

The assembler reserves all register names (see Section 6.3.1). All register names start with a dollar sign ($) and all alphabetic characters in register names are lowercase.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


1.1.1    Integer Registers

Alpha systems have 32 integer registers, each of which is 64 bits wide. Integer registers are sometimes referred to as general registers in other system architectures.

The integer registers have the names $0 to $31.

By including the file regdef.h (use #include <alpha/regdef.h>) in your assembly language program, you can use the software names of all of the integer registers, except for $28, $29, and $30. The operating system and the assembler use the integer registers $28, $29, and $30 for specific purposes.

Note

If you need to use the registers reserved for the operating system and the assembler, you must specify their alias names in your program, not their regular names. The alias names for $28, $29, and $30 are $at, $gp, and $sp, respectively. To prevent you from using these registers unknowingly and thereby producing potentially unexpected results, the assembler issues warning messages if you specify their regular names in your program.

The $gp register (integer register $29) is available as a general register on some non-Alpha compiler systems when the -G 0 compilation option is specified. It is not available as a general register on Alpha systems under any circumstances.

Integer register $31 always contains the value 0. All other integer registers can be used interchangeably, except for integer register $30, which is assumed to be the stack pointer by certain PALcode. See Table 6-1 for a description of integer register assignments. See Appendix D and the Alpha Architecture Handbook for information on PALcode (Privileged Architecture Library code).


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


1.1.2    Floating-Point Registers

Alpha systems have 32 floating-point registers, each of which is 64 bits wide. Each register can hold one single-precision (32-bit) value or one double-precision (64-bit) value.

The floating-point registers have the names $f0 to $f31.

Floating-point register $f31 always contains the value 0.0. All other floating-point registers can be used interchangeably. See Table 6-2 for a description of floating-point register assignments.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


1.2    Bit and Byte Ordering

A system's byte-ordering scheme, or endian scheme, affects memory organization and defines the relationship between address and byte position of data in memory:

Alpha systems use the little-endian scheme. Byte-ordering is as follows:

The bits of each byte are numbered from 7 to 0, using the format shown in Figure 1-1. (Bit numbering is a software convention; no assembler instructions depend on it.)

Figure 1-1: Byte Ordering


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


1.3    Addressing

This section describes the byte-addressing schemes for load and store instructions. (Section 2.8 describes the formats in which you can specify addresses.)


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


1.3.1    Aligned Data Operations

All Alpha systems use the following byte-addressing scheme for aligned data:

Any attempt to address a data item that does not have the proper alignment causes an alignment exception.

The following instructions load or store aligned data:


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


1.3.2    Unaligned Data Operations

The assembler's unaligned load and store instructions operate on arbitrary byte boundaries. They all generate multiple machine-code instructions. They do not raise alignment exceptions.

The following instructions load and store unaligned data:


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


1.4    Exceptions

The Alpha system detects some exceptions directly, and other exceptions are signaled as a result of specific tests that are inserted by the assembler.

The following sections describe exceptions that you may encounter during the execution of assembly programs. Only those exceptions that occur most frequently are described.


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Section] [Next Chapter] [Index] [Help]


1.4.1    Main Processor Exceptions

The following exceptions are the most common to the main processor:


[Return to Library] [Contents] [Previous Chapter] [Previous Section] [Next Chapter] [Index] [Help]


1.4.2    Floating-Point Processor Exceptions

The following exceptions are the most common floating-point exceptions:

For additional information on floating-point exceptions, see Section 4.1.3.