Assembler Directives. NXP CodeWarrior Development Studio
تبلیغات
تبلیغات
Chapter 20 Inline-Assembly for AIOP Build Tools
You also can use the top or bottom half-word of an immediate word value as an immediate operand by using one of the @ modifiers (
).
Listing 20-11. Example of referring to immediate operands
long gTheLong; asm void red(void)
{
fralloc
lis r6, gTheLong@ha
addi r6, r6, gTheLong@h
lis r7, gTheLong@h
ori r7, br7, gTheLong@l
frfree
blr
}
The access patterns are:
lis x,var@ha
la x,var@l(x) or
lis x,var@h
ori x,x,var@l
In this example, la
is the simplified form of addi
to load an address. The instruction las
is similar to la
but shifted.
Using
@ha
is preferred since you can write:
lis x,var@ha
lwz v,var@l(x)
You cannot do this with
@h
because it requires that you use the ori
instruction.
20.3 Assembler Directives
This section describes some special assembler directives that the AIOP built-in assembler accepts. These directives are:
•
•
•
•
CodeWarrior Development Studio for Advanced Packet Processing Build Tools Reference Manual, Rev.
10.2, 01/2016
Freescale Semiconductor, Inc.
343
Assembler Directives
•
•
20.3.1 entry
Defines an entry point into the current function.
entry [ extern | static ]
name
Use the extern
qualifier to declare a global entry point; use the static
qualifier to declare a local entry point. If you leave out the qualifier, extern
is assumed.
NOTE
Inline-assembly directive entry
can be used only with Functionlevel assembly code.
Listing 20-12 on page 344 shows how to use the
entry
directive.
Listing 20-12. Using the entry directive
void __save_fpr_15(void); void __save_fpr_16(void); asm void __save_fpr_14(void)
{
stfd fp14,-144(SP)
entry __save_fpr_15
stfd fp15,-136(SP)
entry __save_fpr_16
stfd fp16,-128(SP)
// ...
blr
}
20.3.2 fralloc
Creates a stack frame for a function and reserves registers for local register variables.
fralloc [ number ]
You need to create a stack frame for a function if the function:
• calls other functions.
• uses more arguments than will fit in the designated parameters
(r3
- r10
, fp1
- fp8
).
• declares local registers.
• declares non-registered parameters.
CodeWarrior Development Studio for Advanced Packet Processing Build Tools Reference Manual, Rev.
10.2, 01/2016
344 Freescale Semiconductor, Inc.
Chapter 20 Inline-Assembly for AIOP Build Tools
The fralloc
directive has an optional argument number that lets you specify the size in bytes of the parameter area of the stack frame. The compiler creates a 0-byte parameter area. If your assembly language routine calls any function that requires more parameters than will fit in r3
- r10
and fp1
- fp8
, you must specify a larger amount.
20.3.3 frfree
Frees a function's stack frame and restores local register variables.
frfree
This directive frees the stack frame and restores the registers that fralloc
reserved.
The frfree
directive does not generate a blr
instruction. If your function uses functionlevel inline assembly, you must explicitly terminate it with this instruction.
20.3.4 machine
Specifies the processor that the assembly language targets.
machine
number
The value of number must be one of those listed in the table below.
505 all
509 generic
Table 20-1. CPU Identifiers
555 56x
If you use generic
, the compiler supports the core instructions for the 603, 604, 740, and
750 processors. In addition, the compiler supports all optional instructions.
If you use all
, the compiler recognizes assembly instructions for all core and optional instructions for all AIOP processors.
If you do not use the machine
directive, the compiler uses the settings you selected from the Processor listbox of the Processor settings panel.
CodeWarrior Development Studio for Advanced Packet Processing Build Tools Reference Manual, Rev.
10.2, 01/2016
Freescale Semiconductor, Inc.
345
Assembler Directives
20.3.5 nofralloc
Specifies that the function will build a stack frame explicitly.
nofralloc
Use the nofralloc
directive so that an inline assembly function does not build a stack frame. When you use nofralloc
, if you have local variables, parameters or make function calls, you are responsible for creating and deleting your own stack frame. For an example of nofralloc
, see the file
__start.c
in the directory:
InstallDir
LS\AIOP_Support\ewl\EWL_Runtime\Runtime_AIOP\Source where InstallDir is the name of the directory on your host computer where you installed your CodeWarrior development tools.
20.3.6 opword
Inserts raw bytes into the object code.
opword
value
This directive inserts value into the object code. For example opword 0x7C0802A6 is equivalent to mflr r0
The compiler does not check the validity of value ; the compiler simply copies it into the object code that it generates.
20.3.7 equ
Sets the value of symbol to expression.
equ
symbol, expression
For example
CodeWarrior Development Studio for Advanced Packet Processing Build Tools Reference Manual, Rev.
10.2, 01/2016
346 Freescale Semiconductor, Inc.
دانلود
تبلیغات