This chapter contains the following sections:
Assembly Significant Characters
Operands
Operands and Addressing Modes
PCP Addressing Modes
Expressions
Numeric Constants
Strings
Expression Operators
Directives and Controls
Overview of Assembler Directives
Overview of Assembler Controls
Macro Operations
Defining a Macro
Calling a Macro
Using Operators for Dummy Arguments
Using the DUP, DUPA, DUPC, and DUPF Directives as Macros
Conditional Assembly: .IF, .ELIF and .ELSE Directives
In this chapter the most important aspects of the TriCore assembly language are described. For a complete overview of the TriCore2 architecture, refer to the TriCore2 Architecture Overview Handbook [2002, Infineon].
An assembly program consists of zero or more statements. A statement may optionally be followed by a comment. Any source statement can be extended to more lines by including the line continuation character (\) as the last character on the line. The length of a source statement (first line and continuation lines) is only limited by the amount of available memory.
Mnemonics and directives are case insensitive. Labels, symbols, directive arguments, and literal strings are case sensitive.
The syntax of an assembly statement is:
[label[:]] [instruction | directive | macro_call] [; comment]
label A label can consist of letters, digits and underscore characters (_). The first character cannot be a digit. A label which is prefixed by whitespace (spaces or tabs) has to be followed by a colon (:). The size of an identifier is only limited by the amount of available memory.
LAB1: ; This label is followed by a colon and can start with a space or tab LAB1 ; This label has to start at the beginning of a line
instruction An instruction consists of a mnemonic and zero, one, two, three, four or five operands. Operands are described in section 4.4, Operands. The instructions are described in the TriCore Architecture Manuals.
ret ; No operand call label ; One operand mov D0,#1 ; Two operands jne D0,#0,loop ; Three operands madd D2,D3,D0,D1 ; Four operands insert D1,D2,#3,#16,#2 ; Five operands
directive With directives you can control the assembler from within the assembly source. Directives are described in section 4.8 , Directives.
macro_call A call to a previously defined macro. Macros are described in section 4.9 Macro Operations.
You can use empty lines or lines with only comments.
Some characters have a special meaning to the assembler. Special characters associated with expression evaluation are described in section 4.6.3, Expression Operators. Other special assembler characters are:
In an instruction, the mnemonic is followed by zero, one, two, three, four or five operands. An operand has one of the following types:
Operands Description
label A label reference as described in section 4.2, Assembly Syntax.
register Any valid register or a register pair, register quad, register extension, register part or special function register.
symbol A symbolic name as described in section 4.5, Symbol Names. Symbols can also occur in expressions.
expression Any valid expression as described in the section 4.6, Expressions.
address A combination of expression, register and symbol.
The TriCore assembly language has several addressing modes. These are listed below with a short description. For details see the TriCore 1 Unified Processor Core v1.3 Architecture Manual, Doc v1.3.3 [2002-09, Infineon]
The instruction uses an 18-bit constant as the memory address. The full 32-bit address results from moving the most significant 4 bits of the 18-bit constant to the most significant bits of the 32-bit address. The other bits are zero filled.
Syntax:
constant18
The effective address is the sum of an address register and the sign-extended 10-bit or 16-bit offset.
Syntax:
[An]offset10
[An]offset16
This addressing mode uses the sum of the address register and the offset both as the effective address and as the value written back into the address register. Use the minus sign for a pre-decrement.
Syntax:
[+An]offset10
This addressing mode uses the value of the address register as the effective address, and then updates this register by adding the sign-extended 10-bit offset to its previous value. Use the minus sign for a post-decrement.
Syntax:
[An+]offset10
This addressing mode is used for accessing data values in circular buffers. It uses an address register pair to hold the state it requires. The even register is always a base address (B). The most-significant half of the odd register is the buffer size (L). The least significant half holds the index into the buffer (I). The effective address is (B+I). The buffer occupies memory from addresses B to B+L-1. The 10-bit offset is specified in the instruction word and is a byte-offset that can be either positive or negative.
Syntax:
[An+c]offset10
Bit reverse addressing is used to access arrays used in FFT algorithms. Bit-reverse addressing uses an address register pair to hold the required state. The even register is the base address of the array (B), the least-significant half of the odd register is the index into the array (I), and the most-significant half is the modifier (M) which is added to I after every access. The effective address is B+reverse(I). The reverse() function exchanges bit n with bit (15-n) for n = 0, ..., 7. The index, I, is post-incremented and its new value is (I + M), where M is the most significant half of the odd register.
Syntax:
[An+r]
The indexed addressing mode uses an address register pair to hold the required state. The Aeven register is the base address of the array (B). The Aodd register is divided equally between the index into the array (I), and the modifier (N) which is added to I after every access.
All load (LD.xxx) instructions, all store(ST.xxx except ST.T) instructions, the load/modify/store (SWAP.W,LDMST) instructions and the cache management (CACHEA.xxx) instructions are able to use the indexed addressing mode.
Syntax:
[Aa/Ab+i]
ld.w d0,[a0/a1+i] ; load word indexed addressing mode st.w [a2/a3+i],d0 ; store word indexed addressing mode
The PCP assembly language has several addressing modes. These addressing modes are used for FPI addressing, PRAM data indirect addressing or flow control destination addressing. For details see the PCP/DMA Architecture manual from Siemens.
A symbol can consist of letters, digits and underscore characters (_). The first character cannot be a digit. The size of an identifier is limited to 4000 characters.
Symbol names and other identifiers beginning with a period (.) are reserved for the system. Names of assembler directives are also reserved.
The following symbols are predefined:
Symbol | Description |
__ASTC__ | Contains the name of the assembler ("astc") |
__ASPCP__ | Contains the name of the PCP assembler ("aspcp") |
__FPU__ | Defined when you use assembler option --fpu-present (allow use of FPU instructions) |
__MMU__ | Defined when you use assembler option --mmu-present (allow use of MMU instructions) |
__TC2__ | Defined when you use assembler option --is-tricore2 (allow use of TriCore 2 instructions) |
Table 4-1: Predefined symbols
Valid symbol names | Invalid symbol names |
loop_1 ENTRY a_B_c _aBC |
1_loop (starts with a number) loop.e (reserved name) .loop (reserved name) |
An expression is a combination of symbols, constants, operators, and parentheses which represent a value that is used as an operand of an assembler instruction (or directive).
Expressions can contain user-defined labels (and their associated integer or floating-point values), and any combination of integers, floating-point numbers, or ASCII literal strings.
Expressions follow the conventional rules of algebra and boolean arithmetic.
Expressions that can be evaluated at assembly time are called absolute expressions. Expressions where the result is unknown until all sections have been combined and located, are called relocatable or relative expressions.
When any operand of an expression is relocatable, the entire expression is relocatable. Relocatable expressions are emitted in the object file and are evaluated by the linker. Relocatable expressions can only contain integral functions; floating point functions and numbers are not supported by the ELF/DWARF object format. An error is emitted when during object creation non-ELF/DWARF relocatable expressions are found.
The assembler evaluates expressions with 64-bit precision in two's complement.
The syntax of an expression can be any of the following:
- numeric contant
- string
- symbol
- expression binary_operator expression
- unary_operator expression
- ( expression )
- function call
All types of expressions are explained below and in the following sections.
( ) You can use parentheses to control the evaluation order of the operators. What is between parentheses is evaluated first.
Numeric constants can be used in expressions. If there is no prefix, the assembler assumes the number is a decimal number.
Base | Description | Example |
Binary | '0B' or '0b' followed by binary digits (0,1). |
0B1101 0b11001010 |
Hexadecimal | '0X' or '0x' followed by a hexadecimal digits (0-9, A-F, a-f). |
0X12FF 0x45 0x9abc |
Decimal, integer | Decimal digits (0-9). |
12 1245 |
Decimal, floating point | Includes a decimal point, or an 'E' or 'e' followed by the exponent. |
6E10 .6 2.7e10 |
ASCII characters, enclosed in single (') or double (") quotes constitue a literal ASCII string. Both type of strings can contain escape characters.
Strings constants in expressions are evaluated to a number. Strings in expressions can have the size of a long word (first 4 characters); any subsequent characters in the string are ignored. In this case the assembler issues a warning. An exception to this rule is when a string longer than 4 characters is used in a .BYTE assembler directive; in that case all characters result in a constant byte. Null strings have a value of 0.
Square brackets ([ ]) delimit a substring operation in the form:
offset is the start position within string. length is the length of the desired substring. Both values may not exceed the size of string.
'ABCD' ; ($41424344)
'''79' ; to enclose a quote double it
"A\"BC" ; or to enclose a quote escape it
'A'+1 ; ($00000042)
'' ; null string
'abcdef' ; ($61626364)
'abc'++'de' ; you can concatenate ; two strings with the '++' operator. ; This results in 'abcde'
['TriCore',0,3] ; results in the substring 'Tri'
The next table shows the assembler operators. They are ordered according to their precedence. Operators of the same precedence are evaluated left to right. Expressions between parentheses have the highest priority (innermost first).
Valid operands include numeric constants, literal ASCII strings and symbols.
Most assembler operators can be used with both integer and floating-point values. If one operand has an integer value and the other operand has a floating-point value, the integer is converted to a floating-point value before the operator is applied. The result is a floating-point value.
Type | Operator | Name | Description |
( ) | parentheses | Expressions enclosed by parenthesis are evaluated first. | |
Unary | + | plus | Returns the value of its operand. |
- | minus | Returns the negative of its operand. | |
~ | complement | Returns complement, integer only | |
! | logical negate | Returns 1 if the operands' value is 1; otherwise 0. For example, if buf is 0 then !buf is 1. | |
Arithmetic | * | multiplication | Yields the product of two operands. |
/ | division |
Yields the quotient of the division of the first operand by the second. With integers, the divide operation produces a truncated integer. | |
% | mod |
Used with integers: yields the remainder from a division of the first operand by the second.
Used with floats: Y%Z = Y if Z= 0 Y%Z = Y-(integer*Z) | |
+ | addtion | Yields the sum of its operands. | |
- | subtraction | Yields the difference of its operands. | |
Shift | << | shift left | Integer only: shifts the left operand to the left (zero-filled) by the number of bits specified by the right operand. |
>> | shift right | Integer only: shifts the left operand to the right (sign bit extended) by the number of bits specified by the right operand. | |
Relational | < <= > >= == != | less than less or equal more than mor or equal equal not equal | If the indicated condition is: - True: result is an integer 1 - False: result is an integer 0 Be cautious when you use floating point values in an equality test; rounding errors can cause unexpected results. |
Bitwise | & | AND | Integer only: yields bitwise AND |
| | OR | Integer only: yields bitwise OR | |
^ | exclusive OR | Integer only: yields bitwise exlusive OR | |
Logical | && | logical AND | Returns an integer 1 if both operands are nonzero; otherwise, it returns an integer 0. |
|| | logical OR | Returns an integer 1 if either of the operands is nonzero; otherwise, it returns an integer 1 |
Table 4-2: Assembly expression operators
The assembler has several built-in functions to support data conversion, string comparison, and math computations. You can use functions as terms in any expression. Functions have the following syntax:
Functions start with the '@' character and have zero or more arguments, and are always followed by opening and closing parentheses. White space (a blank or tab) is not allowed between the function name and the opening parenthesis and between the (comma-separated) arguments.
The built-in assembler functions are grouped into the following types:
The following tables provide an overview of all built-in assembler functions. For a detailed description of these functions, see section 3.2, Built-in Assembly Functions, in Chapter Assembly Language of the Reference Guide.
Function | Description |
@ABS(expr) | Absolute value |
@ACS(expr) | Arc cosine |
@ASN(expr) | Arc sine |
@AT2(expr1,expr2) | Arc tangent |
@ATN(expr) | Arc tangent |
@CEL(expr) | Ceiling function |
@COH(expr) | Hyperbolic cosine |
@COS(expr) | Cosine |
@FLR(expr) | Floor function |
@L10(expr) | Log base 10 |
@LOG(expr) | Natural logarithm |
@MAX(expr,[,...,exprN]) | Maximum value |
@MIN(expr,[,...,exprN]) | Minimum value |
@POW(expr1,expr2) | Raise to a power |
@RND() | Random value |
@SGN(expr) | Returns the sign of an expression as -1, 0 or 1 |
@SIN(expr) | Sine |
@SNH(expr) | Hyperbolic sine |
@SQT(expr) | Square root |
@TAN(expr) | Tangent |
@TNH(expr) | Hyperbolic tangent |
@XPN(expr) | Exponential function (raise e to a power) |
Function | Description |
@CVF(expr) | Convert integer to floating-point |
@CVI(expr) | Convert floating-point to integer |
@FLD(base,value, width[,start]) | Shift and mask operation |
@FRACT(expr) | Convert floating-point to 32-bit fractional |
@SFRACT(expr) | Convert floating-point to 16-bit fractional |
@LNG(expr) | Concatenate to double word |
@LUN(expr) | Convert long fractional to floating-point |
@RVB(expr1[,expr2]) | Reverse order of bits in field |
@UNF(expr) | Convert fractional to floating-point |
@LSB(expr) | Get least significant byte of a word |
@MSB(expr) | Get most significant byte of a word |
Function | Description |
@CAT(str1,str2) | Concatenate strings |
@LEN(string) | Length of string |
@POS(str1,str2[,strt]) | Position of substring in string |
@SCP(str1,str2) | Returns 1 if two strings are equal |
@SUB(str1,expr,expr) | Returns substring in string |
Function | Description |
@ARG({symbol|expr}) | Test if macro argument is present |
@CNT() | Return number of macro arguments |
@MAC(symbol) | Test if macro is defined |
@MXP() | Test if macro expansion is active |
Function | Description |
@HI(expr) | Returns upper 16 bits of expression value |
@HIS(expr) | Returns upper 16 bits of expression value, adjusted for signed addition |
@LO(expr) | Returns lower 16 bits of expression value |
@LOS(expr) | Returns lower 16 bits of expression value, adjusted for signed addition |
Function | Description |
@ASPCP() | Returns the name of the pcp assembler executable |
@ASTC() | Returns the name of the assembler executable |
@CPU(string) | Test if CPU type is selected |
@DEF(symbol) | Returns 1 if symbol has been defined |
@EXP(expr) | Expression check |
@INT(expr) | Integer check |
@LST() | LIST control flag value |
An assembler directive is simply a message to the assembler. Assembler directives are not translated into machine code because they are not instructions. There are three types of assembler directives.
Assembler directives are grouped in the following categories:
Assembler controls are grouped in the following categories:
Each assembler directive or control has its own syntax. You can use assembler directives and controls in the assembly code as pseudo instructions.
The following tables provide an overview of all assembler directives. For a detailed description, see section 3.3.2 , Detailed Description of Assembler Directives, in Chapter Assembly Language of the Reference Guide.
Directive | Description |
.COMMENT | Start comment lines. You cannot use this directive in .IF/.ELSE/.ENDIF constructs and .MACRO/.DUP definitions. |
.DEFINE | Define substitution string |
.END | End of source program |
.FAIL | Programmer generated error message |
.INCLUDE | Include secondary file |
.MESSAGE | Programmer generated message |
.NAME | Identification for object file (instead of file name) |
.ORG | Initialize memory space and location counters to create a nameless section |
.SDECL | Declare a section with name, type and attributes |
.SECT | Activate a declared section |
.UNDEF | Undefine .DEFINE symbol |
.WARNING | Programmer generated warning |
Function | Description |
.EQU | Assigns permanent value to a symbol |
.EXTERN | External symbol declaration |
.GLOBAL | Global symbol declaration |
.LOCAL | Local symbol declaration |
.SET | Set temporary value to a symbol |
.SIZE | Set size of symbol in the ELF symbol table |
.TYPE | Set symbol type in the ELF symbol table |
Function | Description |
.ALIGN | Define alignment |
.ACCUM | Define 64-bit constant in 18 + 46 bits format |
.ASCII / .ASCIIZ | Define ASCII string without / with ending NULL byte |
.BYTE | Define constant byte |
.FLOAT / .DOUBLE | Define a 32-bit / 64-bit floating point constant |
.FRACT / .SFRACT | Define a 16-bit / 32-bit constant fraction |
.SPACE | Define storage |
.WORD / .HALF | Define a word / half-word constant |
Function | Description |
.DUP | Duplicate sequence of source lines |
.DUPA | Duplicate sequence with arguments |
.DUPC | Duplicate sequence with characters |
.DUPF | Duplicate sequence in loop |
.ENDM | End of macro or duplicate sequence |
.EXITM | Exit macro |
.IF/.ELIF/.ELSE/.ENDIF | Conditional assembly |
.MACRO | Define macro |
.PMACRO | Purge macro definition |
Function | Description |
.CALLS | Passes call information to object file. Used by the linker to build a call graph. |
.SYMB | Passes debug information to object file. Used by CrossView Pro for debugging. |
The following tables provide an overview of all assembler controls. For a detailed description, see section 3.3.4 , Detailed Description of Assembler Controls, in Chapter Assembly Language of the Reference Guide.
Function | Description |
$LIST ON/OFF | Generation of assembly list file temporary ON/OFF |
$LIST "flags" | Exclude / include lines in assembly list file |
$PAGE | Generate formfeed in assembly list file |
$PAGE settings | Define page layout for assemly list file |
Specify alternative name for assembly list file | |
$NOPRINT | Disable list file generation |
$PRCTL | Send control string to printer |
$STITLE | Set program subtitle in header of assembly list file |
$TITLE | Set program title in headerof assembly list file |
Function | Description |
$CASE ON/OFF | Case sensitive user names ON/OFF |
$DEBUG ON/OFF | Generation of symbolic debug ON/OFF |
$DEBUG "flags" | Generation of symbolic debug ON/OFF |
$FPU | Allow single precision floating point instructions |
$HW_ONLY | Prevent substitution of assembly instructions by smaller or faster instructions |
$IDENT LOCAL/GLOBAL | Assembler treats labels by default as local or global |
$MMU | Allow memory management instructions |
$OBJECT | Alternative name for the generated object file |
$TCdefect ON/OFF | Enable/disable assembler check for specified functional problem |
$TC2 | Allow TriCore 2 instructions |
$WARNING OFF [num] | Suppress one or all warnings |
Macros provide a shorthand method for handling a repeated pattern of code or group of instructions. Yuo can define the pattern as a macro, and then call the macro at the points in the program where the pattern would repeat.
Some patterns contain variable entries which change for each repetition of the pattern. Others are subject to conditional assembly for a given occurrence of the instruction group. In either case, macros provide a shorthand notation for handling these instruction patterns.
When a macro is called, the assembler generates in-line source statements. The generated statements may contain substitutable arguments. The statements produced by a macro can be any processor instruction, almost any assembler directive, or any previously-defined macro. Source statements resulting from a macro call are subject to the same conditions and restrictions as any other statements.
The assembler is able to process nested macro calls at expansion time only. However, the nested macro definition is not processed until the primary macro is expanded.
The first step in using a macro is to define it in the source file. The definition of a macro consists of three parts:
A macro definition takes the following form:
Header: macro_name .MACRO [dumarg[,dumarg...] [; comment]
.
Body: source statements
.
Terminator: .ENDM
If the macro name is the same as an existing assembler directive or mnemonic opcode, the assembler replaces the directive or mnemonic opcode with the macro and issues a warning. This replacement does not occur for definitions from macro libraries.
The dummy arguments are symbolic names that the macro processor replaces with the literal arguments when the macro is expanded (called). Each dummy argument must follow the same rules as global symbol names. Dummy argument names cannot start with an underscore (_).
The macro definition:
CONSTD .MACRO reg,value ;header mov.u reg,#lo(value) ;body addih reg,reg,#hi(value) .ENDM ;terminator
The macro call:
.SDECL "data",DATA .SECT "data"
CONSTD d4,0x12345678
.END
The macro expands as follows:
mov.u d4,#lo(0x12345678) addih d4,d4,#hi(0x12345678)
To invoke a macro, construct a source statement with the following format:
[label] macro_name [arg[,arg...]] [; comment]
where:
label An optional label that corresponds to the value of the location counter at the start of the macro expansion.
macro_name The name of the macro. This must be in the operation field.
arg One or more optional, substitutable arguments. Multiple arguments must be separated by commas.
comment An optional comment.
The following applies to macro arguments:
- enter delimiting commas in succession with no intervening spaces
- terminate the argument list with a comma, the arguments that normally would follow, are now considered null
- declare the argument as a null string
The assembler recognizes certain text operators within macro definitions which allow text substitution of arguments during macro expansion. You can use these operators for text concatenation, numeric conversion, and string handling.
Operator | Name | Description |
\ | Macro argument concatenation | Concatenates a macro dummy argument with adjacent alphanumeric characters. |
? | Return decimal value of symbol | Substitutes the ?symbol sequence with a character string that represents the decimal value of the symbol. |
% | Return hex value of symbol | Substitutes the ?symbol sequence with a character string that represents the hexadecimal value of the symbol. |
" | Macro string delimiter | Allows the use of macro arguments as literal strings. |
^ | Macro local label override | Causes local labels in its term to be evaluated at normal scope rather than at macro scope. |
Consider the following macro definition:
SWAP_MEM .MACRO REG1,REG2 ;swap memory contents LD.W D0,[A\REG1] ;use D0 as temp LD.W D1,[A\REG2] ;use D1 as temp ST.W [A\REG1],D1 ST.W [A\REG2],D0 .ENDM
The macro is called as follows:
SWAP_MEM 0,1
The macro expands as follows:
LD.W D0,[A0] LD.W D1,[A1] ST.W [A0],D1 ST.W [A1],D0
The macro processor would substitutes the character '0' for the dummy argument REG1, and the character '1' for the dummy argument REG2. The concatenation operator (\) indicates to the macro processor that the substitution characters for the dummy arguments are to be concatenated with the character 'A'.
Instead of substituting the dummy arguments with the macro call arguments, you can also use the value of the macro call arguments.
Consider the following source code that calls the macro SWAP_SYM after the argument AREG has been set to 0 and BREG has been set to 1.
AREG .SET 0 BREG .SET 1 SWAP_SYM AREG,BREG
If you want to replace the dummy arguments with the value of AREG and BREG rather than with the literal strings 'AREG' and 'BREG', you can use the ? operator and modify the macro as follows:
SWAP_SYM .MACRO REG1,REG2 ;swap memory contents LD.W D0,_lab\?REG1 ;use D0 as temp LD.W D1,_lab\?REG2 ;use D1 as temp ST.W _lab\?REG1,D1 ST.W _lab\?REG2,D0 .ENDM
The macro first expands as follows:
LD.W D0,_lab\?AREG LD.W D1,_lab\?BREG ST.W _lab\?AREG,D1 ST.W _lab\?BREG,D0
Then ?AREG is replaced by '0' and ?BREG is replaced by '1':
LD.W D0,_lab\1 LD.W D1,_lab\2 ST.W _lab\1,D1 ST.W _lab\2,D0
Finally, the strings are concatenated because of the '\' operator '\':
LD.W D0,_lab1 LD.W D1,_lab2 ST.W _lab1,D1 ST.W _lab2,D0
The percent sign (%) is similar to the standard decimal value operator except that it returns the hexadecimal value of a symbol.
Consider the following macro definition:
GEN_LAB .MACRO LAB,VAL,STMT LAB\%VAL STMT .ENDM
A symbol with the name NUM is set to 10 and the macro is called with NUM as argument:
NUM .SET 10 GEN_LAB HEX,NUM,NOP
The macro expands as follows:
HEXA NOP
The %VAL dummy argument is replaced by the character 'A' which represents the hexadecimal value 10 of the dummy argument VAL.
To generate a literal string, enclosed by single quotes ('), you must use the argument string operator (") in the macro definition.
Consider the following macro definition:
STR_MAC .MACRO STRING .BYTE "STRING" .ENDM
The macro is called as follows:
STR_MAC ABCD
The macro expands as follows:
.BYTE 'ABCD'
Within double quotes .DEFINE directive definitions can be expanded. Take care when using constructions with quotes and double quotes to avoid inappropriate expansions. Since a .DEFINE expansion occurs before a macro substitution, all .DEFINE symbols are replaced first within a macro dummy argument string:
DEFINE LONG 'short' STR_MAC .MACRO STRING .MESSAGE 'This is a LONG STRING' .MESSAGE "This is a LONG STRING" ENDM
If the macro is called as follows:
STR_MAC sentence
The macro expands as:
.MESSAGE 'This is a LONG STRING' .MESSAGE 'This is a short sentence'
Single quotes prevent expansion so the first .MESSAGE is not stated as is. In the double quoted .MESSAGE, first the define LONG is expanded to 'short' and then the argument STRING is substituted by 'sentence'.
The macro ^-operator prevents name mangling on the ADDR argument if the argument has a leading underscore. If there is no leading underscore on the actual argument the the ^-operator has no effect.
Consider the following macro definition:
LOAD .MACRO ADDR LD.W D0,^ADDR .ENDM
The macro is called as follows:
_LOCAL LOAD _LOCAL
The macro expands as:
_LOCAL LD.W D0,_LOCAL
Without the ^ operator, the macro processor would choose another name for _LOCAL because the label already exists. The macro then would expand like:
_LOCAL LD.W D0,_LOCAL_M_0
The .DUP, .DUPA, .DUPC, and .DUPF directives are specialized macro forms. You can think of them as a simultaneous definition and call of an unnamed macro. The source statements between the .DUP, .DUPA, .DUPC, and .DUPF directives and the .ENDM directive follow the same rules as macro definitions.
For a detailed description of these
directives, see section 3.3, Assembler Directives, in Chapter Assembly Language of the Reference
Guide.
With the conditional assembly directives you can create a part of conditional assembly code. The assembler assembles only the code that it reaches.
You can specify assembly conditions with arguments in the case of macros, or through definition of symbols via the .DEFINE, .SET, and .EQU directives.
The built-in functions of the assembler provide a versatile means of testing many conditions of the assembly environment
You can use conditional directives also within a macro definition to check at expansion time if arguments fall within a certain range values. In this way macros become self-checking and can generate error messages to any desired level of detail.
The conditional assembly directive .IF has the following form:
.IF expression . . [.ELSE] ;(the .ELSE directive is optional) . . [.ELIF] ;(the .ELIF directive is optional) . . .ENDIF
The expression must evaluate to an absolute integer and cannot contain forward references. If expression evaluates to zero, the .IF-condition is considered FALSE. Any non-zero result of expression is considered as TRUE.
For a detailed description of these
directives, see section 3.3, Assembler Directives, in Chapter Assembly Language of the Reference
Guide.