Asm Lan
Asm Lan
© 2000 - 2002
Page 2
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Disclaimer
Information in this document is provided in connection with Intel products. No license, express or
implied, by estoppel or otherwise, to any intellectual property rights is granted by this document.
Except as provided in Intel's Terms and Conditions of Sale for such products, Intel assumes no
liability whatsoever, and Intel disclaims any express or implied warranty, relating to sale and/or
use of Intel products including liability or warranties relating to fitness for a particular purpose,
merchantability, or infringement of any patent, copyright or other intellectual property right. Intel
products are not intended for use in medical, life saving, or life sustaining applications.
This Intel® Itanium® Architecture Assembly Language Reference Guide as well as the software
described in it is furnished under license and may only be used or copied in accordance with the
terms of the license. The information in this manual is furnished for informational use only, is
subject to change without notice, and should not be construed as a commitment by Intel
Corporation. Intel Corporation assumes no responsibility or liability for any errors or inaccuracies
that may appear in this document or any software that may be provided in association with this
document.
Except as permitted by such license, no part of this document may be reproduced, stored in a
retrieval system, or transmitted in any form or by any means without the express written consent
of Intel Corporation.
Designers must not rely on the absence or characteristics of any features or instructions marked
"reserved" or "undefined." Intel reserves these for future definition and shall have no
responsibility whatsoever for conflicts or incompatibilities arising from future changes to them.
Celeron, Dialogic, i386, i486, iCOMP, Intel, Intel logo, Intel386, Intel486, Intel740, IntelDX2,
IntelDX4, IntelSX2, Intel Inside, Intel Inside logo, Intel NetBurst, Intel NetStructure, Intel Xeon,
Intel XScale, Itanium, MMX, MMX logo, Pentium, Pentium II Xeon, Pentium III Xeon, and VTune
are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United
States and other countries.
Page 3
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Overview
This document describes the programming conventions used to write an assembly program for
the Itanium® architecture.
As prerequisites, you should be familiar with the Itanium architecture, and have assembly
language programming experience.
Page 4
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
z Program Elements Overview describes the basic elements and language specifications of
an assembly-language program for the Itanium® architecture.
z Data Allocation describes the statements used to allocate initialized and unitialized space
for data objects, and align data objects in the program.
z Pseudo-ops lists the Itanium architecture pseudo operations and their equivalent machine
instructions, and pseudo-ops with missing operands.
z Link-relocation Operators lists the link-relocation operators and describes their functionality.
z List of Assembly Language Directives lists the assembly language directives according to
category.
z Glossary
Page 5
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Related Documentation
The following documents, available at http://developer.intel.com, provide additional information:
Page 6
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Notation Conventions
This notation is used in syntax descriptions:
This type style Indicates an element of syntax, a reserved word, keyword, a filename,
computer output, or part of a program example. The text appears in
lowercase, unless uppercase is significant.
This type style Indicates the text you enter as input.
This type style Indicates a placeholder for an identifier, an expression, a string, a
symbol or a value. Substitute one of these items for the placeholder.
[items] Indicates optional items.
[items | item] Indicates the possible choices. A vertical bar (|) separates the items.
Choose one of the items enclosed in brackets.
Page 7
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
z identifiers
z symbols
z name spaces
z constants
z expressions
z statements.
Page 8
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Identifiers
In Itanium® architecture assembly language, objects such as machine instructions, registers,
memory locations, sections in the object file, and constants, have symbolic names. In the source
code these names are represented syntactically by identifiers.
An identifier may contain letters, digits, and a few special characters. Identifiers may not begin
with a digit.
The following table summarizes the rules for character usage in identifiers.
The assembler may place a limit on the length of an identifier, but this limit must be no less than
256 characters.
Page 9
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Name Spaces
There are three classes of names in the Itanium® architecture assembly language:
z Symbols, which refer to memory locations, sections, and symbolic constants. These names
are case sensitive.
z Registers, which refer to registers defined in the Itanium architecture. These names are not
case sensitive. Some register names consist of multiple syntactic elements rather than a
single identifier.
The assembler places names in three separate name spaces, according to their class. A name
may not be defined twice in the same namespace, but it may be defined once in each
namespace. When a name is defined in both the register and symbol namespaces, the register
name takes precedence over the symbol unless the identifier is “protected” by terminating it with
the # operator; this forces the assembler to look up the identifier in the symbol namespace.
The # operator in conjunction with a symbol is legal only when the symbol is an operand.
The # operator is unnecessary and illegal when included in the symbol definition, as shown:
r5#: //illegal
Page 10
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Symbols
A symbol refers to a location in memory, an object file section, a numeric constant, or a register.
A symbol has the following attributes:
z name
z type
z value
The special symbols dollar sign ($) and period (.) when used in expressions, always refer to the
current location counter. The current location counter points to the address of a bundle
containing the current instruction, or to the address of the first data object defined by the current
assembly statement. There is no difference between these symbols, either can be used.
In the following example, the movl instruction moves the address of the bundle containing the
current instruction ($) into register r1:
movl r1=$
In the following data allocation statement, the period (.) is the address of the first data object
defined by the assembly statement:
data4 2, 3, .
Page 11
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Symbol Names
Symbol names are case-sensitive identifiers. Symbols whose names begin with a period (.) are
temporary. Temporary symbols are not placed in the object file symbol table. Symbols whose
names begin with two periods (..) are temporary, and local. Local symbols are scope restricted
symbols. Local symbols are recognized only within the scope in which they are defined. See the
Symbol Scope Declaration section for more information about local symbol scopes.
The following table summarizes the rules for using temporary and scope-restricted indicators in
different types of symbol names.
Symbols whose names begin with an "at" sign (@) are reserved as predefined constants. The
assembler provides predefined symbolic constants for special operand values for several
instructions, for example, fclass and mux instructions. The following tables list the predefined
symbolic constant names for the operands of these instructions. These symbolic constants can
be used in expressions as any user-defined symbolic constant.
Page 12
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Alternate @alt
Broadcast @brcst
Page 13
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Symbol Types
A symbol’s type indicates the class of object to which it refers. A symbol type can be any of the
following:
Page 14
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Symbol Values
A symbol is defined when it is assigned a value. A symbol value can also be a number or
expression assigned to a symbolic constant. The value of a symbol identifies the object to which
it refers. If the symbol refers to a location in memory, the assigned value is the address of that
memory location. In most cases, this address is resolved only in link time.
Page 15
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Register Names
All registers have predefined names, which are listed in Appendix A. Predefined register names
are not case-sensitive. You can assign new register names to some of the predefined registers
with a register assignment statement, or a rotating register directive. See the Assignment
Statements, Equate Statements, and Rotating Register Directives sections, for more details.
Registers that use the value of a specified general-purpose register as an index into the register
file consist of the register file name followed by the name of a general register enclosed in
brackets, such as pmc[r].
The assembler determines the register type according to the form of its name, as shown in the
following table. Some registers appear in name and number form. For example, ar.bsp is the
name form of an application register, which also has a number form, ar17.
in0 - in95
loc0 - loc95
out0 - out95
f0 - f127
Floating-point registers
p0 - p63
Predicate registers (1-bit)
b0 - b7
Branch registers
ar0 - ar127
Application registers
cr0 - cr127
Control registers
Name form e.g. ar.bsp Named application registers
ip Instruction pointer
psr.um
Indirect file registers e.g. pmc[r2] Register file with general-purpose
register as index.
Page 16
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 17
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Mnemonics
Mnemonics are predefined assembly-language names for machine instructions, pseudo-ops,
directives, and data allocation statements. Mnemonics are not case-sensitive.
In this manual, completers are italicized to distinguish them from the instruction mnemonic
suffixes. For example, in the instruction brp.ret.sptk.imp b0,L, the optional completers
appear in italics to set them apart from the .ret suffix. For a full description of the instructions,
see the Intel® Itanium® Architecture Software Developer’s Manual.
Pseudo-op Mnemonics
Pseudo-op mnemonics represent assembler instructions that alias machine instructions. They
are equivalent to instruction mnemonics and are provided for the convenience of the
programmer. See Pseudo-ops section for a list of the assembler pseudo-ops.
mov r5=2
The assembler translates this pseudo-op into the equivalent machine instruction:
add1 r5=2,r0
For more details about the pseudo-ops, see the Intel® Itanium® Architecture Software
Developer’s Manual.
Directive Mnemonics
Directives are assembler instructions to the assembler during the assembly process; they do not
produce executable code. To distinguish them from other instructions, directive mnemonics begin
with a period (.).
The following sections, Program Structure through Annotations, describe the assembler
directives and explain how to use them.
Page 18
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Data allocation mnenonics specify the types of data objects assembled in data allocation
statements. See Data Allocation for a list of these mnemonics. Data allocation statements are
used to allocate initialized memory areas.
Page 19
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Constants
Constants can be numeric or string.
Page 20
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Numeric Constants
A numeric constant contains integer and floating-point numbers. The assembler supports C and
Microsoft Macro Assembly language (MASM) numeric constants. C numeric constants are the
default.
Page 21
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
C Numeric Constants
C numeric constants can be any of the following:
z Decimal integer constants (base 10) consist of one or more digits, 0 through 9, where 0
cannot be used as the first digit.
z Binary constants (base 2) begin with a 0b or 0B prefix, followed by one or more binary
digits (0, 1).
z Octal constants (base 8) consist of one or more digits 0 through 7, where the first digit is
0.
— an optional sign - or +
— a period .
For example, the following floating-point constant contains both the optional and required parts:
+1.15e-12.
The following floating-point constant contains only the required parts: 1.0
The following formal grammar summarizes the rules for the C numeric constants:
C-constant:
C-integer-constant
floating-point-constant
character-constant
C-integer-constant:
[1-9][0-9]*
0[bB][01]*
0[0-7]*
0[xX][0-9a-fA-F]*
Page 22
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
floating-point-constant:
integer-part.[ fractional-part ] [ exponent-part ]
integer-part:
[0-9]*
fractional-part:
[0-9]*
exponent-part:
[eE][+-][0-9]*
[eE][0-9]*
Page 23
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
z Radix constants are numeric constants that also specify the radix of the value. They
consist of one or more digits, 0 through 9, followed by a radix indicator. The radix indicators
of MASM numeric constants define them as decimal (D), hexadecimal (H), octal (O), or
binary (B). If the current radix is hexadecimal, the letters B and D are interpreted as digits.
In this case, T specifies a decimal radix, and Y specifies a binary radix. See MASM Radix
Indicators table below.
See the Radix Indicator Directive section for more information about how to specify a radix.
z Integer constants in the current radix consist of one or more digits, 0 through 9, A through
F. If the current radix is not hexadecimal, the characters A through F are not applicable.
z Floating-point constants have the same syntax as in C. See the C Numeric Constants
section.
The following formal grammar summarizes the rules for the MASM numeric constants:
MASM-constant:
MASM-integer-constant
MASM-radix-constant
floating-point-constant
character-constant
MASM-integer-constant:
[0-9][0-9a-fA-F]*
MASM-radix-constant
[0-9][0-9a-fA-F]*[tTdDhHOoqQbByY]
floating-point-constant: (as in C)
Page 24
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 25
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Characters can represent numeric constants. For instance, a single ASCII character can
represent a numeric constant by enclosing it in single quotes (’’). The numeric constant is the
ASCII value of the specified characterise use other special characters to represent numeric
constants, use the character escapes defined in the ANSI C language, and enclose them in
single quotes. Table below lists the common character escapes. To use the single quote ( ’ ) to
represent a numeric constant, insert a backslash (\) before it, and enclose both in single quotes
(’’), as such,’\’.
Page 26
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
String Constants
String constants consist of a sequence of characters enclosed in double quotes ("").
To specify double-quotes (") in a string constant, insert a backslash (\) before it, as such, "\".
To include other special characters in a string constant, use the character escapes defined in the
ANSI C language. See table Common Character Escapes for a list of common character
escapes.
Page 27
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Expressions
An expression is a combination of symbols, numeric constants, and operators that uses standard
arithmetic notation to yield a result. Expressions can be absolute or relocatable.
Absolute Expressions
An expression is absolute when it is not subject to link-time relocation. An absolute expression
may contain relocatable symbols, but they must reduce to pairs of the form (R1 - R2 ), where R1
and R2 are relocatable symbols defined in the same section in the current source file.
Relocatable Expressions
An expression is relocatable when it is subject to link-time relocation. A relocatable expression
contains a relocatable symbol, and may contain an absolute expression. If a relocatable
expression contains an absolute expression, it must be reducible to the form (R+K), where R is
either a relocatable symbol defined in the current source file, or an undefined symbol, and K is an
absolute expression. The address of the relocatable symbol is defined in link time.
Operators
The assembler evaluates all operators according to their level of precedence. Table below lists
the operator precedence rules from lowest to highest.
- Subtraction
| Bitwise inclusive OR
^ Bitwise exclusive OR
1 (Medium) * Multiplication
/ Division
% Remainder
Page 28
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
& Bitwise A ND
2 (High) - Unary negation
Link-relocation Operators
Page 29
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Statements
An assembly-language program consists of a series of statements separated by a semicolon (;).
Multiple statements may be on the same line.
To separate lines, use the standard line termination convention on the local host system, typically
CR (carriage return) and LF (line feed). To separate elements within a statement, use the CR,
LF, FF (form feed), VT (vertical tab), Space, or Tab that represent white space.
To separate a comment from the code at the end of a statement, insert the comment before the
semi colon (;) and precede it with a double-backslash (//). The assembler ignores comments.
The assembler may place a limit on the length of an input line, but this limit must be no less than
256 characters.
z label statements
z instruction statements
z directive statements
z assignment statements
z equate statements
The topics that follow detail each of the statement types, their components and syntax, and
provide an example of each.
Page 30
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Label Statements
A label statement has the following syntax:
[label]: // comments
Where:
foo::
Page 31
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Instruction Statements
An instruction statement has the following syntax:
Where:
(qp):
Page 32
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 33
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Directive Statements
A directive statement has the following syntax:
Where:
.directive Represents the directive mnemonic. Directives always begin with a period
(.). Directive mnemonics are not case-sensitive.
operands The operands are optional and determined by the directive. Where multiple
operands are present in directives, separate them with commas.
.proc foo
Page 34
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Assignment Statements
Assignment statements enable the programmer to define or redefine a symbol by assigning it a
value. This value may be a reference to another symbol, register name, or expression. The new
value takes effect immediately and remains in effect until the symbol is redefined. Symbols
defined in assignment statements do not have forward references.
z be declared global.
z Symbol assignment statements, which define or redefine a symbol in the symbol name
space.
z Register assignment statements, which define or redefine a register name in the symbol
name space.
identifier=expression // comments
Where:
C = L0+2
Where:
Page 35
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
register name Specifies an alternate register name. If the register name is a stack or
rotating register name, the new register name continues to reference the
previously-defined register name, even if the name is no longer in effect.
See the Register Stack Directive and Rotating Register Directives
sections.
A = r1
Page 36
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Equate Statements
Equate statements enable the programmer to define a symbol by assigning it a value. This value
may be a reference to another symbol, register name, or expression. In equate statements, a
symbol can be defined only once throughout the source file. These symbols may have forward
references, except when referencing a register name. A symbol name defined in an equate
statement cannot be defined in an assignment statement.
Equate statements have the same syntax as assignment statements, except for the operator.
identifier==expression // comments
Where:
A == 5
Where:
Page 37
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
A == r1
Page 38
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Where:
label Defines a symbol whose value is the address of the first data object defined by
the statement. If the assembler inserts padding to align the location counter to
an implied alignment boundary, the label is assigned the value of the newly-
aligned address.
Page 39
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Where:
xdataop Defines the type and size of data objects that are assembled. Cross-
section data object mnemonics are not case-sensitive.
section-name Refers to a predefined name of an existing section in the object file.
operands Contain multiple expressions that are separated by commas. Each
expression defines a separate data object of the same type and size.
The assembler puts the data objects into consecutive locations in
memory, and automatically aligns each to its natural boundary.
Page 40
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Program Structure
This section describes the Itanium® architecture assembly language directives associated with
symbol declarations. These directives can be used to perform the following functions:
Page 41
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Sections
The output object file of an assembly program is made up of named sections that contain code
and data. The assembler allows any number of sections to be created in parallel within the output
object file, one of which can be accessed at a time. The section currently accessed is referred to
as the current section.
The assembler maintains a separate location counter for each existing section. The assembler
always adds new code or data to the end of the current section, moving the location counter in
that section ahead to incorporate the new code or data. The Cross-section Data Allocation
Statements section explains how to add data to a section that is not the current section.
Section directives and predefined section directives are used to define and switch between
sections. Some section directives have flag and type operands that specify the flag and type
attributes of a section.
Page 42
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
The type operand specifies a section’s type attribute. The type operand is a string constant
containing one of the valid section types listed in Table Section Types. The section types listed in
the table correspond directly to ELF (UNIX*) section types, except for the "comdat" section type,
which corresponds to COFF32 (Windows NT). The type operand is case-sensitive.
Section Types
Section Type Description
"progbits" Sections with initialized data or code.
"nobits" Sections with uninitialized data (bss).
"comdat" COMDAT sections, Windows NT
Page 43
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
The associated section operand is a section name. A section name can only be loaded in link
time if the associated section is already loaded.
To select the A flag, use the .section or .pushsection directive with an additional assoc-
section operand in one of the following formats:
[,assoc-section]]
Where:
Page 44
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 45
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.section section-name
.section section-name,"flags","type"
Where:
In the first format, the .section directive sets the section-name as the current section. In the
second format, the .section directive defines a new section, assigns flags and type attributes,
and makes the newly-defined section the current section. If the newly-defined section has the
same name, flag attributes, and type attribute as a previously-defined existing section, the
assembler switches to the previously-defined section without defining a new one. For example,
the following .section directive defines a new section (my_section), assigns flags ("aw")
and type ("progbits") attributes, and makes it the current section.
In the third format, the .section directive creates a new section with a previously-defined section
name, and assigns it new flags and type attributes. The newly-created section becomes the
current section; any reference to this section name refers to the newly-created section. The
Using Section Directives section illustrates how to use the .section directive.
Page 46
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 47
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Absolute Sections
Absolute sections are only supported by ELF object file formats. To define an absolute section
with a fixed starting address, use the .section and .pushssection directives with an
optional origin operand. The origin operand must be an absolute expression. Absolute
section addresses cannot overlap. The linker does not merge absolute sections with other
section types, or with other absolute sections.
The following example defines a new section name and assigns it new flags and type
attributes, with a starting address specified by the origin parameter.
Page 48
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.pushsection section-name
.pushsection section-name,"flags","type"
Where:
The Using Section Directives section illustrates how to use the .pushsection
and .popsection directives.
Page 49
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
The predefined section directive mnemonics are the same as the section names. The assembler
generates section names in lower case, even though directive mnemonics are not case-sensitive.
On some platforms the assembler automatically creates a local symbol with a "section" type
attribute for each defined section in the object file. See the Symbol Type Directive section for
more information about symbol types.
The linker combines sections with the same name, flags and type attributes. The linker
creates two separate output sections for sections with the same name, but different flags and
type attributes.
To define a section without the default flags and type attributes, use the .section directive.
The predefined section directives cannot define a new section using the same name as a
previously-defined section.
Table Predefined Section Directives below lists the predefined section directives, and their
default flags and type attributes. A predefined section directive can have the same name as a
section name.
Page 50
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Where
Page 51
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.text //Default
.section A //Makes A the current section.
//.text is A’s previous section.
.pushsection B //Pushes A onto the stack and makes B the
//current section. A is B’s previous section.
.pushsection C //Pushes B onto stack and makes C the current
//section, B is C’s previous section.
.popsection //Pops B from stack and makes it current.
.popsection //Pops A from stack and makes it current.
//.text is A’s previous section.
.previous //Makes A’s previously current section .text the
//current section. A becomes .text’s previous
//section.
.previous //Makes A the current section, .text becomes A’s
//previous section.
Page 52
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
To include the contents of another file in the current source file, use the .include directive in
the following format:
.include "filename"
Where:
Page 53
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Bundles
Itanium® architecture instructions are grouped together in 128-bit aligned containers called
bundles. Each bundle contains three 41-bit instruction
slots, and a 5-bit template field. The template field specifies which type of execution unit
processes each instruction in the bundle. Bit 0 is set to 1 if
there is a stop at the end of a bundle. There is no fixed relation between the boundaries of an
instruction group and the boundaries of a bundle.
Bundle Format
Multiway branch bundles contain more than one branch instruction. When the first branch
instruction of a multiway bundle is taken, the subsequent branch instruction does not execute.
Bundles are always aligned at 16-byte boundaries. The assembler automatically aligns sections
containing bundles to at least 16-bytes.
Refer to the Intel® Itanium® Architecture Software Developer’s Manual for more details about
bundles.
Page 54
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Implicit Bundling
The assembler bundles instructions automatically by default.
Page 55
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Explicit Bundling
The programmer can explicitly assemble bundles by grouping together up to three instructions,
and enclosing them in braces ({}). The assembler places these instructions in one bundle,
separate from all preceding and subsequent instructions. Stops at the end of an explicit bundle
can be placed before or after the closing brace.
Section directives and data allocation statements cannot be used within an explicit bundle.
Cross-section data allocation statements can be used within an explicit bundle. See the Cross-
section Data Allocation Statements section for more information.
In explicit-bundling mode, labels can be inserted only as the first statement of an explicit bundle.
Instruction tags can be applied to any instruction.
When using explicit-bundling, the appropriate template can be selected in one of the following
ways:
Auto-template Selection
By default, the assembler searches and selects a matching template for a bundle. The template
fields specify intra-bundle instruction stops. When two templates consist of the same sequence of
instruction types, they are distinguished by stops. The assembler selects the appropriate
template field based on the stops within the bundle. If no template is found, the assembler
produces a diagnostic message. Instruction group stops may occur in a bundle.
Page 56
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Refer to the Intel® Itanium® Architecture Software Developer’s Manual for more information
about template field encoding and instruction slot mapping.
Note:
Select the .mlx directive for the move long immediate instruction and for the long branch
instruction. These instructions operate on 64-bit data types and are too large to fit into one
of the 41-bit bundle slots. This directive selects the mlx template and inserts the instruction
in slot 1 and slot 2 of the bundle.
Example below is the code that shows an explicit bundle using explicit template selection, and a
stop.
Page 57
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Instruction Groups
Itanium® architecture instructions are organized in instruction groups. Each instruction group
contains one or more statically contiguous instruction(s) that can execute in parallel. An
instruction group must contain at least one instruction; there is no upper limit on the number of
instructions in an instruction group.
An instruction group is terminated statically by a stop, and dynamically by taken branches. Stops
are represented by a double semi-colon (;;). The programmer can explicitly define stops. Stops
immediately follow an instruction, or appear on a separate line. They can be inserted between
two instructions on the same line.
Refer to the Intel® Itanium® Architecture Software Developer’s Manual for more detailed
information about instruction groups.
Page 58
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
The assembler reads and processes assembly code in one of two modes: explicit and automatic.
Use explicit mode if you are an expert user with profound knowledge of Itanium® architecture or
performance is important. In explicit mode, you are responsible for bundling and stops (;;), and
the assembler generates errors where it finds dependency violations.
Use automatic mode if you are a novice user or performance is not the highest consideration. In
automatic mode, the assembler bundles the code and adds stops to avoid dependency
violations. It ignores existing stops and annotations.
You can mix code from both modes in the one file. Set the mode using the command-line option
or the directives .auto and .explicit. The directive .default causes the assembler to
revert to the mode of operation defined in the command line.
For a complete description of the rules of data dependencies, see the Intel® Itanium®
Architecture Software Developer’s Manual.
Page 59
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Procedures
Software conventions require that instructions belong to a declared procedure, and that
procedure prologues be separated from the main body within the procedure. These conventions
ensure that the proper stack unwind information is placed in the object file. Refer to the Software
Conventions and Runtime Architecture Guide for details about the software conventions.
Page 60
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Procedure Directives
The .proc and .endp directives combine code belonging to the same procedure. The .proc
directive marks the beginning of a procedure, and the .endp directive marks the end of a
procedure. A single procedure may consist of several disjointed blocks of code. Each block
should be individually bracketed with these directives. Name operands within a procedure can be
used only for that specific procedure.
The .proc directive declares a symbol as a function. The .proc directive does not define the
symbol by assigning it a value. Symbols must be defined as a label within the procedure. When
name is defined, it is automatically assigned a "function" type.
.proc name,...
name: //label
Where:
Page 61
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 62
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
The Software Conventions and Runtime Architecture Guide describes stack unwind elements
and their semantics. Refer to this document for information about the semantics of the stack
unwind directives described in this section.
Page 63
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Procedures contain prologue and body regions that are divided by headers. These headers are
specified using the .prologue and .body directives.
The .prologue directive introduces a prologue region within a procedure. Each prologue region
must be introduced by the .prologue directive.
The .body directive separates the procedure prologue from the main body of the procedure. You
can use the .body directive more than once within procedures with multiple body regions.
For language specific data, use the .handlerdata directive followed by handler data
allocations with the .endp directive after the handler data allocations. The assembler places the
handler data in the .xdata section.
See the Stack Unwind Directives Usage Guidelines section for more information about using this
directive.
Example below, Procedure Format in a Code Sequence, illustrates the format of a procedure
with two prologues, two body regions, and language specific data.
Page 64
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Generally, functions have unwind table entries. A stack unwind directive must be present
between the .proc and .endp directives to write function entries and unwind information to the
unwind table.
To create a function entry for unwind information when there is no stack unwind information, use
the .unwentry directive.
The table that follows, Stack Unwind Directives, lists the stack unwind directives and their
operands. The right-most column of the table summarizes the records and fields that are affected
by these directives. For more information about the affected records and fields, refer to the
Software Conventions and Runtime Architecture Guide.
previous header
psp_sprel
Page 65
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
pso_psprel
.restore sp [ecount] [tag] epilogue
.copy_state state_no copy_state
.label_state state_no label_state
.save rp gr-location [tag] rp_when
rp_gr
.altrp br- rp_br
location
.savesp rp rp imm-location [tag] rp_when
rp_sprel
.savepsp rp rp imm-location [tag] rp_when
rp_psprel
.save ar.fpsr gr_location [tag] fpsr_when
fpsr_gr
.savesp ar.fpsr imm_location [tag] fpsr_when
fpsr_sprel
.savepsp ar.fpsr imm_location [tag] fpsr_when
fpsr_psprel
.save ar.bsp gr_location [tag] bsp_when
bsp_gr
.savesp ar.bsp imm_location [tag] bsp_when
bsp_sprel
.savepsp ar.bsp imm_location [tag] bsp_when
bsp_psprel
.save ar.bsp gr_location [tag] bspstore_when
store bspstore_gr
.savesp ar.bsp imm_location [tag] bspstore_when
store bspstore_spre
.savepsp ar.bsp imm_location [tag] bspstore_when
store bspstore_pspr
.save ar.rnat gr_location [tag] rnat_when
rnat_gr
Page 66
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
rnat_sprel
.savepsp ar.rnat imm_location [tag] rnat_when
rnat_psprel
.save ar.pfs gr-location [tag] pfs_when
pfs_gr
.savesp ar.pfs imm-location [tag] pfs_when
pfs_sprel
.savepsp ar.pfs imm-location [tag] pfs_when
pfs_psprel
.save ar.unat gr-location [tag] natcr_when
natcr_gr
.savesp ar.unat imm-location [tag] natcr_when
natcr_sprel
.savepsp ar.unat imm-location [tag] natcr_when
natcr_psprel
.save ar.lc gr-location [tag] lc_when
lc_gr
.savesp ar.lc imm-location [tag] lc_when
lc_sprel
.savepsp ar.lc imm-location [tag] lc_when
lc_psprel
.save pr gr-location [tag] preds_when
preds_gr
.savesp pr imm-location [tag] preds_when
preds_sprel
.savepsp pr imm-location [tag] preds_when
preds_psprel
.save @priunat gr_location [tag] priunat_when
priunat_gr
.savesp @priunat imm_location [tag] priunat_when
Page 67
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
priunat_sprel
.savepsp @priunat imm_location [tag] priunat_when
priunat_pspre
.save.g imm-grmask gr_mem
spill_imask
.save.g imm_grmask gr_location [tag] gr_gr imask
.save.f imm-frmask fr_mem
spill_imask
.save.b imm-brmask br_mem
spill_imask
.save.gf imm-grmask imm-frmask frgr_mem
spill_imask
.save.b imm-brmask gr-location br_gr
spill_imask
.spill imm- spill_base
location
.spillreg reg treg [tag] spill_reg
.restorereg reg [tag] spill_reg
.spillsp reg imm_location [tag] spill_sprel
.spillpsp reg imm_location [tag] spill_psprel
1 qp reg treg spill_reg_p
.spillreg.p
.restorereg.p qp reg [tag] spill_reg_p
.spillsp.p qp reg imm_location spill_sprel_p
.spillpsp.p qp reg imm_location spill_psprel_
.unwabi os-type imm_context abi
1
.spillreg.p, .spillsp.p, and .spillpsp.p have an optional fourth operand: [tag].
Page 68
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
z br-location is the alternative branch register used to get the return link. By default, b0 is
the return link.
z ecount is the number of prologues -1 specified by the assembler if this field is not
specified by the user.
z grsave saves the rp, ar.pfs, psp, and pr register contents to the first general-purpose
register.
z imm-location (immediate location) is the offset between the sp or psp, and the
save_address, specified in bytes. This offset is always positive and specified as follows:
z imm-mask (immediate mask) is an integer constant specifying a bit pattern for the
preserved registers, as follows:
— The immediate mask (mm-frmask) of the .save.f and .save.gf directives refer to
the preserved floating-point registers.
— The immediate mask (imm-grmask) of the .save.g and .save.gf directives refer to
the preserved general registers.
— The immediate mask (imm-brmask) of the .save.b directive refers to the preserved
branch registers.
z os-type is one of @svr4, @hpux, or @nt. It specifies the operating system type.
Page 69
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
z reg is one of the following registers: r4-r7, f2-f5, f16-f31, b1-b5, pr, @psp,
@priunat, rp, ar.bsp, ar.bspstore, ar.rnat, ar.unat, ar.fpsr, ar.pfs, or
ar.lc.
z tag is an optional operand, which specifies a "when" attribute of the operation described
by the directive.
Page 70
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Example Code Sequence Using the .save.g Directive illustrates the use of the .save.g
directive. Each .save.g directive describes the subsequent store instruction. The operand is a
mask where only one bit is set. This bit specifies the preserved saved register. The assembler
produces a gr_mem descriptor with a 0x5 mask. In addition, the assembler marks the 2-bit fields
of the imask descriptor, corresponding to the slots of the two store instructions.
.save.g 0x1
st8... = r4
...
.save.g 0x4
st8... = r6
Example Code Sequence Using the .save.gf Directive illustrates the use of the .save.gf
directive. The .save.gf directive describes the subsequent store instruction. The operands is a
mask where only one bit is set. This bit specifies the preserved saved register. The assembler
produces a frgr_mem descriptor with a 0x42 mask for the floating-point registers and a 0x2 mask
for the general-purpose registers. In addition, the assembler marks the 2-bit fields of the imask
descriptor, corresponding to the slots of the three store instructions.
.save.gf 0, 0x2
fst... = f3
...
.save.gf 0, 0x40
fst... = f18
...
.save.gf 0x2, 0
st8... = r5
Page 71
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
z Place stack unwind directives between the unwind entry point of the function declared
in .proc and .endp.
z The first directive in each region in a procedure must be one of the following region header
directives, .prologue or .body.
z The first directive in the procedure must point to the same address as the first unwind entry
point of the function.
z When none of the stack unwind directives listed in the Stack Unwind Directives table are
specified, optionally use the .unwentry directive to create an unwind entry for the
function. Do not use this directive if the unwind records are filled by the compiler.
z Use tags only within the current region. A tag operand cannot be specified out of the scope
region. If a tag is omitted, the directive refers to the next instruction, which resides in the
same region.
z Use only one .personality directive at any point within each procedure.
— Use one of the following frame directives if the procedure creates a new stack frame:
.fframe, .vframe, or .vframesp.
— Use each of the .save directives only once. For example: .save rp, ar.pfs,
ar.unat, ar.lc, and pr.
— A single unwind record is built for one or more occurrences of the following directives:
.save.g, .save.f, .save.b, and .save.gf. The bit-mask field of the record is a bitwise
OR of all the masks that appear in the directives.
— The .prologue <imm_mask> directive with the psp bit set and the .vframe directive
both define the psp location. Use only one of them.
Page 72
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 73
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.file "hello.c"
.pred.safe_across_calls p1-p5,p16-p63
.section .rdata, "a", "progbits"
.align 8
.STRING1:
stringz "Hello World!!!\n"
.text
.align 16
.global hello#
Page 74
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.proc hello#
hello:
.prologue
.save ar.pfs, r34
alloc r34 = ar.pfs, 0, 4, 1, 0
.vframe r35
mov r35 = r12
.save rp, r33
mov r33 = b0
.body
addl r36 = @ltoff(.STRING1), gp
;;
ld8 r36 = [r36]
mov r32 = r1
br.call.sptk.many b0 = printf#
;;
mov r1 = r32
mov ar.pfs = r34
mov b0 = r33
.restore sp
mov r12 = r35
br.ret.sptk.many b0
.endp hello#
.global printf#
.type printf#, @function
Page 75
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.ln line-number[,function]
Where:
.bf function,line
.ef function,line,code-size
Where:
Page 76
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Declarations
This section describes the Itanium® architecture assembly language directives associated with
symbol declarations. These directives can be used to perform the following functions:
Page 77
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 78
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Where:
Page 79
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
To declare one or more symbols with a global scope, use the .global directive. These symbols
are flagged as global symbols for the linkage editor. The .global directive has the following
format:
Where:
Page 80
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
To declare one or more symbols with a weak scope, use the .weak directive. These symbols are
flagged as weak symbols for the linkage editor. The weak scope declaration format for UNIX*
(ELF) and Windows NT (COFF32) differ and are described in the sections that follow.
Where:
The following example illustrates how to declare an undefined symbol with a weak scope. The
defined symbol x: has a local scope. y has the attributes of x and has a local scope. The symbol
y can then be declared with a weak scope using the .weak directive while keeping the other
attributes of x.
x:
y == x
.weak y
Where:
Page 81
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Use the following syntax to declare a symbol with a weak scope and search for defined symbols
within other object files and not within libraries:
Where:
The following example illustrates a weak scope declaration where x: is a local defined symbol. x
is the associated symbol for y. The .weak directive assigns y a weak scope.
x:
.weak y = x
Page 82
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
The default visibility of symbols is specified by the symbol's binding type. That is, global and
weak symbols are visible outside of their defining component (executable file or shared object).
Local symbols are hidden, as described below.
A symbol defined in the current executable file or shared object is protected if it is visible in other
components but not preemptable. Preemptable means that any reference to such a symbol from
within the defining component must be resolved to the definition in that component, even if there
is a definition in another component.
A symbol defined in the current component is hidden if its name is not visible to other
components. Such a symbol is necessarily protected. This directive may be used to control the
external interface of a component.
To declare one or more symbols as protected, use the .protected directive. These symbols
are flagged as protected symbols for the linkage editor. The .protected directive has the
following format:
Where:
To declare one or more symbols as hidden, use the .hidden directive. These symbols are
flagged as hidden symbols for the linkage editor. The .hidden directive has the following
format:
Where:
To declare one or more symbols as exported, use the .export directive. These symbols are
flagged as exported symbols for the linkage editor. The .export directive has the following
format:
Where:
Page 83
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 84
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.type name,type
Where:
Symbol Types
Note:
The assembler automatically creates a symbol of type name for section names. When the
object file format is COFF32 (Windows NT) the assembler creates a function symbol name
for @function. For more information see the Procedure Label (PLabel) section.
Page 85
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.size name,size
Where:
To implicitly specify the default size attribute of a symbol, use a data allocation statement. The
default symbol size is written to the symbol table. See the Data Allocation Statements section for
more information.
Note:
When the object file format is COFF32 (Windows NT), the .size directive is only effective
for common symbols.
Page 86
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.file "name"
Where:
Page 87
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
z The linker merges two or more common symbol declarations for the same symbol.
z The assembler merges two or more local common symbol declarations for the same
symbol.
If a symbol is declared as both common and local common, the common declaration overrides
the local common declaration. Any definition of a symbol supersedes either type of common
declaration.
.common name,size,alignment
Where:
Note:
When the object file format is COFF32 (Windows NT), the alignment operand is not
supported.
.lcomm name,size,alignment
Where:
Page 88
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
power of two.
The assembler allocates storage in the .bss or .sbss sections for undefined symbols declared
as local common. The .bss or .sbss sections are chosen according to the size of the local
common symbol. The assembler defines the symbol with the relocatable address of the allocated
storage. The symbol is declared with a local scope, and assigned the largest size and alignment
attributes of the local common declarations for that symbol.
Page 89
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.alias symbol,"alias"
Where:
The .secalias directive declares an alias for a section name. This directive can be used to
reference an external section whose name is not valid in the assembly language.
The .secalias directive has the following format:
.secalias section-name,"alias"
Where:
Page 90
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Data Allocation
This section describes the Itanium® architecture assembly language statements used to allocate
initialized and unitialized space for data objects in current sections and in cross sections, and to
align data objects in sections of the code.
Page 91
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Where:
The table below summarizes the data allocation mnemonics, and their expression type, memory
format, data-object size, and alignment boundary for each.
Page 92
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
To disable the automatic alignment of data objects in data allocation statements, add the .ua
completer after the mnemonic, for example, data4.ua. These statements allocate unaligned
data objects at the current location within the current section.
The default byte order for data allocation statements is platform dependent. To specify the byte
order for data allocation statements, use the .msb, or .lsb directives described in the Byte
Order Specification Directives section.
Page 93
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
The .skip statement reserves a block of space in the current section. The size of the block is
specified in bytes, and is determined by an expression operand. The expression operand
specifies the size of space reserved in the current section. The .skip statement with a label,
defines a symbol of @object type, and sets the size attribute for that symbol.
Where:
The .org statement reserves a block of space in the current section. The .org statement
advances the location counter to the location specified by the expression operand. The .org
statement with a label defines a symbol of @object type, and sets the size attribute for that
symbol. The .org statement has the following format:
Where:
Page 94
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
location counter.
Page 95
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Alignment
Instructions and data objects are aligned on natural alignment boundaries within a section. To
disable automatic alignment of data objects in data allocation statements, add the .ua completer
after the data allocation mnemonic, for example, data4.ua. Bundles are aligned at 16-byte
boundaries, and data objects are aligned according to their size. The assembler does not align
string data, since they are byte arrays.
Each section has an alignment attribute, which is determined by the largest aligned object within
the section.
Section location counters are not aligned automatically. To align the location counter in the
current section to a specified alignment boundary use the .align statement. The .align
statement has the following format:
.align expression
Where:
The .align statement enables the assembler to reserve space in any section type, including a
"nobits" section. During program execution time the contents of a "nobits" section are
initialized as zero by the operating system program loader. When using the .align statement in
any other section type, the assembler initializes the reserved space with zeros for non-
executable sections, and with a NOP pattern for executable sections.
Note:
When the object file format is COFF32 (Windows NT) the section alignment boundary is
limited to 8KB. The assembler does not guarantee alignment for requests above 8KB.
Page 96
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Where:
To disable automatic alignment of data objects in a cross-section data allocation statement, add
the .ua completer to the statement, for example, .xdata4.ua. These statements allocate
unaligned data objects at the current location counter of the cross section, not the current
section.
The default byte order for cross-section data allocation statements is platform dependent. The
byte order is determined by the cross section, not by the current section.
Page 97
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Miscellaneous Directives
This section describes the following Itanium® architecture assembly language directives:
z Preprocessor support
Page 98
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Refer to the Intel® Itanium® Architecture Software Developer’s Manual for detailed information
about register renaming and for a full description of the alloc instruction.
The .regstk directive replaces the default register mappings defined by a preceding alloc
instruction with new mappings. The .regstk directive does not allocate a new register stack
frame.
Where:
The in, loc, and out register names defined by a previous .regstk directive or alloc
instruction are visible by all subsequent instructions until the next .regstk directive or alloc
instruction is specified.
The alternate register names specified by the operands of the .regstk directive refer to
registers in the current register stack frame. If you reference input, local, or output registers using
Page 99
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
the alternate register names that are not within the current stack frame, the assembler produces
an error message.
To prevent referencing the alternate register names, use the .regstk directive without the
operands. The operands of a subsequent .regstk directive or alloc instruction redefine the
mappings of the alternate register names.
The alloc instruction and .regstk directive do not affect the names of the general registers,
r32 through r127.
Page 100
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.regstk 4,4,2,0
tmp = loc0 //loc0 is currently r36
...
.regstk 8,1,3,0
add loc0 = r1,r7 //loc0 is currently r40
add r1 = r2,tmp //tmp = r36!
Page 101
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
The following directives enable the programmer to provide names for one or more registers
within each rotating register region:
The .rotx directives assign alternate names and generation numbers for the rotating registers.
One generation corresponds to one iteration of a software-pipelined loop. Each copied register is
numbered with an index, where the most recent copy of a register has a zero index, such as b
[0]. For every loop iteration, the registers within the group are renamed, and become one
generation older by incrementing the index by one.
The .rotx directives define the number of instances of each pipeline variable and allocate them
in the appropriate rotating register region. You can use an arbitrary name with a subscript-like
notation for referencing the current and previous generations of each variable.
Where:
When the alias rotating register names are used as instruction operands, they have the following
format:
name[expression]
Where:
Page 102
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
The .rotr, .rotf, and .rotp directives cancel all previous alias names associated with the
appropriate register file, before defining new register names. The register files include the
general, floating-point, and predicate registers.
If the number of rotating general registers implied by a .rotr directive exceeds the number of
rotating registers declared by the nearest preceding alloc instruction, or .regstk directive, the
assembler issues a warning.
Page 103
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Example Using the .rotp Directive illustrates how the .rotp directive declares alternate rotating
predicate register names for two predicate registers, p[2], and three predicate registers q[3].
Instructions subsequent to the .rotp directive refer to p[0] for the current generation of p, and
p[1] for the previous generation of p. For the current generation of q, the subsequent
instructions refer to q[0], q[1] for the previous generation, and q[2] for the one before the
previous generation.
.rotp p[2],q[3]
//The alternate predicate register names map to the
// predicate registers as follows:
p[0] = p16; p[1] = p17
q[0] = p18; q[1] = p19; q[2] = p20
Example Using the .rotf Directive illustrates how the .rotf directive declares alternate floating-
point register names for three floating-point registers x[3], two floating-point registers y[2], and
three floating-point registers z[3].
.rotf x[3],y[2],z[3]
//The alternate floating-point register names map to the
//floating-point registers as follows:
x[0]=f32;x[1]=f33;x[2]=f34
y[0]=f35;y[1]=f36
z[0]=f37;z[1]=f38;z[2]=f39
Page 104
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Example Defining an Alias Name in an Assignment Statement illustrates how to define an alias
name using an assignment statement so that the alias name is not affected by a
subsequent .rotr directive. The .rotr directive maps b[1] to general register r36. b[1] is
assigned to tmp. The second .rotr directive defines the new mapping of b[1] to r33. The
subsequent add instruction that refers to b[1] is currently mapped to r33. The second add
instruction refers to tmp, which is mapped to r36, not r33.
.rotr a[3],b[2],c[4]
tmp = b[1] //b[1] is currently r36
...
.rotr b[4],c[3],d[2]
add b[1] = r1,r7 //b[1] is currently r33
add r1 = r2,tmp //tmp = r36!
Page 105
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
The .msb and .lsb directives change the byte order for current sections only. They do not affect
the instructions that are assembled. They only affect the data created. The default byte order is
little-endian.
The .msb directive switches to MSB, where the most-significant byte is stored at the lowest
address (big-endian). The .lsb directive switches to LSB, where the least-significant byte is
stored at the lowest address (little-endian).
The byte order is a property of each section. If the byte order is changed in one section, it
remains in effect for that section until the byte order is redefined. This change does not affect the
byte order of other sections in the assembly program.
Page 106
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.ident "string"
Where:
Page 107
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
To select a MASM numeric constant and specify a radix indicator, use the .radix directive in
the following format:
.radix [radix-indicator]
Where:
The MASM numeric constant and radix remain in effect until redefined.
To select a C numeric constant, use the .radix directive in the following format:
.radix [C]
Where:
The .radix directive used with an operand, pushes the previous numeric constant style and
radix onto a radix stack. The .radix directive without the radix-indicator operand, pops and
restores the previous style and radix from the stack. The assembler may limit the depth of a radix
stack, but this limit must be no less than 10 levels.
Page 108
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Preprocessor Support
The assembler recognizes a special filename and the line number directive (#line) inserted by
the standard C preprocessor, and sets its record as the current filename and line number
accordingly. The #line directive has the following format:
Where:
Page 109
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Annotations
Annotations are a subset of the assembler directives. They explicitly provide additional
information for the assembler during the assembly process. These annotations have the same
format and syntax as all other directives. This section describes these annotations and their
functionality.The annotations covered in this section include:
z .pred.rel
z .pred.vector
z .mem.offset
z .entry
Page 110
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
"imply" implication
When conflicting instructions follow an entry point, IAS ignores all existing predicate relationships
defined before the entry point.
Page 111
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
This annotation takes effect at the point of insertion and the assembler may use this information
for further analysis. The .pred.vector annotation has the following syntax:
Where:
Example Using a Predicate Vector Annotation with a Mask illustrates a predicate vector
annotation that sets the predicate registers according to the specified value 0x9, and uses a
mask of 0xffff to define a subset of the predicate register file.
Page 112
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Where:
off_val The relative offset for the memory region where the
data is stored or retrieved.
base_ind A number that identifies the memory region where the
information is stored or retrieved. The number is an
arbitrary method of distinguishing between different
memory regions.
.proc foo
foo::
FOO_STACK_INDEX=0
... //code...
.mem.offset 0,FOO_STACK_INDEX //Suppose r3 contains the stack pointer
st8.spill [r3]=r32,8 //We want to save r32-r34
.mem.offset 8,FOO_STACK_INDEX
st8.spill [r3]=r33,8
.mem.offset 16,FOO_STACK_INDEX
st8.spill [r3]=r34,8
.endp
.proc bar
bar::
.BAR_STACK_INDEX=1
... //code...
.mem.offset 0,BAR_STACK_INDEX //Suppose r3 contains the stack pointer
st8.spill [r3]=r40 //We want to save r40
Page 113
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Entry Annotation
The entry annotation .entry notifies the assembler that a label can be entered from another
function. By default, only global labels, designated by <label>::, are considered entry points.
The annotation and the label need not be consecutive.
Where:
Page 114
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
z General Registers
z Floating-point Registers
z Predicate Registers
z Branch Registers
z Application Registers
z Control Registers
z Other Registers
z Indirect-register Files
Page 115
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
General Registers
Register Register Name
Fixed general registers r0 - r31
Stacked general registers r32 - r127
Alternate names for input registers in0 - in95
Alternate names for local registers loc0 - loc95
Alternate names for output registers out0 - out95
Global pointer (r1) gp
Return value registers (r8-r11) ret0 - ret3
Stack pointer (r12) sp
Page 116
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Floating-point Registers
Register Register Name
Floating-point registers f0 - f127
Argument registers (f8-f15) fret0 - fret7
Return value registers (f8-f15) fret0 - fret7
Page 117
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Predicate Registers
Register Register
Predicates p0 - p63
All predicates pr
Rotating predicates pr.rot
Page 118
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Branch Registers
Register Register Name
Branch registers b0 - b7
Return pointer (b0) rp
Page 119
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Application Registers
Register Register Register Name
Number
Application registers by number 0 - 127 ar0 - ar127
Kernel registers 0 - 7 ar.k0 -
ar.k7
RSE control register 16 ar.rsc
Backing store pointer 17 ar.bsp
Backing store “store” pointer 18 ar.bspstore
RSE NaT collection register 19 ar.rnat
Compare & Exchange comparison 32 ar.ccv
value
User NaT collection register 36 ar.unat
Floating-point status register 40 ar.fpsr
Interval time counter 44 ar.itc
Previous frame state 64 ar.pfs
Loop counter 65 ar.lc
Epilog counter 66 66 ar.ec
Page 120
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Control Registers
Register Register Register Name
Number
Control registers by number 0 - 127 cr0 - cr127
Default control register 0 cr.dcr
Interval time match 1 1 cr.itm
Interruption vector address 2 2 cr.iva
Page table address 8 8 cr.pta
Guest page table address 9 cr.gpta
Interruption processor status register 16 cr.ipsr
Interruption status register 17 cr.isr
Interruption instruction pointe 19 cr.iip
Interrupt faulting address 20 cr.ifa
Interrupt TLB insertion register 21 cr.itir
Interruption instruction previous address 22 cr.iipa
Interruption frame state 23 cr.ifs
Interruption immediat 24 cr.iim
Interruption hash address 25 cr.iha
External interrupt registers 64 cr.lid
65 cr.ivr
66 cr.tpr
67 cr.eoi
68-71 cr.irr0-cr.irr3
72 cr.itv
73 cr.pmv
74 cr.cmcv
80-81 cr.lrr0-cr.lrr1
Page 121
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Other Registers
Register Register Name
Processor status register psr
Processor status register, lower 32 psr.l
bits
User mask psr.um psr.um
Instruction pointer ip
Page 122
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Indirect-register Files
Register Register Name
Performance monitor control registers pmc[r]
Performance monitor data registers pmd[r]
Protection key registers pkr[r]
Region registers rr[r]
Instruction breakpoint registers ibr[r]
Data breakpoint registers dbr[r]
Instruction translation registers itr[r]
Data translation registers dtr[r]
Processor identification register CPUID[r]
Page 123
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Pseudo-ops
This section contains two tables of pseeudo-ops:
Page 124
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
addl r1 =imm22,r3
break Break imm21 break.b imm21 (B)
absolute value
fadd.pc.sf Floating-point f1 =f3,f2 fma.pc.sf f1 =f3,f1,f2
add
multiply
fneg Floating-point f1 =f3 fmerge.ns f1 =f3,f3
negate
fnegabs Floating-point f1 =f3 fmerge.ns f1 =f0,f3
negate absolute
value
fnorm.pc.sf Floating-point f1 =f3 fma.pc.sf f1 =f3,f1,f0
normalize
fsub.pc.sf Floating-point f1 =f3,f2 fms.pc.sf f1 =f3,f1,f2
Page 125
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
subtract
ld8.mov ld8 that can be r2=[r3], ld8 r2=[r3]
translated to
mov. It is used to Symbol+Addend mov r2=r3
support link time
rewriting of
indirect
addressing code
sequences. In
ELF format only.
mov Move to ar3 =imm8 mov.i ar3 =imm8 (I)
application
register mov.m ar3 =imm8 (M)
immediate
mov Move to ar3 =r2 mov.i ar3 =r2 (I)
application
register mov.m ar3 =r2 (M)
mov Move f1 =f3 fmerge.s f1 =f3,f3
floating-point
register
mov Move from r1 =ar3 mov.i r1 =ar3 (I)
application
register mov.m r1 =ar3 (M)
mov Move immediate r1 =imm22 addl r1 =imm22,r0
mov Move general r1 =r2 adds r1 =0,r2
register
mov Move to branch b1 =r2 mov b1 =r2
register
nop No operation imm21 nop.b imm21 (B)
Page 126
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
multiply low
unsigned
Page 127
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
fclass.nm.fctype p1,p2=f2,f3
fcmp fcmp.fcrel.fctype.sf p1,p2=f2,f3 p0
mov mov pr=r2,mask17 all ones
tbit tbit.trel.ctype p1,p2=r3,pos6 p0
tnat tbit.trel.ctype p1,p2=r3 p0
Page 128
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Link-relocation Operators
The table below lists and describes the link-relocation operators and their usage. Unless
otherwise specified, the usage is for both COFF and ELF formats.
Page 129
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 130
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 131
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Category Directive
Alias declaration directives .alias
.secalias
Assembler annotations .pred.rel
.pred.vector
.mem.offset
.entry
Assembler modes .auto
.explicit
.default
Byte order specification directive .msb
.lsb
Common symbol declaration .common
directives
.lcomm
Cross-section data allocation .xdata1
statements
.xdata2
.xdata4
.xdata8
.xstring
.xstringz
Data-allocation statements data1 data1
data2
data4
data8
real4
Page 132
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
real8
real10
real16
string
stringz
Explicit template selection directives .mii
.mfi
.bbb
.mlx
.mib
.mmb
.mmi
.mbb
.mfb
.mmf
File symbol declaration directive .file
Ident string directive .ident
Include file directive .include
Language specific data directive .handlerdata
(Windows NT * specific)
.endp
Radix indicator directive .radix
Register stack directive .regstk
Reserving uniniatialized space .skip
statements
.org
Rotating register directives .rotr
.rotp
.rotf
Section directives .section
Page 133
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
.pushsection
.popsection
.previous
.text
.data
.sdata
.bss
.sbss
.rodata
.comment
Section and data alignment directive .align
Stack unwind information directives See Stack Unwind Directives
table
Symbol scope declaration directives .global
.weak
.local
Symbol visibility directives .protected
.hidden
Symbol type and size directives .type
.size
Symbolic debug directive .ln
Symbolic debug directive Windows .bf
NT
.ef
specific
Virtual register allocation directives .vreg.allocatable
.vreg.safe_across_calls
.vreg.family
.vreg.var
.vreg.undef
Page 134
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 135
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Glossary
absolute address A virtual (not physical) address within the
absolute number.
absolute expression An expression that is not subject to link-time
relocation.
alias Two identifiers referring to the same
element.
assembler A program that translates assembly
language
template field.
COFF Common Object File Format, an object-
module
Page 136
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
format.
directive An assembler instruction that does not
produce executable code.
execution time The time during which a program is actually
it is defined.
IA-32 Intel Architecture-32: the name for Intel’s
(ISA).
identifier Syntactic representation of symbol names
using alphabetic or special characters, and
digits.
instruction An operation code that performs a specific
machine operation.
instruction group Itanium® architecture instructions are
organized in instruction groups. Each
instruction group contains one or more
statically contiguous instructions that
execute in parallel. An instruction group
must contain at least one instruction; there is
no upper limit on the number of instructions
in an instruction group.
Page 137
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
which it is defined.
location counter Keeps track of the current address when
assembling a program. It starts at zero at the
beginning of each segment and increments
appropriately as each instruction is
assembled. To adjust the location counter of
a section, use the .align directive, or
the .org directive.
memory stack A contiguous array of memory locations,
commonly referred to as “the stack”, used in
many processors to save the state of the
calling procedure, pass parameters to the
called procedure and store local variables for
the currently executing procedure.
mnemonic A predefined assembly-language name for
instruction.
name space A virtual (not physical) file. The assembler
assigns names to a symbol, register, or
Page 138
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
programmer.
qualifying predicate The execution of most instructions is gated
by a qualifying predicate. If the predicate is
true, the instruction executes normally; if the
instruction is false the instruction does not
modify architectural state or affect program
behaviour.
register rotation Software renaming of registers to provide
every loop iteration with its own set of
registers.
register stack configuration A 64-bit register used to control the register
relocation
rotating registers Registers which are rotated by one register
Page 139
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
• label statements
• instruction statements
• directive statements
• assignment statements
• equate statements
Page 140
Intel(R) Itanium(R) Architecture Assembly Lanuage Reference Guide
Page 141