4 ASSEMBLY LANGUAGE

This chapter contains the following sections:

Input Specification
Assembler Significant Characters
Registers

4.1 Input Specification

An assembly program consists of zero or more statements, one statement per line. A statement may optionally be followed by a comment, which is introduced by a semicolon character (;) and terminated by the end of the input line. Any source statement can be extended to one or more lines by including the line continuation character (\) as the last character on the line to be continued. The length of a source statement (first line and any continuation lines) is only limited by the amount of available memory. Upper and lower case letters are considered equivalent for assembler mnemonics and directives, but are considered distinct for labels, symbols, directive arguments, and literal strings.

A statement can be defined as:

[label[:]] [instruction | directive | macro_call] [; comment]

where,

label is an identifier. A space or tab as the first character on a line indicates that the line has no label. There is, however, one exception: the occurrence of label: (a symbol followed by a colon) defines a label which may be indented. A label starting with an underscore '_' is a local label.

instruction is any valid DSP56xxx assembly language instruction consisting of a mnemonic and one, two, three or no operands and optionally one or two data transfer fields (X and Y parallel move fields). Operands are described in the chapter Operands and Expressions. The instructions are described separately in the chapter Instruction Set.

directive any one of the assembler directives; described separately in the chapter Assembler Directives.

macro_call a call to a previously defined macro. See the chapter Macro Operations.

A statement may be empty.

4.2 Assembler Significant Characters

There are several one and two character sequences that are significant to the assembler. Some have multiple meanings depending on the context in which they are used. Special characters associated with expression evaluation are described in Chapter 5 , Operands and Expressions. Other assembler-significant characters are:

Individual descriptions of each of the assembler special characters follow. They include usage guidelines, functional descriptions, and examples.

;

Comment Delimiter Character

Any number or characters preceded by a semicolon (;), but not part of a literal string, is considered a comment. Comments are not significant to the assembler, but they can be used to document the source program. Comments will be reproduced in the assembler output listing. Comments are preserved in macro definitions.

Comments can occupy an entire line, or can be placed after the last assembler-significant field in a source statement. The comment is literally reproduced in the listing file.

Examples:

; This comment begins in column 1 of the source file
LOOP JSR COMPUTE  ; This is a trailing comment
     ; These two comments are preceded
     ; by a tab in the source file

\

Line Continuation Character or
Macro Dummy Argument Concatenation Operator

Line Continuation

The backslash character (\), if used as the last character on a line, indicates to the assembler that the source statement is continued on the following line. The continuation line will be concatenated to the previous line of the source statement, and the result will be processed by the assembler as if it were a single line source statement. The maximum source statement length (the first line and any continuation lines) is 512 characters.

Example:

; THIS COMMENT \
EXTENDS OVER \
THREE LINES

Macro Argument Concatenation

The backslash (\) is also used to cause the concatenation of a macro dummy argument with other adjacent alphanumeric characters. For the macro processor to recognize dummy arguments, they must normally be separated from other alphanumeric characters by a non-symbol character. However, sometimes it is desirable to concatenate the argument characters with other characters. If an argument is to be concatenated in front of or behind some other symbol characters, then it must be followed by or preceded by the backslash, respectively.

Section 6.5.1 .

Example:

Suppose the source input file contained the following macro definition:

SWAP_REG  MACRO REG1,REG2  ;swap REG2,REG2
    MOVE  R\REG1,X0        ;using X0 as temp
    MOVE  R\REG2,R\REG1
    MOVE  X0,R\REG2
    ENDM

The concatenation operator (\) indicates to the macro processor that the substitution characters for the dummy arguments are to be concatenated in both cases with the character R. If this macro were called with the following statement,

    SWAP_REG  0,1

the resulting expansion would be:

    MOVE  R0,X0
    MOVE  R1,R0
    MOVE  X0,R1

?

Return Value of Symbol Character

The ?symbol sequence, when used in macro definitions, will be replaced by an ASCII string representing the value of symbol. This operator may be used in association with the backslash (\) operator. The value of symbol must be an integer (not floating point).

Section 6.5.2 .

Example:

Consider the following macro definition:

SWAP_SYM    MACRO REG1,REG2  ;swap REG1,REG2
      MOVE  R\?REG1,X0       ;using X0 as temp
      MOVE  R\?REG2,R\?REG1
      MOVE  X0,R\?REG2
      ENDM

If the source file contained the following SET statements and macro call,

