Directives. NXP CodeWarrior Development Studio
Реклама
Реклама
Directives
5. Anything following a
; character is considered to be a comment, except in GNU compatibility mode, where
; is a statement separator.
12.1.7 Data Alignment
The assembler's default alignment is on a natural boundary for the data size and for the target processor family. To turn off this default alignment, use the alignment
keyword argument with to the
. option
directive.
NOTE
The assembler does not align data automatically in the
.debug
section.
12.2 Directives
• Some directives may not be available for the assembler for your target processor.
• The default starting character for most directives is the period (.). However, if you clear the Directives begin with '.' checkbox of the Assembler settings panel, you can omit the period.
• You can use the C/C++ preprocessor format to specify several preprocessor directives .
Explanations are in these sections:
•
•
Conditional Preprocessor Directives
•
•
•
•
•
•
12.2.1 Macro Directives
These directives let you create macros:
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
166 Freescale Semiconductor, Inc.
Chapter 12 Assembler
•
•
•
•
For more information on macros, see
12.2.1.1 macro
Starts the definition of a macro.
label .macro [ parameter ] [ ,parameter ] ...
Parameters
label
Name you give the macro.
parameter
Optional parameter for the macro.
12.2.1.2 endm
Ends the definition of a macro.
.endm
12.2.1.3 mexit
Stops macro execution before it reaches the .endm directive. Program execution continues with the statement that follows the macro call.
.mexit
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
167
Directives
12.2.1.4 #define
Defines a C pre-processor macro with the specified parameters. Note that the C preprocessor is run on the assembler file before normal assembly. C pre-processor macros should not be confused with normal macros declared using the
MACRO
and
ENDM
directives.
#define
name [ (
parms) ]
assembly_statement [ ; ] [ \ ]
assembly_statement [ ; ] [ \ ]
assembly_statement
parms ::=
parameter [ ,
parameter ]...
Parameters
name
Name you give the macro.
parms
List of parameters, separated by commas.
assembly_statement
Any valid assembly statement.
Remarks
To extend an assembly_statement, type a backslash (\) and continue the statement on the next line. To specify multiple assembly statements in the macro, type a semicolon and backslash (;\), then type a new assembly statement on the next line. If the assembler is in
GNU mode, multiple statements can be on one line of code - separate them with semicolon characters (;).
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
168 Freescale Semiconductor, Inc.
NOTE
For more information, see
"Using the #define Directive" on page 181
.
Chapter 12 Assembler
12.2.2 Conditional Preprocessor Directives
Conditional directives let you control whether compilation includes a block of code.
These directives let you make multiple builds that are slightly different.
You must use conditional directives together to form a complete block. Several conditional directives are variations of
.if
that make it easier to establish blocks that test strings for equality, test whether a symbol is defined, and so on.
NOTE
You can use the C/C++ preprocessor format to specify these conditional directives:
#if #ifdef #ifndef
#else #elif #endif
With two exceptions, these directives function identically whether their starting character is a pound sign (#) or a period.
The exceptions are:
1. You cannot use the pound sign format in a macro.
2. The period form of
#elif
is
.elseif
.
The conditional preprocessor directives are:
•
•
•
•
•
•
•
•
•
Compatibility Conditional Directives
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
169
Directives
12.2.2.1 if
Starts a conditional assembly block, making assembly conditional on the truth of a boolean expression.
.if bool-expr
Parameter
bool-expr
Any boolean expression.
Remarks
If bool-expr
is true, the assembler processes the statements of the block. If bool-expr
is false, the assembler skips the statements of the block.
Each
.if
directive must have a matching
.endif
directive.
12.2.2.2 ifdef
Starts a conditional assembly block, making assembly conditional on the definition of a symbol.
#ifdef symbol
Parameter
symbol
Any valid symbol.
Remarks
If previous code includes a definition for symbol
, the assembler processes the statements of the block. If symbol
is not defined, the assembler skips the statements of the block.
Each
.ifdef
directive must have a matching
.endif
directive.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
170 Freescale Semiconductor, Inc.
Chapter 12 Assembler
12.2.2.3 ifndef
Starts a conditional assembly block, making assembly conditional on a symbol not being defined.
.ifndef symbol
Parameter
symbol
Any valid symbol.
Remarks
If previous code does not include a definition for symbol
, the assembler processes the statements of the block. If there is a definition for symbol
, the assembler skips the statements of the block.
Each
.ifndef
directive must have a matching
.endif
directive.
12.2.2.4 ifc
Starts a conditional assembly block, making assembly conditional on the equality of two strings.
.ifc string1, string2
Parameters
string1
Any valid string.
string2
Any valid string.
Remarks
If string1 and string2 are equal, the assembler processes the statements of the block. (The equality comparison is case-sensitive.) If the strings are not equal, the assembler skips the statements of the block.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
171
Directives
Each
.ifc
directive must have a matching
.endif
directive.
12.2.2.5 ifnc
Starts a conditional assembly block, making assembly conditional on the inequality of two strings.
.ifnc string1, string2
Parameters
string1
Any valid string.
string2
Any valid string.
Remarks
If string1 and string2 are not equal, the assembler processes the statements of the block.
(The inequality comparison is case-sensitive.) If the strings are equal, the assembler skips the statements of the block.
Each
.ifnc
directive must have a matching
.endif
directive.
12.2.2.6 endif
Ends a conditional assembly block. A matching
.endif
directive is mandatory for each type of
.if
directive.
.endif
12.2.2.7 elseif
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
172 Freescale Semiconductor, Inc.
Chapter 12 Assembler
Starts an alternative conditional assembly block, making assembly conditional on the truth of a boolean expression.
.elseif bool-expr
Parameter
bool-expr
Any boolean expression.
Remarks
If bool-expr
is true, the assembler processes the statements of the block. If bool-expr
is false, the assembler skips the statements of the block.
You can use this directive to create a logical, multilevel if-then-else statement, according to this syntax:
.if bool-expr statement-group
[ .elseif bool-expr statement-group ]...
[ .else statement-group ]
.endif
(In this syntax, statement-group
is any group of assembly-language statements.)
The
.elseif
directive can be part of more complicated logical structures, such as:
.if bool-expr-1
statement-group-1
.elseif bool-expr-2
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
173
Directives
statement-group-2
.elseif bool-expr-3
statement-group-3
.elseif bool-expr-4
statement-group-4
.else
statement-group-5
.endif
• If this structure's bool-expr-1
is true, the assembler executes the statement-group-1 assembly-language statements, then goes to the
.endif
directive.
• If bool-expr-1
is false, the assembler skips statement-group-1
, executing the first
.elseif
directive. If bool-expr-2
is true, the assembler executes statement-group-2
, then goes to the
.endif
directive.
• If bool-expr-2
also is false, the assembler skips statement-group-2
, executing the second
.elseif
directive.
• The assembler continues evaluating the boolean expressions of succeeding
.elseif
directives until it comes to a boolean expression that is true.
• If none of the boolean expressions are true, the assembler processes statement-group-5
, because this structure includes an
.else
directive. (If none of the boolean values were true and there were no
.else
directive, the assembler would not process any of the statement groups.)
12.2.2.8 else
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
174 Freescale Semiconductor, Inc.
Chapter 12 Assembler
Starts an alternative conditional assembly block.
.else
Remarks
This directive is optional. The assembler processes the statements of the alternative conditional assembly block only if the expressions for an
.if
directive and any associated
.elseif
directives are false.
12.2.3 Compatibility Conditional Directives
For compatibility with other assemblers, the assembler supports these additional conditional directives:
•
•
•
•
•
•
.ifge if greater than or equal
12.2.3.1 .ifeq if equal
Starts a conditional assembly block, making assembly conditional on a string value being equal to zero.
.ifeq string
Parameter
string
Any valid string.
Remarks
If the string
value equals 0, the assembler processes the statements of the block. If the string
value does not equal 0, the assembler skips the statements of the block.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
175
Directives
12.2.3.2 .ifne if not equal
Starts a conditional assembly block, making assembly conditional on a string value not being equal to zero.
.ifne string
Parameter
string
Any valid string.
Remarks
If the string value is not equal to 0, the assembler processes the statements of the block. If the string
value does equal 0, the assembler skips the statements of the block.
12.2.3.3 .iflt if less than
Starts a conditional assembly block, making assembly conditional on a string value being less than zero.
.iflt string
Parameter
string
Any valid string.
Remarks
If the string
value is less than 0, the assembler processes the statements of the block. If the string
value equals or exceeds 0, the assembler skips the statements of the block.
12.2.3.4 .ifle if less than or equal
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
176 Freescale Semiconductor, Inc.
Chapter 12 Assembler
Starts a conditional assembly block, making assembly conditional on a string value being less than or equal to zero.
.ifle string
Parameter
string
Any valid string.
Remarks
If the string value is less than or equal to 0, the assembler processes the statements of the block. If the string
value is greater than 0, the assembler skips the statements of the block.
12.2.3.5 .ifgt if greater than
Starts a conditional assembly block, making assembly conditional on a string value being greater than zero.
.ifgt string
Parameter
string
Any valid string.
Remarks
If the string
value is greater than 0, the assembler processes the statements of the block. If the string value is less than or equal to 0, the assembler skips the statements of the block.
12.2.3.6 .ifge if greater than or equal
Starts a conditional assembly block, making assembly conditional on a the string value being greater than or equal to zero.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
177
Directives
.ifge string
Parameter
string
Any valid string.
Remarks
If the string
value is greater than or equal to 0, the assembler processes the statements of the block. If the string
value is less than 0, the assembler skips the statements of the block.
12.2.4 Section Control Directives
These directives identify the different sections of an assembly file:
•
•
•
•
•
•
•
•
•
•
•
•
12.2.4.1 text
Specifies an executable code section; must be in front of the actual code in a file.
.text
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
178 Freescale Semiconductor, Inc.
Chapter 12 Assembler
12.2.4.2 data
Specifies an initialized read-write data section.
.data
12.2.4.3 rodata
Specifies an initialized read-only data section.
.rodata
12.2.4.4 bss
Specifies an uninitialized read-write data section.
.bss
12.2.4.5 sdata
Specifies a small data section as initialized and read-write.
.sdata
12.2.4.6 sdata2
Specifies a small data section as initialized and read-only.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
179
Directives
.sdata2
12.2.4.7 sbss
Specifies a small data section as uninitialized and read-write.
.sbss
12.2.4.8 text_vle
Specifies a Variable length encoded section as read/execute.
.text_vle
12.2.4.9 debug
Specifies a debug section.
.debug
Remarks
If you enable the debugger, the assembler automatically generates some debug information for your project. However, you can use special directives in the debug section that provide the debugger with more detailed information. For more information on the debug directives, see
12.2.4.10 previous
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
180 Freescale Semiconductor, Inc.
Chapter 12 Assembler
Reverts to the previous section; toggles between the current section and the previous section.
.previous
12.2.4.11 offset
Starts a record definition, which extends to the start of the next section.
.offset [expression]
Parameter
expression
Optional initial location-counter value.
Remarks
Table 12-6 lists the only directives your can use inside a record.
Table 12-6. Directives within a Record
.align
.ascii
.asciz
.byte
.double
.equ
.float
.long
.org
.set
.short
.space
.textequ
Data declaration directives such as
.byte
and
.short
update the location counter, but do not allocate any storage.
Example
Figure 12-1 shows a sample record definition.
Figure 12-1. Record Definition with Offset Directive
.offset
top: .short 0 left: .short 0 bottom: .short 0 right: .short 0
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
181
Directives
rectSize .equ *
12.2.4.12 section
Defines a section of an ELF (Executable and Linkable Format) object file.
.section name [,alignment [,type [,flags]]]
Parameters
name
Name of the section.
alignment
Alignment boundary.
type
Numeric value for the ELF section type, per Table 12-7 . The default type
value is
1
:
(SHT_PROGBITS).
flags
2
3
4
5
6
0
1
Numeric value for the ELF section flags, per Table 12-8 . The default flags
value is
0x00000002, 0x00000001
: (SHF_ALLOC+SHF_WRITE).
Table 12-7. ELF Section Header Types (SHT)
7
Type
NULL
PROGBITS
SYMTAB
STRTAB
RELA
HASH
DYNAMIC
NOTE
Name Meaning
Section header is inactive.
Section contains information that the program defines.
Section contains a symbol table.
Section contains a string table.
Section contains relocation entries with explicit addends.
Section contains a symbol hash table.
Section contains information used for dynamic linking.
Section contains information that marks the file, often for compatibility purposes between programs.
Table continues on the next page...
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
182 Freescale Semiconductor, Inc.
8
9
10
11
0x00000001
0x00000002
0x00000004
0xF0000000
Flag
Type
Chapter 12 Assembler
Table 12-7. ELF Section Header Types (SHT) (continued)
NOBITS
REL
SHLIB
DYNSYM
Name Meaning
Section occupies no space in the object file.
Section contains relocation entries without explicit addends.
Section has unspecified semantics, so does not conform to the Application
Binary Interface (ABI) standard.
Section contains a minimal set of symbols for dynamic linking.
Table 12-8. ELF Section Header Flags (SHF)
WRITE
ALLOC
EXECINSTR
MASKPROC
Name Meaning
Section contains data that is writable during execution.
Section occupies memory during execution.
Section contains executable machine instructions.
Bits this mask specifies are reserved for processor-specific purposes.
Remark
Use this directive to create arbitrary relocatable sections, including sections to be loaded at an absolute address.
Possiblesyntaxforms
The section directive accepts a number of different syntax forms, partly for convenience and partly for compatibility with other assemblers. A section declaration requires four pieces of information: a section name, alignment, ELF section type (for example,
SHT_PROGBITS) and ELF section flags (for example, SHF_ALLOC
+SHF_EXECINSTR).
The possible syntax forms are as follows:
• Specify built-in section name.
.section text
This example specifies a built-in section name text
. Equivalently, .text is also a valid syntax form.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
183
Directives
Table 12-9 provides a list of all the possible values, together with their ELF types and ELF Section Header Flags.
.text
.data
.rodata
.bss
.sdata
.sdata0
.sdata2
.sbss
.sbss0
.sbss2
.debug
.text_vle
Name
Table 12-9. Built-in Section names with their ELF Types and
Flags
.PPC.EMB.sdata0
.PPC.EMB.sbss0
ELF Type
SHT_PROGBITS
SHT_PROGBITS
SHT_PROGBITS
SHT_NOBITS
SHT_PROGBITS
SHT_PROGBITS
SHT_PROGBITS
SHT_NOBITS
SHT_NOBITS
SHT_PROGBITS
SHT_PROGBITS
SHT_PROGBITS
SHT_PROGBITS
SHT_PROGBITS
ELF Flag
SHF_ALLOC
+SHF_EXECINSTR
SHF_ALLOC+SHF_WRITE
SHF_ALLOC
SHF_ALLOC+SHF_WRITE
SHF_ALLOC+SHF_WRITE
SHF_ALLOC+SHF_WRITE
SHF_ALLOC
SHF_ALLOC+SHF_WRITE
SHF_ALLOC+SHF_WRITE
SHF_ALLOC
0
SHF_ALLOC
+SHF_EXECINSTR+
SHF_PE_EXECINSTR
SHF_ALLOC+SHF_WRITE
SHF_ALLOC+SHF_WRITE
In general, .text is for instructions, .data for initialised data, .rodata for read-only data
(constants) and .bss for uninitialised data. The additional forms like .sdata are for small data areas. The built-in section names are architecture-specific, and are intended to make access to data more efficient. The alignment used for these sections is architecture-specific and is usually 4.
• Specify your own section name but get the attributes of the built-in section type.
.section mySection,text
This example is equivalent to writing .text except that the section will be called mySection.
• Specify the alignment, and optionally the ELF type and flags.
.section name [,alignment [,type [,flags]]]
In the syntax above, if the alignment is not specified it defaults to 16. If the type or flags are not specified, the defaults are as follows:
• If the name parameter is a built-in section name, the type and the flags are taken as specified in the Table 12-9 . For example, in the syntax form.section text,8 the
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
184 Freescale Semiconductor, Inc.
Chapter 12 Assembler
type is SHT_PROGBITS and the flags value is SHF_ALLOC
+SHF_EXECINSTR.
• In all other cases, the default type is SHT_PROGBITS and the default flags value is SHF_ALLOC+SHF_WRITE, corresponding to a writeable data section.
• Specify the type and flags parameters in pre-defined characters, optionally in double quotes.
.section mySection,4,"rx" or .section mySection,4,rx
The values are additive. For example, rx is equivalent to SHF_ALLOC
+SHF_WRITE+SHF_EXECINSTR
NOTE
If the syntax doesn't specify a type it defaults to
SHT_PROGBITS
Table 12-10 provides a list of all the possible characters and their corresponding ELF
Type and ELF Flags.
r w x d m b c
Table 12-10. Characters and their corresponding ELF Type and ELF
Flags
Character
0
0
0
ELF Type
SHT_NOBITS
SHT_PROGBITS
SHT_PROGBITS
SHT_PROGBITS
ELF Flag
SHF_ALLOC+SHF_WRITE
SHF_ALLOC
+SHF_EXECINSTR
SHF_ALLOC+SHF_WRITE
SHF_ALLOC+SHF_WRITE+
SHF_EXECINSTR
SHF_ALLOC
SHF_ALLOC+SHF_WRITE
SHF_ALLOC
+SHF_EXECINSTR
12.2.5 Scope Control Directives
These directives let you import and export labels:
•
•
•
For more information on labels, see "Labels".
.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
185
Directives
NOTE
You cannot import or export equates or local labels.
12.2.5.1 global
Tells the assembler to export the specified labels, that is, make them available to other files.
.global label [ ,label ]...
Parameter
label
Any valid label.
12.2.5.2 extern
Tells the assembler to import the specified labels, that is, find the definitions in another file.
.extern label [ ,label ]...
Parameter
label
Any valid label.
12.2.5.3 public
Declares specified labels to be public.
.public label [ ,label ]...
Parameter
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
186 Freescale Semiconductor, Inc.
Chapter 12 Assembler
label
Any valid label.
Remarks
If the labels already are defined in the same file, the assembler exports them (makes them available to other files). If the labels are not already defined, the assembler imports them
(finds their definitions in another file).
12.2.6 Symbol Definition Directives
These directives let you create equates:
•
•
•
•
12.2.6.1 set
Defines an equate, assigning an initial value. You can change this value at a later time.
equate .set expression
Parameters
equate
Name of the equate.
expression
Temporary initial value for the equate.
12.2.6.2 equal sign (=)
Defines an equate, assigning an initial value. You can change this value at a later time.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
187
Directives
equate = expression
Parameters
equate
Name of the equate.
expression
Temporary initial value for the equate.
Remarks
This directive is equivalent to
.set
. It is available only for compatibility with assemblers provided by other companies.
12.2.6.3 equ
Defines an equate, assigning a permanent value. You cannot change this value at a later time.
equate .equ expression
Parameters
equate
Name of the equate.
expression
Permanent value for the equate.
12.2.6.4 textequ
Defines a text equate, assigning a string value.
equate .textequ "string"
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
188 Freescale Semiconductor, Inc.
Chapter 12 Assembler
Parameters
equate
Name of the equate.
string
String value for the equate, in double quotes.
Remarks
This directive helps port existing code. You can use it to give new names to machine instructions, directives, and operands.
Upon finding a text equate, the assembler replaces it with the string value before performing any other processing on that source line.
Examples
dc.b .textequ ".byte"
endc .textequ ".endif"
12.2.7 Data Declaration Directives
These directive types initialize data:
•
•
•
12.2.7.1 Integer Directives
These directives let you initialize blocks of integer data:
•
•
•
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
189
Directives
•
•
•
12.2.7.1.1 byte
Declares an initialized block of bytes.
[ label ] .byte expression [ ,expression ]...
Parameters
label
Name of the block of bytes.
expression
Value for one byte of the block; must fit into one byte.
12.2.7.1.2 fill
Declares a block of bytes, initializing each byte to zero.
[ label ] .fill expression
Parameters
label
Name of the block of bytes.
expression
Number of bytes in the block.
12.2.7.1.3 incbin
Tells the assembler to include the binary content of the specified file.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
190 Freescale Semiconductor, Inc.
Chapter 12 Assembler
. incbin filename[,start[,length]]
Parameters
filename
Name of a binary file.
start
Offset from start of file at which to begin including data.
length
Number of bytes of data to include.
Remarks
This directive is useful when you wish to include arbitrary data directly in the program being assembled, e.g.
logoPicture: .incbin "CompanyLogo.jpg"
12.2.7.1.4 long
Declares an initialized block of 32-bit short integers.
[ label ] .long expression [ ,expression ]...
Parameters
label
Name of the block of integers.
expression
Value for 32 bits of the block; must fit into 32 bits.
12.2.7.1.5 short
Declares an initialized block of 16-bit short integers.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
191
Directives
[ label ] .short expression [ ,expression ]...
Parameters
label
Name of the block of integers.
expression
Value for 16 bits of the block; must fit into 16 bits.
12.2.7.1.6 space
Declares a block of bytes, initializing each byte to zero.
[ label ] .space expression
Parameters
label
Name of the block of bytes.
expression
Number of bytes in the block.
12.2.7.2 String Directives
These directives initialize blocks of character data:
•
•
A string can contain any of the escape sequences Table 12-11 lists.
\b
\n
Table 12-11. Escape sequences
Sequence Description
Backspace
Line feed (ASCII character 10)
Table continues on the next page...
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
192 Freescale Semiconductor, Inc.
Chapter 12 Assembler
\r
\t
\"
\\
\nnn
Table 12-11. Escape sequences (continued)
Sequence Description
Return (ASCII character 13)
Tab
Double quote
Backslash
Octal value of \nnn
12.2.7.2.1 ascii
Declares a block of storage for a string; the assembler allocates a byte for each character.
[ label ] .ascii "string"
Parameters
label
Name of the storage block.
string
String value to be stored, in double quotes.
12.2.7.2.2 asciz
Declares a zero-terminated block of storage for a string.
[ label ] .asciz "string"
Parameters
label
Name of the storage block.
string
String value to be stored, in double quotes.
Remarks
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
193
Directives
The assembler allocates a byte for each string
character. The assembler then allocates an extra byte at the end, initializing this extra byte to zero.
12.2.7.3 Floating-Point Directives
These directives initialize blocks of floating-point data:
•
•
12.2.7.3.1 float
Declares an initialized block of 32-bit, floating-point numbers; the assembler allocates 32 bits for each value.
[ label ] .float value [ ,value ]...
Parameters
label
Name of the storage block.
value
Floating-point value; must fit into 32 bits.
12.2.7.3.2 double
Declares an initialized block of 64-bit, floating-point numbers; the assembler allocates 64 bits for each value.
[ label ] .double value [ ,value ]...
Parameters
label
Name of the storage block.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
194 Freescale Semiconductor, Inc.
Chapter 12 Assembler
value
Floating-point value; must fit into 64 bits.
12.2.8 Assembler Control Directives
These directives let you control code assembly:
•
•
•
•
•
•
•
12.2.8.1 align
Aligns the location counter to the next multiple of the specified power of 2.
.align expression
Parameter
expression
Power of 2, such as 2, 4, 8, 16, or 32.
12.2.8.2 endian
Specifies byte ordering for the target processor; valid only for processors that permit change of endianness.
.endian big | little
Parameters
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
195
Directives
big
Big-endian specifier.
little
Little-endian specifier.
12.2.8.3 error
Prints the specified error message to the IDE Errors and Warnings window.
.error "error"
Parameter
error
Error message, in double quotes.
12.2.8.4 include
Tells the assembler to take input from the specified file.
.include filename
Parameter
filename
Name of an input file.
Remarks
When the assembler reaches the end of the specified file, it takes input from the assembly statement line that follows the
.include
directive. The specified file can itself contain an
.include
directive that specifies yet another input file.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
196 Freescale Semiconductor, Inc.
Chapter 12 Assembler
12.2.8.5 pragma
Tells the assembler to use a particular pragma setting as it assembles code.
.pragma pragma-type setting
Parameters
pragma-type
Type of pragma.
setting
Setting value.
12.2.8.6 org
Changes the location-counter value, relative to the base of the current section.
.org expression
Parameter
expression
New value for the location counter; must be greater than the current location-counter value.
Remarks
Addresses of subsequent assembly statements begin at the new expression value for the location counter, but this value is relative to the base of the current section.
Example
In
Listing 12-1 on page 197 , the label
Alpha
reflects the value of
.text + 0x1000
. If the linker places the
.text
section at
0x10000000
, the runtime
Alpha
value is
0x10001000
.
Listing 12-1. Address-Change Example
.text
.org 0x1000
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
197
Directives
Alpha:
...
blr
NOTE
You must use the CodeWarrior IDE and linker to place code at an absolute address.
12.2.8.7 option
Sets an assembler control option as Table 12-12 describes.
.option keyword setting
Parameters
keyword
Control option.
setting
Setting value appropriate for the option: OFF, ON, RESET, or a particular number value.
RESET returns the option to its previous setting.
Table 12-12. Option Keywords
Keyword Description
alignment off | on | reset branchsize 8 | 16 | 32 case off | on | reset colon off | on | reset
Controls data alignment on a natural boundary. Does not correspond to any option of the Assembler settings panel.
Specifies the size of forward branch displacement. Applies only to x86 and
68K assemblers. Does not correspond to any option of the Assembler settings panel.
Specifies case sensitivity for identifiers.
Corresponds to the Case-sensitive identifiers checkbox of the Assembler settings panel.
Specifies whether labels must end with a colon (:). The OFF setting means that you can omit the ending colon from label names that start in the first column.
Table continues on the next page...
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
198 Freescale Semiconductor, Inc.
Chapter 12 Assembler
Table 12-12. Option Keywords (continued)
Keyword
no_at_macros off | on period off | on | reset reorder off | on | reset space off | on | reset
Description
Corresponds to the Labels must end with ':' checkbox of the Assembler settings panel.
Controls $AT use in macros. The OFF setting means that the assembler issues a warning if a macro uses $AT. Applies only to the MIPS Assembler.
Controls period usage for directives. The
ON setting means that each directive must start with a period. Corresponds to the Directives begin with '.' checkbox of the Assembler settings panel.
Controls NOP instructions after jumps and branches. The ON setting means that the assembler inserts a NOP instruction, possibly preventing pipeline problems. The OFF setting means that the assembler does not insert a NOP instruction, so that you can specify a different instruction after jumps and branches. Applies only to the MIPS
Assembler.
Controls spaces in operand fields. The
OFF setting means that a space in an operand field starts a comment.
Corresponds to the Allow space in operand field checkbox of the Assembler settings panel.
12.2.9 Debugging Directives
When you enable the debugger, the assembler automatically generates some debug information for your project. However, you can use these directives in the debug section to provide additional information to the debugger:
•
•
•
•
•
NOTE
These debugging directives are valid only in the
.debug
and
.text
sections of an assembly file. Additionally, you
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
199
Directives
must enable debugging for the file that contains the debugging directives; you use the Project window to enable this debugging.
12.2.9.1 file
Specifies the source-code file; enables correlation of generated assembly code and source code.
.file "filename"
Parameter
filename
Name of source-code file, in double quotes.
Remarks
Must precede other debugging directives in the assembly file. If you write your own
DWARF code, you must use the
.function
and
.line
directives as well as this
.file
directive.
Example
shows how to use the
.file
directive for your own DWARF code.
Listing 12-2. DWARF Code Example
.file "MyFile.c"
.text
.globl _MyFunction
.function "MyFunction",_MyFunction, _MyFunctionEnd -_MyFunction
_MyFunction:
.line 1
lwz r3, 0(r3)
.line 2
blr
_MyFunctionEnd:
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
200 Freescale Semiconductor, Inc.
Chapter 12 Assembler
12.2.9.2 function
Tells the assembler to generate debugging data for the specified subroutine.
.function "func", label, length
Parameters
func
Subroutine name, in double quotes.
label
Starting label of the subroutine.
length
Number of bytes in the subroutine.
12.2.9.3 line
Specifies the absolute line number (of the current source file) for which the assembler generates subsequent code or data.
.line number
Parameter
number
Line number of the file; the file's first line is number 1.
12.2.9.4 size
Specifies a length for a symbol.
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
Freescale Semiconductor, Inc.
201
Изтегляне
Реклама