AREG  SET       0
BREG  SET       1
      SWAP_SYM  AREG,BREG

the resulting expansion as it would appear on the source listing would be:

      MOVE  R0,X0
      MOVE  R1,R0
      MOVE  X0,R1

%

Return Hex Value of Symbol Character

The %symbol sequence, when used in macro definitions, will be replaced by an ASCII string representing the hexadecimal value of symbol. This operator may be used in associations with the backslash (\) operator. The value of symbol must be an integer (not floating point).

Section 6.5.3 .

Example:

Consider the following macro definition:

GEN_LAB  MACRO  LAB,VAL,STMT
LAB\%VAL STMT
      ENDM

If this macro were called as follows,

NUM   SET     10
      GEN_LAB HEX,NUM,'NOP'

The resulting expansion as it would appear in the listing file would be:

HEXA  NOP

^

Macro Local Label Override

The circumflex (^), when used as a unary operator in a macro expansion, will prevent name mangling of any associated local label. Normally, the macro preprocessor will change any local label inside a macro expansion to a normal label local to the current module. This is done by removing the leading underscore and appending a unique string "_M_Zxxxx" where "xxxx" is a unique sequence number. The ^-operator has no effect on non-local labels or outside of a macro expansion. The ^-operator is useful for passing local labels as macro arguments to be used as referents in the macro. Note that the circumflex is also used as the binary exclusive or operator.

Section 6.5.5 .

Example:

Consider the following macro definition:

LOAD  MACRO ADDR
      MOVE  P:^ADDR,R0
      ENDM

If this macro were called as follows,

_LOCAL
      LOAD  _LOCAL

the assembler would ordinarily issue an error since _LOCAL is not defined within the body of the macro. With the override operator the assembler retains the _LOCAL symbol and uses that value in the MOVE instruction.

"

Macro String Delimiter or
Quoted String DEFINE Expansion Character

Macro String

The double quote ("), when used in macro definitions, is transformed by the macro processor into the string delimiter, the single quote ('). The macro processor examines the characters between the double quotes for any macro arguments. This mechanism allows the use of macro arguments as literal strings.

Section 6.5.4 .

Example:

Using the following macro definition,

CSTR  MACRO   STRING
      DC      "STRING"
      ENDM

and a macro call,

      CSTR    ABCD

the resulting macro expansion would be:

      DC      'ABCD'

Quoted String DEFINE Expansion

A sequence of characters which matches a symbol created with a DEFINE directive will not be expanded if the character sequence is contained within a quoted string. Assembler strings generally are enclosed in single quotes ('). If the string is enclosed in double quotes (") then DEFINE symbols will be expanded within the string. In all other respects usage of double quotes is equivalent to that of single quotes.

Example:

Consider the source fragment below:

    DEFINE  LONG  'short'
STR_MAC     MACRO STRING
    MSG     'This is a LONG STRING'
    MSG     "This is a LONG STRING"
    ENDM

If this macro were invoked as follows,

    STR_MAC sentence

then the resulting expansion would be:

    MSG  'This is a LONG STRING'
    MSG  'This is a short sentence'

@

Function Delimiter

All assembler built-in functions start with the @ symbol. See section 5.4 for a full discussion of these functions.

Example:

SVAL  EQU  @SQT(FVAL)  ; Obtain square root

*

Location Counter Substitution

When used as an operand in an expression, the asterisk represents the current integer value of the runtime location counter.

Example:

      ORG  X:$100
XBASE EQU  *+$20   ; XBASE = $120

++

String Concatenation Operator

Any two strings can be concatenated with the string concatenation operator (++). The two strings must each be enclosed by single or double quotes, and there must be no intervening blanks between the string concatenation operator and the two strings.

Example:

'ABC'++'DEF' = 'ABCDEF'

[]

Substring Delimiter

Square brackets a substring operation. The string argument is the source string. offset is the substring starting position within string. length is the length of the desired substring. string may be any legal string combination, including another substring. An error is issued if either offset or length exceed the length of string.

Example:

DEFINE ID  ['DSP56000',3,5]  ; ID = '56000'

<<

I/O Short Addressing Mode Force Operator

Many DSP instructions allow an I/O short form of addressing. If the value of an absolute address is known to the assembler on pass one, then the assembler will always pick the shortest form of addressing consistent with the instruction format. If the absolute address is not known to the assembler on pass one (that is, the address is a forward or external reference), then the assembler will pick the long form of addressing by default. If this is not desired, then the I/O short form of addressing can be forced by preceding the absolute address by the I/O short addressing mode force operator (<<).

Example:

Since the symbol IOPORT is an external reference in the following sequence of source lines, the assembler would pick the long absolute form of addressing by default:

    BTST    #4,Y:IOPORT
    EXTERN  IOPORT

Because the long absolute addressing mode would cause the instruction to be two words long instead of one word for the I/O short absolute addressing mode, it would be desirable to force the I/O short absolute addressing mode as shown below:

    BTST    #4,Y:<<IOPORT
    EXTERN  IOPORT

<

Short Addressing Mode Force Operator

Many DSP instructions allow a short form of addressing. If the value of an absolute address is known to the assembler on pass one, or the FORCE NEAR directive is active, then the assembler will always pick the shortest form of addressing consistent with the instruction format. If the absolute address is not known to the assembler on pass one (that is, the address is a forward or external reference), then the assembler will pick the long form of addressing by default. If this is not desired, then the short absolute form of addressing can be forced by preceding the absolute address by the short addressing mode force operator (<).

FORCE

Example:

Since the symbol DATAST is an external reference in the following sequence of source lines, the assembler would pick the long absolute form of addressing by default:

    MOVE    Y0,Y:DATAST
    EXTERN  DATAST

Because the long absolute addressing mode would cause the instruction to be two words long instead of one word for the short absolute addressing mode, it would be desirable to force the short absolute addressing mode as shown below:

    MOVE    Y0,Y:<DATAST
    EXTERN  DATAST

>

Long Addressing Mode Force Operator

Many DSP instructions allow a long form of addressing. If the value of an absolute address is known to the assembler on pass one, then the assembler will always pick the shortest form of addressing consistent with the instruction format, unless the FORCE FAR directive is active. If this is not desired, then the long absolute form of addressing can be forced by preceding the absolute address by the long addressing mode force operator (>).

FORCE

Example:

Since the symbol DATAST is known in the following sequence of source lines, the assembler would pick the short absolute form of addressing:

        MOVE  Y0,Y:DATAST
DATAST  EQU   Y:$23

If this is not desirable, then the long absolute addressing mode can be forced as shown below:

        MOVE  Y0,Y:>DATAST
DATAST  EQU   Y:$23

#

Immediate Addressing Mode

The pound sign (#) is used to indicate to the assembler to use the immediate addressing mode.

Example:

CNST  EQU   $5
      MOVE  #CNST,X0

#<

Immediate Short Addressing Mode Force Operator

Many DSP instructions allow a short form of addressing. If the immediate data is known to the assembler on pass one (not a forward or external reference), or the FORCE NEAR directive is active, then the assembler will always pick the shortest form of immediate addressing consistent with the instruction. If the immediate data is a forward or external reference, then the assembler will pick the long form of immediate addressing by default. If this is not desired, then the short form of addressing can be forced using the immediate short addressing mode force operator (#<).

FORCE

Example:

In the following sequence of source lines, the symbol CNST is not known to the assembler on pass one, and therefore, the assembler would use the long immediate addressing form for the MOVE instruction.

      MOVE  #CNST,X0
CNST  EQU   $5

Because the long immediate addressing mode makes the instruction two words long instead of one word for the immediate short absolute addressing mode, it may be desirable to force the immediate short addressing mode as shown below:

      MOVE  #<CNST,X0
CNST  EQU   $5

#>

Immediate Long Addressing Mode Force Operator

Many DSP instructions allow a long immediate form of addressing. If the immediate data is known to the assembler on pass one (not a forward or external reference), then the assembler will always pick the shortest form of immediate addressing consistent with the instruction, unless the FORCE FAR directive is active. If this is not desired, then the long form of addressing can be forced using the immediate long addressing mode force operator (#>).

FORCE

Example:

In the following sequence of source lines, the symbol CNST is known to the assembler on pass one, and therefore, the assembler would use the short immediate addressing form for the MOVE instruction.

CNST  EQU   $5
      MOVE  #CNST,X0

If this is not desirable, then the long immediate form of addressing can be forced as shown below:

CNST  EQU   $5
      MOVE  #>CNST,X0

4.3 Registers

The following register names, either upper or lower case, cannot be used as symbol names in an assembly language source file:

The following registers are used by the assembler in structured control statement processing (Chapter 8 ):


Copyright © 2002 Altium BV