Home
Table of Contents (Continued)
Contents
1. D 5 2 9 Alternate Encoding Function ENC The ENC provides two encoding expressions for the same instruction This is useful in cases where the unknown value of an external operand can affect which expression is used for the final encoding The function takes four arguments The first argument to the function is the external operand expression The second argument is the absolute value beyond which the second encoding expression is used over the first The third argument is the first encoding expression and the last argument is the second encoding expression Freescale DSP Assembler Reference Manual 265 Appendix D Freescale DSP Object File Format COFF Object File Data Expression For 266 DSP Assembler Reference Manual Freescale Appendix E Instruction Set Information E 1 DSP56300 Information The Freescale DSP56300 refers to a family of high speed low power programmable CMOS processors The DSP56300 supports 24 bit signed fixed point fractional arith metic E 1 1 Instruction Set Summary DSP56300 instructions can be grouped by function into six types Arithmetic instructions Logical instructions Bit manipulation instructions Loop instructions Move instructions Program control instructions oar wh E 1 1 1 Arithmetic Instructions The DSP56300 instructions used for arithmetic operations are ABS Absolute value ADC Add long with carry ADD Add ADDL Shift left then add ADD
2. W Warning 142 188 Freescale DSP Assembler Reference Manual 279
3. 2 1 TOUT TIS en 11 2 2 SYMPA E Lu EE 11 2 3 le E 11 2 4 So rce Statement MOMMA EE 12 2 4 1 Label Field Geet deenen ee Eeer Etgen 13 2 4 2 Operation GE 14 2 4 3 OPStand FICC EE 14 2 4 4 Data Transfer Ee 14 2 4 5 Comment Ee Ae eege ee 15 2 5 EECHER A E 15 Freescale DSP Assembler Reference Manual v 3 1 3 2 3 3 3 4 3 5 3 5 1 3 5 2 3 6 3 6 1 3 6 2 3 6 3 3 6 4 3 6 5 3 6 6 3 7 3 8 3 8 1 3 8 2 3 8 3 3 8 4 3 8 5 4 1 4 2 4 3 4 3 1 4 3 2 4 3 3 4 4 vi Table of Contents continued Chapter 3 Expressions attze ie ed DE 17 Absolute and Relative Expressions AAR 17 Expression Memory Space Attribute cccccsscsseceeeeeeeeeeeeeeeeeeseeeeeeseeeeees 17 Internal Expression Representation EE 19 OMS IANS erter 19 Numeric e 19 String CONSENS fos eege eege naaa iaie 20 CDS AON eelere 20 U ary EES 20 a dg deele ee 21 le ie 21 Relational eer 22 Bitwise OP GALOIS oi js5 edendenEE Eeer ee EE edel 22 ee eelere 22 Operator PROCOUGMCE EE 23 lte die GE 23 Mathematical Functions EEN 24 Conversion PUNCIONS c cceetoesecus ets tenenenhenssattaishctatoeaancseadetnaiehensitss 25 ale Ree EE 25 Macro FUNCIONS EE 25 Assembler Mode Funchons ek 26 Chapter 4 Software Project Management Lett geleed seater eliotn al iene ld ei ener ety ho ae aie 37 Ee EE E EE setae ees ee seats 37 Sections and Data Hiding usA 38 Sections and SY MDOIS ose fees Deg 38 SOCOMS ANG EE eebe eege tege sehen feet A0 Nested and Fragment
4. BREAK causes exit from WHILE loop END any instructions here are skipped ENDW execution resumes here after _BREAK 7 3 2 CONTINUE Statement SYNTAX CONTINUE FUNCTION The CONTINUE statement causes the next iteration of a looping construct WHILE REPEAT FOR LOOP to begin This means that the loop ex pression or operand comparison is performed immediately bypassing any subsequent instructions NOTES If a CONTINUE is encountered with no loop statement active a warning is issued Freescale DSP Assembler Reference Manual 169 Chapter 7 Structured Control Statements Syntax CONTINUE should be used with care near ENDL directives or near the end of DO loops It generates a jump instruction which is illegal in those contexts One or more CONTINUE directives inside a LOOP construct will generate a NOP instruction just before the loop address EXAMPLE REPEAT AF lt cs gt CONTINUE causes immediate jump to UNTIL END any instructions here are skipped LUNTIL x r1 lt EQ gt 0 evaluation here after CONTINUE 7 3 3 FOR Statement SYNTAX FOR lt op1 gt lt op2 gt TO DOWNTO lt op3 gt BY lt op4 gt DO lt stmtlist gt ENDF FUNCTION Initialize lt op1 gt to lt op2 gt and perform lt stmtlist gt until lt op1 gt is greater TO or less than DOWNTO lt op3 gt Makes use of a user defined operand lt op1 gt to serve as aloop counter FOR TO allows counting upward
5. Just like the FORCE pseudo op errors can result if a value is too large to be forced short For relocatable code the error may not occur until the linking phase See also FORCE SCSREG A label is not allowed with this directive EXAMPLE SCSJMP SHORT force all subsequent SCS jumps short Freescale DSP Assembler Reference Manual 153 Chapter 6 Assembler Significant Characters and Directives Assembler Directives SCSREG Reassign Structured Control Statement Registers SCSREG __ lt srcreg gt lt dstreg gt lt tmpreg gt lt extreg gt The SCSREG directive reassigns the registers used by structured control statement SCS directives see Chapter 7 It is convenient for reclaiming default SCS registers when they are needed as application operands within a structured control construct lt sr creg gt is ordinarily the source register for SCS data moves lt dstreg gt is the destination register lt tmpreg gt is a temporary register for swapping SCS operands lt extreg gt is an extra register for complex SCS operations With no arguments SCSREG resets the SCS registers to their default assignments The SCSREG directive should be used judiciously to avoid register context errors during SCS expansion Source and destination registers may not necessarily be used strictly as source and destination operands The assembler does no checking of reassigned regis ters beyond validity for the target processor Errors can result wh
6. CIRCULAR BUFFER MOD 24 M_BUF DC 0 5 0 5 0 5 0 5 DS 20 REMAINDER UNINITIALIZED ENDBUF Freescale DSP Assembler Reference Manual 95 Chapter 6 Assembler Significant Characters and Directives Assembler Directives COBJ Comment Object File COBJ lt string gt The COB directive is used to place a comment in the object code file The lt string gt will be put in the object file as a comment refer to the object format description in Appendix D A label is not allowed with this directive See also IDENT EXAMPLE COBJ Start of filter coefficients 96 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives COMMENT Start Comment Lines COMMENT lt delimiter gt lt delimiter gt The COMMENT directive is used to define one or more lines as comments The first non blank character after the COMMENT directive is the comment delimiter The two delimit ers are used to define the comment text The line containing the second comment delim iter will be considered the last line of the comment The comment text can include any printable characters and the comment text will be reproduced in the source listing as it ap pears in the source file A label is not allowed with this directive EXAMPLE COMMENT This is a one line comment COMMENT This is a multiple line comment Any number of lines can be placed between the two delimiters Freescal
7. Chapter 5 Macro Operations and Conditional Assembly Macro Calls When specifying a local label within the body of a macro the programmer must be aware that the label symbol is valid for the entire body of the current level of macro expansion It is not valid for any nested macros within the current level of expansion The example above shows why the local label feature is useful If the macro N_R_MUL were called several times there would be several _ENDLOOP labels resulting from the macro expan sions This is acceptable because each _ENDLOOP label is considered private to a par ticular instance of macro expansion It is sometimes desirable to pass local labels as macro arguments to be used within the macro as address references e g MOVE _LABEL RO The assembler effectively dis allows this however since underscore label references within a macro invocation are re garded as labels local to that expansion of the macro A macro local label override is provided which causes local symbol lookup to have normal scope rather than macro call scope If a circumflex precedes an expression containing an underscore label at ex pansion the associated term will be evaluated using the normal local label list rather than the macro local label list The operator has no effect on normal labels or outside a macro expansion 5 4 Macro Calls When a macro is invoked the statement causing the action is termed a macro call The syntax of a macro call
8. HSINE EQU SNH VAL hyperbolic sine SQT lt expression gt Returns the square root of lt expression gt as a floating point value lt expression gt must be positive The memory space attribute of the result will be None Example SQRT EQU SQT 3 5 SQRT 1 870829 TAN lt expression gt Returns the tangent of lt expression gt as a floating point value The memory space attribute of the result will be None Example MOVE TAN 1 0 D1 S load tangent Freescale DSP Assembler Reference Manual 35 Chapter 3 Expressions Functions TNH lt expression gt Returns the hyperbolic tangent of lt expression gt as a floating point value The memory space attribute of the result will be None Example HTAN TNH VAL hyperbolic tangent UNF lt expression gt Converts lt expression gt to a floating point value For fractional DSPs DSP56300 lt expression gt should represent a binary fraction The memory space attribute of the result will be None Example FRC EQU UNF 400000 FRC 0 5 XPN lt expression gt Returns the exponential function base e raised to the power of lt expression gt as a floating point value The memory space attribute of the result will be None Example EXP EQU XPN 1 0 EXP 2 718282 36 DSP Assembler Reference Manual Freescale Chapter 4 Software Project Management 4 1 Introduction The Freescale DSP assemblers provide several directives designed to a
9. Inhibit source listing This option will stop the assembler from producing a source listing default reset in absolute mode Perform interrupt location checks Certain DSP instructions may not appear in the interrupt vector locations in program memory This option enables the assembler to check for these instructions when the program counter is within the interrupt vector bounds Increment load counter if different from runtime by number of bytes in DSP word to provide byte wide support for overlays in bootstrap mode This option must appear before any code or data generation Use the listing file as the debug source file rather than the assembly language file The L command line option to generate a listing file must be specified for this option to take effect Include local labels in the symbol table and cross reference listing Local la bels are not normally included in these listings If neither the S or CRE options are specified then this option has no effect The LOC option must be speci fied before the first symbol is encountered in the source file default reset Print macro calls default reset Print macro definitions Print macro expansions Scan MACLIB directory paths for include files The assembler ordinarily looks for included files only in the directory specified in the INCLUDE directory or in the paths given by the I command line option If the MI option is used the assembler will also look for included files
10. LOADDR EQU CVS X TARGET set LOADDR to X TARGET DEF lt symbol gt Returns an integer 1 memory space attribute N if lt symbol gt has been defined O otherwise lt symbol gt may be any label not associated with a MACRO or SECTION directive If lt symbol gt is quoted it is looked up as a DEFINE symbol if it is not quot ed it is looked up as an ordinary label Example IF DEF ANGLE assemble if ANGLE defined EXP lt expression gt Returns an integer 1 memory space attribute N if the evaluation of lt expression gt would not result in errors Returns 0 if the evaluation of lt expression gt would cause an error No error will be output by the assembler if lt expression gt contains an er ror No test is made by the assembler for warnings The lt expression gt may be relative or absolute Example IF EXP FRC VAL skip on error Freescale DSP Assembler Reference Manual 29 Chapter 3 Expressions Functions FLD lt base gt lt value gt lt width gt lt start gt Shift and mask lt value gt into lt base gt for lt width gt bits beginning at bit lt start gt If lt start gt is omitted zero least significant bit is assumed All arguments must be positive integers and none may be greater than the target word size Returns the shifted and masked value with a memory space attribute of None Example SWITCH EQU FLD TOG 1 1 7 turn eighth bit on FLR lt expression gt Returns a float
11. MAIN IO In this latter case the assembler interprets MAIN as a source file name and uses the default naming conventions for the B option Indicates that the assembler should run in absolute mode generating an ab solute object file when the B command line option is given By default the assembler produces a relocatable object file that is subsequently processed DSP Assembler Reference Manual Freescale B lt objfil gt Chapter 1 Freescale DSP Assembler Running the Assembler by the Freescale DSP linker See Chapter 4 for more information on as sembler modes This option specifies that an object file is to be created for assembler output lt objfil gt can be any legal operating system filename including an optional pathname A hyphen also may be used as an argument to indicate that the object file should be sent to the standard output The type of object file produced depends on the assembler operation mode If the A option is supplied on the command line the assembler operates in absolute mode and generates an absolute object CLD file If there is no A option on the command line the assembler operates in relative mode and creates a relocatable object CLN file If a pathname is not specified the file will be created in the current directory If no filename is specified the assembler will use the basename filename without extension of the first filename encountered in the source input file list and append
12. REPEAT Begin REPEAT loop UNTIL End of REPEAT loop WHILE Begin WHILE loop Freescale DSP Assembler Reference Manual 183 Appendix B Directive Summary Structured Programming 184 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages C 1 Introduction Assembler messages are grouped into four categories Command Line Errors These errors indicate invalid command line options missing filenames file open errors or other invocation errors Command line errors generally cause the as sembler to stop processing Warnings Warnings notify the programmer of suspect constructs but do not otherwise affect the object file output Errors These errors indicate problems with syntax addressing modes or usage In these cases the resulting object code is generally not valid Fatal Fatal errors signify serious problems encountered during the assembly process such as lack of memory file not found or other internal errors The assembler halts immediately The assembler also will provide information on the source field location of the error if it can be ascertained If a listing file is produced messages ordinarily will appear immedi ately before the line containing the error One exception is when the relationship between the first and last instructions in a DO loop produces an error In this case the error text will appear after the last instruction at the end of the loop Messages are always routed to
13. Returns integer 1 if the macro argument represented by lt symbol gt or lt expression gt is present 0 otherwise If the argument is a symbol it must be single quoted and refer to a dummy argument name If the argument is an expression it refers to the ordinal position of the argument in the macro dummy argument list A warning will be issued if this function is used when no macro expansion is active The memory space attribute of the result will be None Example IF ARG TWIDDLE twiddle factor provided 26 DSP Assembler Reference Manual Freescale Chapter 3 Expressions Functions ASN lt expression gt Returns the arc sine of lt expression gt as a floating point value in the range pi 2 to pi 2 The result of lt expression gt must be between 1 and 1 The memory space attribute of the result will be None Example ARCSINE SET ASWN 1 0 ARCSINE 1 570796 AT2 lt expri expr2 gt Returns the arc tangent of lt expr1 gt lt expr2 gt as a floating point value in the range pi to pi Expri and expr2 must be separated by a comma The memory space attribute of the result will be None Example ATAN EQU ATA2 1 0 1 0 ATAN 0 7853982 ATN lt expression gt Returns the arc tangent of lt expression gt as a floating point value in the range pi 2 to pi 2 The memory space attribute of the result will be None Example MOVE ATN 1 0 D0 S load arc tangent CCC Returns the cumulative cycle coun
14. if the input radix is set to16 assuming an initial radix of 10 The default radix is10 See Chapter 6 on the RADIX directive for more information 3 5 2 String Constants String constants that are used in expressions are converted to a concatenated sequence of ASCII bytes right aligned as shown below Strings used in expressions are limited to the long word size of the target processor subsequent characters in the string are ig nored Null strings strings that have no characters have a value of 0 String constants greater than the maximum number of characters can be used in expres sions but the assembler will truncate the value and will use only those characters that will fit in a DSP long word In this case a warning will be printed This restriction also applies to string constants using the string concatenation operator Handling of string constants by the DC and DCB directives is an exception to this rule see Chapter 6 for a description Examples ABCD 41424344 79 00273739 A 00000041 S 00000000 null string abcdef 61626364 abc de 61626364 3 6 Operators Some of the assembler operators can be used with both floating point and integer values If one of the operands of the operator has a floating point value and the other has an in teger value the integer will be converted to a floating point value before the operator is applied and the result will be floating point If both operands of the
15. tion applies for example to bit manipulation instructions and some jump type in structions Post increment by offset addressing mode not allowed The post increment by offset addressing mode is not allowed for this instruction The restriction applies for example to bit manipulation instructions and some jump type instructions 216 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Pre decrement addressing mode not allowed The pre decrement addressing mode is not allowed for this instruction The restric tion applies for example to instructions which include parallel XY memory data transfers RDIRECT directive not allowed in section Since the effect of the RDIRECT directive is global it cannot be used within a sec tion which has been declared using the SECTION directive Move the RDIRECT directive outside the declared section to avoid this error Redefinition would overflow line A substitution string declared using the DEFINE directive will cause the current source line to overflow if substitution occurs Reference outside of current buffer block Reference outside of current overlay block Reference was made to an underscore local label which fell outside the current buffer or overlay definition Register direct addressing not allowed Register direct addressing mode is not allowed for this instruction The restriction applies for example to bit manipulation instructions some jum
16. will not be reproduced on the assembler listing and will not be saved as part of a macro definition 2 5 Assembler Output The assembler output consists of an optional listing of the source program and an optional object file Appendix D contains the description of the object file format The assembly source program listing contains the original source statements formatted for easier reading as well as additional information which is generated by the assembler Most lines in the listing correspond directly to a source statement Lines which do not cor respond directly to source statements include page headings error messages and ex pansions of macro calls or directives such as DC Define Constant see Chapter 6 The assembly listing optionally may contain a symbol table or a cross reference table of all non local symbols appearing in the program These are always printed after the end of source input or the END directive whichever occurs first if either the symbol table or cross reference table options are in effect see the OPT directive Chapter 6 The symbol table contains the name of each symbol along with its defined value The cross reference table additionally contains the assembler maintained source line number of every refer ence to every non local symbol local symbols may be included in the cross reference list ing by using the LOC option see the OPT directive Chapter 6 If the MU option is enabled see the OPT directiv
17. Assembly Listing eu EE 177 Effects on the Programmer s Environment 1 0 0 0 cceccccceeeeeeeeeeeeeeeeeeeeeeeeeeees 177 DSP Assembler Reference Manual Freescale B 1 B 2 B 3 B 4 B 5 B 6 B 7 C 1 C 2 C 3 C 4 C 5 D 1 D 2 D 3 D 3 1 D 3 2 D 3 3 D 3 3 1 D 3 3 2 D 3 3 3 D 3 4 D 3 4 1 Freescale Table of Contents continued Appendix A ASCII Character Codes Appendix B Directive Summary POSSUM ON EE Symbol DefiNitio egetee et Data Definition Storage Allocation Listing Control and Re LEE Object File Control E Macros and Conditional Aesembhy AAA Str ctur d Progra MMN DE Appendix C Assembler Messages ed eieiei Le DEE Command Line Errors inccsacccievesdcanccasssce eas cas vakracihasae eens cetdupteiben cae deateeaaiaeion ts En oe EONS E EE ee eegen Appendix D Freescale DSP Object File Format COFF TO GUCHG a a E E T ET Object File Structure salar ees Object File Components asec tect ease cee eee ee ence a ae aad PIG IO ACO ee Optional EE EES E ee EN Relocation Information EE bine Wl S11 181 0 6 Ml EE leen DSP Assembler Reference Manual Table of Contents continued D 3 4 2 EEN lte EE 243 D 3 4 3 Section NUMDEF ae i aie ernie a i 244 D 3 4 4 e EE EE eege EE 244 D 3 4 5 Symbol Storage Class EEN 246 D 3 4 6 AT WEN 250 D 3 4 6 1 EIERE gees eege a e eege 251 D 3 4 6 2 Een EE 251 D 3 4 6 3 MAG an 253 D 3 4 6 4 ENG Of StruUct resS ee 253 D 3 4 6 5 PURICHONS EE 254 D 3 4 6 6 PRA
18. Figure E 18 Section Symbol Auxiliary Entry Freescale DSP Assembler Reference Manual 251 Appendix D Freescale DSP Object File Format COFF Object File Components Declaration Name Description long int secno Logical section number long int rsecno Logical relocation section number long int flags Section type flags struct mematt mem Section memory attributes Unused zero filled Figure E 19 Relocatable Section Auxiliary Entry The logical section number is the ordinal related to a SECTION directive in the assembler source file The relocation section number usually is the same as the logical section num ber but may be different if the logical section is static within an enclosing section The memory mapping is an alternate encoding of the CORE_ADDR information in the section header Section type flags indicate whether this COFF section represents a buffer or overlay block If the current COFF section is a buffer or overlay block a third auxiliary entry is produced The layout of that entry is shown in Figure E 19 Declaration Name Description long int bufcnt Buffer section number long int buftyp Buffer type long int buflim Buffer limit struct mematt long int ovimem ovicnt Overlay memory attributes Overlay section number long int ovistr Overlay origin expression Unused zero filled F
19. L P lt rl gt is one of the letters R for runtime counter or L for load counter The lt expression gt is an absolute integer value within the address range of the machine If during assembly the specified location counter falls below the value given by lt expression gt a warning is issued A label is not allowed with this directive See also HIMEM EXAMPLE LOMEM XR 100 YR 100 SET X Y RUN LOW MEM BOUNDS 128 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives LSTCOL Set Listing Field Widths LSTCOL lt labw gt lt opcw gt lt oprw gt lt opc2w gt lt opr2w gt lt xw gt lt yw gt Sets the width of the output fields in the source listing Widths are specified in terms of column positions The starting position of any field is relative to its predecessor except for the label field which always starts at the same position relative to page left margin pro gram counter value and cycle count display The widths may be expressed as any pos itive absolute integer expression However if the width is not adequate to accommodate the contents of a field the text is separated from the next field by at least one space Any field for which the default is desired may be null A null field can be indicated by two adjacent commas with no intervening space or by omitting any trailing fields altogether If the LSTCOL directive is given with no argume
20. lt rms gt lt rmp gt lt rce gt kexp1 gt lt Ims gt lt Imp gt lt lce gt xexp2 gt Which memory space X Y L or P will be used as the runtime memory space If the memory space is L any allocated datum with a value greater than the target word size will be extended to two words otherwise it is trun cated Which runtime counter H L or default if neither H or L is specified that is associated with the lt rms gt will be used as the runtime location counter Indicates the runtime physical mapping to DSP memory internal E ex ternal R ROM A port A B port B If not present no explicit mapping is done Non negative absolute integer expression representing the counter number to be used as the runtime location counter Must be enclosed in parenthe ses Should not exceed the value 65535 Initial value to assign to the runtime counter used as the lt rlc gt If lt exp1 gt is a relative expression the assembler uses the relative location counter If lt exp1 gt is an absolute expression the assembler uses the absolute location counter If lt exp1 gt is not specified then the last value and mode that the counter had will be used Which memory space X Y L or P will be used as the load memory space If the memory space is L any allocated datum with a value greater than the target word size will be extended to two words otherwise it is truncated Which load counter H L or default if
21. ment but in general floating point values are stored in double precision format This means that there are ordinarily 64 bits of storage allotted for a floating point number by the assembler with 11 bits of exponent 53 bits of mantissa and an implied binary point 3 5 Constants Constants represent quantities of data that do not vary in value during the execution of a program 3 5 1 Numeric Constants Numeric constants can be in one of three bases Binary Binary constants consist of a percent sign followed by a string of binary digits 0 1 Example 11010 Hexadecimal Hexadecimal constants consist of a dollar sign followed by a string of hexadecimal digits 0 9 A F a f Example 12FF 12ff Decimal Decimal constants can be either floating point or integer Integer decimal constants consist of a string of decimal 0 9 digits op tionally preceded by a grave accent Floating point constants are indicated either by a preceding following or included decimal point or by the presence of an upper or lower case E followed by the exponent Example 12345 integer 6E10 floating point 6 floating point 2 7e2 floating point Freescale DSP Assembler Reference Manual 19 Chapter 3 Expressions Operators A constant may be written without a leading radix indicator if the input radix is changed using the RADIX directive For example a hexadecimal constant may be written without the leading dollar sign
22. not used at present D 3 3 2 Relocation Information Object files have one relocation entry for each relocatable reference in the text or data The relocation information consists of entries with the format described in Figure E 8 Freescale DSP Assembler Reference Manual 239 Appendix D Freescale DSP Object File Format COFF Object File Components Declaration Name Description long r_vaddr Address of reference long r_symndx String table index unsigned long r_type Relocation type Figure E 8 Relocation Entry Format The address field represents the relocatable address within the section raw data where a modification is needed In standard COFF the r_symndx field points to an entry in the symbol table corresponding to the reference requiring modification The relocation type encodes how the raw data is to be changed to reflect the resolved symbol value In Freescale DSP COFF r_symndkx is an offset into the string table which points to a re location expression The linker interprets this expression and updates the word at r_vaddr with the result of the expression evaluation The relocation type is always zero See section D 5 Object File Data Expression Format for more information on relocation expressions D 3 3 3 Line Numbers When the compiler or assembler is invoked with the G debug option an entry is made in the object for every source line where a breakpoint can be inserted It is then possible to
23. reference source line numbers when using a debugger The structure of an object file line entry is shown in Figure E 9 Declaration Name Description long _symndx Function name symbol table index CORE_ADDR _paddr Line number physical address unsigned long _Inno Source file line number Figure E 9 Line Number Entry Format All line numbers in a section are grouped by function as shown in Figure E 10 The first entry in a function grouping has line number 0 and has in place of the physical address 240 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Components an index into the symbol table for the entry containing the function name Subsequent entries have actual line numbers and addresses of the program text corresponding to the line numbers The line number entries are relative to the beginning of the function and appear in increasing order of address Symbol index 0 Physical address Line number Physical address Line number Symbol index 0 Physical address Line number Physical address Line number Figure E 10 Line Number Grouping D 3 4 Symbol Table The COFF symbol table serves a dual purpose it provides resolution for symbolic refer ences in relocation expressions during linking and it establishes a framework for the han dling of symbolic debug information The symbol table consists of at least one fixed
24. same rules as symbol names Dummy argument names that are preceded by an under score are not allowed Within each of the three dummy argument fields the dummy ar guments are separated by commas The dummy argument fields are separated by one or more blanks Macro definitions may be nested but the nested macro will not be defined until the primary macro is expanded Chapter 5 contains a complete description of macros See also DUP DUPA DUPC DUPF ENDM EXAMPLE SWAP_SYM MACRO REG1 REG2 sswap REG1 REG2 using X0 as temp MOVE R REG1 X0 MOVE R REG2 R REG1 MOVE X0 R REG2 ENDM Freescale DSP Assembler Reference Manual 131 Chapter 6 Assembler Significant Characters and Directives Assembler Directives MODE Change Relocation Mode MODE lt ABS OLUTE REL ATIVE gt Causes the assembler to change to the designated operational mode The MODE direc tive may be given at any time in the assembly source to alter the set of location counters used for section addressing Code generated while in absolute mode will be placed in memory at the location determined during assembly Relocatable code and data are based from the enclosing section start address The MODE directive has no effect when the command line A option is issued See Chapter 4 for more information on modes sec tions and relocation A label is not allowed with this directive See also ORG EXAMPLE MODE ABS Change to absolute mode 132 DSP Assembler Refere
25. 0 R NUM ENDM then the assembled source listing would show DUPF NUM 0 7 MOVE 0 RO MOVE 0 R1 MOVE 0 R2 MOVE 0 R3 MOVE 0 R4 MOVE 0 R5 MOVE 0 R6 MOVE 0 R7 ENDM Freescale DSP Assembler Reference Manual 109 Chapter 6 Assembler Significant Characters and Directives Assembler Directives Note that the lines will only be shown on the source listing if the MD option is enabled The lines will only be shown on the source listing if the MEX option is enabled DUPF ENDM MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE NUM 0 7 0 RO 0 R1 0 R2 0 R3 0 R4 0 R5 0 R6 0 R7 See the OPT directive in this chapter for more information on the MD and MEX options DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives END End of Source Program END lt expression gt The optional END directive indicates that the logical end of the source program has been encountered Any statements following the END directive are ignored The optional ex pression in the operand field can be used to specify the starting execution address of the program lt expression gt may be absolute or relocatable but must have a memory space attribute of Program or None The END directive cannot be used in a macro expansion A label is not allowed with this directive EXAMPLE END BEGIN BEGIN is the starting execution address Freescale DSP Assembler Refer
26. COMMENT directive was never found Unexpected end of file missing ENDBUF A BUFFER directive was encountered without a closing ENDBUF directive Unexpected end of file missing ENDIF An IF directive was encountered without a closing ENDIF directive Unexpected end of file missing ENDM A macro definition was started using the MACRO directive but the end of the source file was encountered before a closing ENDM directive was found Unexpected end of file missing ENDSEC A SECTION directive was found without a closing ENDSEC directive Unknown math error A transcendental math function returned an error that could not be classified as out of range or outside the function domain Unrecognized mnemonic A symbol in the assembler opcode field was not a defined macro an instruction mnemonic or a directive Unrecognized secondary mnemonic A symbol in the assembler secondary opcode field was not one of the instructions FADD FSUB or FADDSUB UNTIL without associated REPEAT directive An UNTIL directive was encountered before a matching REPEAT structured con trol statement 224 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Value argument larger than machine word size The value parameter of a FLD function has a value larger than can fit in the tar get machine word Width argument greater than machine word size The width parameter of a FLD function has a value larger than
27. Chapter 6 Assembler Significant Characters and Directives Assembler Directives RADIX Change Input Radix for Constants RADIX lt expression gt Changes the input base of constants to the result of lt expression gt The absolute integer expression must evaluate to one of the legal constant bases 2 10 or 16 The default radix is 10 The RADIX directive allows the programmer to specify constants in a pre ferred radix without a leading radix indicator The radix prefix for base 10 numbers is the grave accent Note that if a constant is used to alter the radix it must be in the appro priate input base at the time the RADIX directive is encountered A label is not allowed with this directive EXAMPLE _RAD10 DC 10 Evaluates to hex A RADIX 2 _RAD2 DC 10 Evaluates to hex 2 RADIX 16 _RAD16 DC 10 Evaluates to hex 10 RADIX 3 Bad radix expression Freescale DSP Assembler Reference Manual 151 Chapter 6 Assembler Significant Characters and Directives Assembler Directives RDIRECT Remove Directive or Mnemonic from Table RDIRECT lt direc gt lt direc gt lt direc gt The RDIRECT directive is used to remove directives from the assembler directive and mnemonic tables If the directive or mnemonic that has been removed is later encoun tered in the source file it will be assumed to be a macro Macro definitions that have the same name as assembler directives or mnemonics will cause a warning message to
28. DEFVAL is visible only inside SECT1 so the value moved to RO will be 2 However the second move instruction is outside the scope of SECT1 and will therefore use the initial definition of DEFVAL This means that the value 1 will be moved to R1 4 3 3 Nested and Fragmented Sections Sections can be nested to any level When the assembler encounters a nested section the current section is stacked and the new section is used When the ENDSEC directive of the nested section is encountered the assembler restores the old section and uses it The ENDSEC directive always applies to the most recent SECTION directive Nesting sections provides a measure of scoping for symbol names in that symbols defined within a given section are visible to other sections nested within it For example if section B is nested inside section A then a symbol defined in section A can be used in section B with out XDEFing in section A or XREFing in section B This scoping behavior can be turned off and on with the NONS and NS options respectively see the OPT directive Chapter 6 Sections may also be split into separate parts That is lt section name gt can be used mul tiple times with SECTION and ENDSEC directive pairs If this occurs then these separate but identically named sections can access each others symbols freely without the use of the XREF and XDEF directives If the XDEF and XREF directives are used within one section they apply to all sections with the s
29. LSTCOL Set listing field widths NOLIST Stop assembly listing OPT Assembler options PAGE Top of page size page PRCTL Send control string to printer STITLE Initialize program subtitle TABS Set listing tab stops TITLE Initialize program title 182 DSP Assembler Reference Manual Freescale Appendix B Directive Summary Object File Control B 5 Object File Control The directives used for control of the object file are COBJ Comment object code IDENT Object code identification record SYMOBJ Write symbol information to object file B 6 Macros and Conditional Assembly The directives used for macros and conditional assembly are DUP Duplicate sequence of source lines DUPA Duplicate sequence with arguments DUPC Duplicate sequence with characters DUPF Duplicate sequence in loop ENDIF End of conditional assembly ENDM End of macro definition EXITM Exit macro IF Conditional assembly directive MACLIB Macro library MACRO Macro definition PMACRO Purge macro definition B 7 Structured Programming The directives used for structured programming are BREAK Exit from structured loop construct CONTINUE Continue next iteration of structured loop ELSE Perform following statements when IF false ENDF End of FOR loop ENDI End of IF condition ENDL End of hardware loop ENDW End of WHILE loop FOR Begin FOR loop JE Begin JE condition LOOP Begin hardware loop
30. are separated by commas For example consider the following macro definition N_R_MUL MACRO NMUL AVEC BVEC RESULT header This macro implements N real multiplies RESULT I AVEC l BVEC I l 1 NMUL were NMUL number of multiplications f AVEC base address of array AVEC I BVEC base address of array BVEC I RESULT base address of array RESULT I MOVE AVEC RO body MOVE BVEC R4 MOVE RESULT R1 MOVE X RO D4 S Y R4 D7 S DO NMUL ENDLOOP FMPY S D4 D7 D0 X RO D4 S Y R4 D7 S MOVE DO S X R1 _ENDLOOP ENDM terminator When a macro call is executed the dummy arguments within the macro definition NMUL AVEC BVEC RESULT in the example above are replaced with the correspond ing argument as defined by the macro call All local labels within a macro are considered distinct for the currently active level of macro expansion unless the macro local label override is used see below These local labels are valid for the entire macro expansion and are not considered bounded by non local la bels Therefore all local labels within a macro must be unique This mechanism allows the programmer to freely use local labels within a macro definition without regard to the number of times that the macro is expanded Non local labels within a macro expansion are considered to be normal labels and thus cannot occur more than once unless used with the SET directive see Chapter 6 Freescale DSP Assembler Reference Manual 59
31. can fit in the tar get machine word XDEF without preceding SECTION directive XREF without preceding SECTION directive An XDEF or XREF directive was encountered outside any previously defined sec tion XLL option must be used before any local label The XLL option must be activated before any local labels are encountered so that the assembler can make the appropriate entries in the symbol table XR option must be used before any label The XR option must be activated before any labels are encountered so that the as sembler can make the appropriate entries in the symbol table Freescale DSP Assembler Reference Manual 225 Appendix C Assembler Messages Fatal Errors C 5 Fatal Errors lt mode gt encoding failure A bad address mode indicator or register number was passed to the assembler en coding routines lt mode gt represents the register set or addressing mode in ques tion This is a serious internal error that should be reported to Freescale Absolute mode select failure The mode indicator passed to the absolute addressing mode selection logic was not valid This is a serious internal error that should be reported to Freescale Arithmetic exception An internal floating point exception occurred while evaluating an expression The assembler cannot continue Cannot encode instruction Cannot encode branch instruction Cannot encode jump instruction The correspondence between the source opcode mnemonic and the i
32. consists of the following fields lt label gt lt macro name gt lt arguments gt lt comment gt The argument field can have the form lt arg gt lt arg gt lt arg gt The macro call statement is made up of three fields besides the comment field the lt la bel gt if any will correspond to the value of the location counter at the start of the macro expansion the operation field which contains the macro name and the operand field which contains substitutable arguments Within the operand field each calling argument of a macro call corresponds one to one with a dummy argument of the macro definition For example the N_R_MUL macro defined earlier could be invoked for expansion called by the statement N_R_MUL CNT 1 VEC1 VEC2 OUT where the operand field arguments separated by commas and taken left to right corre spond to the dummy arguments N through RESULT respectively These arguments are then substituted in their corresponding positions of the definition to produce a se quence of instructions Macro arguments consist of sequences of characters separated by commas Although these can be specified as quoted strings to simplify coding the assembler does not re quire single quotes around macro argument strings However if an argument has an em bedded comma or space that argument must be surrounded by single quotes An 60 DSP Assembler Reference Manual Freescale Chapter 5 Macro Operations and Condi
33. data values in memory such as sine cosine tables for FFT algo rithms Also there are functions for easily converting values expressed in decimal float Freescale DSP Assembler Reference Manual 9 Chapter 1 Freescale DSP Assembler Assembler Support for Digital Signal Processing ing point to their binary or fractional equivalents This conversion is done automatically for immediate instruction operands and arguments to the DC directive see Chapter 6 See Chapter 3 for more information on assembler expressions operators and built in functions The register set of the Freescale digital signal processors allows for efficient use of mod ulo and reverse carry buffers for FFT applications The assembler supports this architec ture by providing several special purpose directives for allocating circular buffers The BADDR BUFFER DSM and DSR directives automatically advance the program counter to the next appropriate base address given the buffer size and perform various boundary and magnitude checks to insure that the buffer is valid The BSM and BSR provide for automatic alignment and block initialization of DSP buffers Since a buffer allocated in this fashion can cause alignment gaps in memory the MU option see the OPT directive Chapter 6 may be used to generate a full memory utilization report See Chapter 6 for more information on assembler directives and options 10 DSP Assembler Reference Manual Freescale Chapter 2 Writing Ass
34. generates an inverse conditional jump to beyond the matching ENDx UNTIL directive For example AF lt EQ gt zero bit set bne Z_LO00002 code generated by assembler CLR D1 User code END Z_L00002 assembler generated label REPEAT subtract until DO lt D7 Z_L00034 assembler generated label SUB D7 D0 user code UNTIL lt LT gt bge Z_L00034 code generated by assembler 7 4 1 2 Operand Comparison Expressions Two operands may be compared in a simple expression with subsequent transfer of con trol based on that comparison Such a comparison takes the form lt op1 gt lt cc gt lt op2 gt where lt cc gt is a condition mnemonic enclosed in angle brackets as described in section 7 4 1 1 and lt op1 gt and lt op2 gt are register or memory references symbols or assembler expressions When processed by the assembler the operands are arranged such that a compare jump sequence of the following form always results CMP lt reg1 gt lt reg2 gt JIB cc lt label gt where the jump conditional is the inverse of lt cc gt Ordinarily lt op1 gt is moved to the lt reg1 gt data register and lt op2 gt is moved to the lt reg2 gt data register prior to the compare This is not always the case however if lt op1 gt happens to be lt reg2 gt and lt op2 gt is lt reg1 gt an intermediate register is used as a scratch register In any event worst case code generation for a given operand comparison expressio
35. length entry per symbol with some symbols followed by auxiliary entries of the same size Because of symbolic debugging requirements the order of symbols in the symbol table is very important Whereas an individual symbol table entry can completely describe a sin gle debugging entity the entities exist within the framework of the source language that produced them For example symbol scoping and function blocks in C are represented by the appropriate ordering of begin end block entries in the symbol table Symbols in the symbol table appear in the sequence shown in Figure E 11 Freescale DSP Assembler Reference Manual 241 Appendix D Freescale DSP Object File Format COFF Object File Components Filename 1 Function 1 Local symbols for function 1 Function 2 Local symbols for function 2 Statics Filename 2 Function 1 Local symbols for function 1 Statics Defined global symbols Undefined global symbols Figure E 11 COFF Symbol Table Ordering The entry for each symbol is a structure that holds the symbol value its type and other information There are symbol table entries used for relocation and linking and there are special symbols used only for debugging The two kinds of entries are distinguished by combinations of field values in the symbol record The structure of a symbol table entry is illustrated in Figure E 12 242 DSP Assembler Reference Manual Freescale Ap
36. lt expression gt FUNCTION lt stmtlist gt is executed repeatedly until lt expression gt is true When expres sion becomes true advance to the next instruction following UNTIL NOTES The lt stmtlist gt is executed at least once even if lt expression gt is true upon entry to the REPEAT loop EXAMPLE REPEAT UNTIL x r1 lt EQ gt 0 loop until zero is found 7 3 7 WHILE Statement SYNTAX WHILE lt expression gt DO lt stmtlist gt ENDW FUNCTION The lt expression gt is tested before execution of lt stmtlist gt While lt expres sion gt remains true lt stmtlist gt is executed repeatedly When lt expression gt evaluates false advance to the instruction following the ENDW statement NOTES If lt expression gt is false upon entry to the WHILE loop lt stmtlist gt is not ex ecuted execution continues after the ENDW directive Freescale DSP Assembler Reference Manual 173 Chapter 7 Structured Control Statements Simple and Compound Expressions The DO keyword is optional EXAMPLE WHILE x r1 lt GT gt 0 loop until zero is found ENDW 7 4 Simple and Compound Expressions Expressions are an integral part of IF REPEAT and WHILE statements Structured control statement expressions should not be confused with the assembler expressions discussed in Chapter 3 The latter are evaluated at assembly time and will be referred to here as assembler expressions they can se
37. macro defini tion The assembler processes such nested macro calls at expansion time only The nesting of one macro definition within another definition is permitted However the nested macro definition will not be processed until the primary macro is expanded The macro must be defined before its appearance in a source statement operation field 5 2 Macro Libraries The Freescale DSP assembler allows for the maintenance of macro libraries with the MA CLIB directive This directive is used to specify the pathname as defined by the host op erating system of a directory that contains macro definitions Each macro definition must be in a separate file and the file must be named the same as the macro with the extension ASM added For example BLOCKMV ASM would be a file that contained the definition of the macro called BLOCKMV If a MACLIB directive has been specified in the source code and the assembler encoun ters a name in the operation field that is not a previously defined macro or is not contained in the directive or mnemonic tables the directory specified in the MACLIB directive will be searched for a file of that name with the ASM extension added If such a file is found the current source line will be saved and the file will be opened for input as an INCLUDE file When the end of the file is encountered the source line is restored and processing is resumed Because the source line is restored the processed file must have a macr
38. must be a legal operating system pathname The M option may be repeated as many times as desired The directories will be searched in the order specified on the command line See the MACLIB di rective Chapter 6 for more information Example ASM56300 M fftlib trans asm This example uses UNIX pathname conventions and would cause the assembler to look in the fftlib subdirectory of the current directory for a file with the name of the currently invoked macro found in the source file O lt opt gt lt opt gt lt opt gt This is equivalent to a source statement of the form OPT lt opt gt lt opt gt lt opt gt lt opt gt can be any of the options that are available with the OPT directive see Chapter 6 If multiple options are specified they must be separated by commas The O lt opt gt sequence can be repeated for as many options as desired Example ASM56300 OS CRE myprog asm This will activate the symbol table and cross reference listing options On some hosts the assembler displays a banner on the console when in voked This option inhibits the banner display It has no effect on hosts where the signon banner is not displayed by default Example ASM56300 Q myprog asm Assemble the file MYPROG ASM but do not display the signon ban ner on the console 6 DSP Assembler Reference Manual Freescale V lt filenames gt Chapter 1 Freescale DSP Assembler Running the Assembler This option cause
39. neither H or L is specified that is as sociated with the lt Ims gt will be used as the load location counter DSP Assembler Reference Manual Freescale Chapter 4 Software Project Management Address Assignment lt Imp gt Indicates the load physical mapping to DSP memory internal E exter nal R ROM A port A B port B If not present no explicit mapping is done lt Ice gt Non negative absolute integer expression representing the counter number to be used as the load location counter Must be enclosed in parentheses Should not exceed the value 65535 lt exp2 gt Initial value to assign to the load counter used as the Je If lt exp2 gt isa relative expression the assembler uses the relative location counter If lt exp2 gt is an absolute expression the assembler uses the absolute location counter If lt exp2 gt is not specified then the last value and mode that the counter had will be used The ORG directive is useful in multi programmer projects because it provides a means for the individual programmer to specify in which memory space and which segment of that memory space the code being written will be located without specifying an absolute ad dress Absolute address assignment can be deferred until the various components of the program are brought together The utility of the ORG directive is not limited to multi pro grammer projects Even in single programmer projects the ORG directive supports ma nip
40. next function entry Unused zero filled Figure E 23 Function Symbol Auxiliary Entry 254 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Components D 3 4 6 6 Arrays The format for C language array auxiliary entries is given in Figure E 24 The tag index contains the offset to the next array symbol in the symbol table The line number field gives the source file line number for the array declaration Declaration Name Description long int x_tagndx Tag index unsigned long x_Inno Line number of array declaration unsigned long unsigned long x_size x_dimen 0 Size of array First array dimension unsigned long x_dimen 1 Second array dimension unsigned long x_dimen 2 Third array dimension unsigned long x_dimen 3 Fourth array dimension Unused zero filled Figure E 24 Array Symbol Auxiliary Entry D 3 4 6 7 End of Blocks and Functions The format for C language symbol entries for the end of blocks and functions is given in Figure E 25 Only the source file line number for the end of the block or function is stored Declaration Description Unused zero filled unsigned long Source file line number Unused zero filled Figure E 25 End of Block or Function Auxiliary Entry Freescale DSP Assembler Reference Manual 255 Appendix D F
41. of an assembler expression Expressions otherwise follow the convention al rules of algebra and boolean arithmetic 3 2 Absolute and Relative Expressions An expression may be either relative or absolute An absolute expression is one which consists only of absolute terms or is the result of two relative terms with opposing signs A relative expression consists of a relative term by itself or only in combination with abso lute terms When the assembler is operating in relative mode all address expressions must adhere to the above definitions for absolute or relative expressions This is because only these types of expressions will retain a meaningful value after program relocation For example when relative terms are paired with opposing signs the result is the difference between the two relative terms which is an absolute value However if two positive relative terms are added together the result is unpredictable based on the computed values of the terms at relocation time 3 3 Expression Memory Space Attribute A symbol is associated with either an integer or a floating point value which is used in place of the symbol during the expression evaluation Each symbol also carries a memory space attribute of either X Y L Program or None SET labels constants and floating point expressions always have a memory space attribute of None The result of an ex pression will always have a memory space attribute associated with it The unary logi
42. of text in words long int dsize Size of data in words long int bsize Size of uninitialized data in words CORE_ADDR entry Program entry point CORE_ADDR text_start Base address of text CORE_ADDR data_start Base address of data CORE_ADDR text_end End address of text CORE_ADDR data_end End address of data Figure E 5 Freescale DSP Optional Runtime Header Format D 3 3 Sections A section is the smallest portion of an object file that is treated as one separate and distinct entity Sections can accommodate program text initialized and uninitialized data and block data COFF sections in DSP object files may be grouped under a logical section defined by the assembler SECTION directive see Chapter 6 It is a mistake to assume that every COFF file will have a specific number of sections or to assume characteristics of sections such as their order their location in the object file or the address at which they are to be loaded This information is available only after the 236 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Components object file has been created Programs manipulating COFF files should obtain it from file and section headers in the file D 3 3 1 Section Headers Every object file has a table of section headers to specify the layout of data within the file The section header table consists of one entry for every section in
43. of the nested section is encountered the assembler restores the old section and uses it The ENDSEC directive always applies to the most previous SECTION directive Nesting sections provides a measure of scoping for symbol names in that symbols defined within a given section are visible to other sections nested within it For example if section B is nested inside section A then a symbol defined in section A can be used in section B with out XDEFing in section A or XREFing in section B This scoping behavior can be turned off and on with the NONS and NS options respectively see the OPT directive this chap ter Sections may also be split into separate parts That is lt section name gt can be used mul tiple times with SECTION and ENDSEC directive pairs If this occurs then these separate but identically named sections can access each others symbols freely without the use of the XREF and XDEF directives If the XDEF and XREF directives are used within one section they apply to all sections with the same section name The reuse of the section name is allowed to permit the program source to be arranged in an arbitrary manner for example all statements that reserve X space storage locations grouped together but re tain the privacy of the symbols for each section When the assembler operates in relative mode the default sections act as the basic grouping for relocation of code and data blocks For every section defined in the source a s
44. operator are integers the result will be an integer value Similarly if both the operands are floating point the result will be a floating point value 3 6 1 Unary operators plus minus one s complement Integer only logical negate d The unary plus operator returns the value of its operand The unary minus operator returns the negative of its operand 20 DSP Assembler Reference Manual Freescale Chapter 3 Expressions Operators The one s complement operator returns the one s complement of its operand It cannot be used with a floating point operand The unary logical negation operator returns an integer 1 memory space attribute None if the value of its operand is 0 and will return a O otherwise For example if the symbol BUF had a value of 0 then BUF would have a value of 1 If BUF had a value of 1000 IBUF would have a value of 0 3 6 2 Arithmetic operators addition subtraction multiplication division mod The addition operator yields the sum of its operands The subtraction operator yields the difference of its operands The multiplication operator yields the product of its operands The divide operator yields the quotient of the division of the first operand by the second For integer operands the divide operation will produce a truncated integer result The mod operator applied to integers will yield the remainder from the division of the first operand by the
45. register See Appen dix E for a list of the register names of the appropriate target processor 2 3 Strings One or more ASCII characters enclosed by single quotes constitute a literal ASCII string In order to specify an apostrophe within a literal string two consecutive apostro Freescale DSP Assembler Reference Manual 11 Chapter 2 Writing Assembly Language Programs Source Statement Format phes must appear where the single apostrophe is intended Strings are used as operands for some assembler directives and also can be used to a limited extent in expressions A string may also be enclosed in double quotes in which case any DEFINE directive symbols contained in the string would be expanded The double quote should be used with care inside macros since it is used as a dummy argument string operator see Chap ter 5 In that case the macro concatenation operator can be used to escape the double quoted string if desired Two strings separated by the string concatenation operator will be recognized by the assembler as equivalent to the concatenation of the two strings For example these two strings are equivalent ABC DEF ABCDEF The assembler has a substring extraction capability using the square brackets Here is an example DSP56300 3 5 56300 Substrings may be used wherever strings are valid and can be nested There are also functions for determining the length of a string and the posit
46. relative expression If the assembler is running in absolute mode or if the load counter expression is absolute then the overlay is absolute If the assembler is in relative mode and the load counter expression is relative the overlay is relocatable Runtime relocatable overlay code is addressed relative to the location given in the runtime 144 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives location counter expression This expression if relative may not refer to another overlay block See also MODE EXAMPLES ORG P 1000 Sets the runtime memory space to P Selects the default runtime counter counter 0 associated with P space to use as the runtime location counter and initializes it to 1000 The load memory space is implied to be P and the load location counter is assumed to be the same as the runtime location counter ORG PHE Sets the runtime memory space to P Selects the H load counter counter 2 as sociated with P space to use as the runtime location counter The H counter will not be initialized and its last value will be used Code generated hereafter will be mapped to external E memory The load memory space is implied to be P and the load location counter is assumed to be the same as the runtime location counter ORG PI OVL1 Y Indicates code will be generated for an overlay The runtime memory space is P and the default counter is
47. relocatable buffers is located based on the largest relocatable buffer it contains un less the buffers inside the section are auto aligned This insures that any smaller buffers within the section are properly aligned If any buffers in the section are auto aligned they will be relocated independent of any other code or data in the section Note that reposi tioning of any buffer whether relocatable or absolute may result in alignment gaps in memory depending on the layout of data surrounding the buffer blocks 4 6 Example 1 Multi Programmer Environment Typical multi programmer projects are often split into tasks representing functional units For discussion purposes suppose a project has been divided into three tasks I O FILTER and MAIN Each task will be written by a separate programmer as a separate section For example when the I O task has been written there will be a file called IO ASM This file will have the following form SECTION _O XREF _ PORT O_PORT ORG XL lt storage location definitions gt ORG P lt lO section source statements gt ENDSEC In this example because the X space storage locations were defined within the section _O they will be private storage locations that are accessible only by the _O handler and cannot be referenced by other sections If global memory resource management is de sired then the _O section would not have defined any storage locations and these would have been defined as XR
48. second If the mod operator is used with floating point operands the mod operator will apply the following rules Y Z Y ifZ 0 X ifZ lt gt 0 where X has the same sign as Y is less than Z and satisfies the relationship Yo 24 where i is an integer 3 6 3 Shift operators shift left lt lt Integer only shift right gt gt Integer only The shift left operator causes the left operand to be shifted to the left and zero filled by the number of bits specified by the right operand The shift right operator causes the left operand to be shifted to the right by the number of bits specified by the right operand The sign bit will be extended Freescale DSP Assembler Reference Manual 21 Chapter 3 Expressions Operators Shift operators cannot be applied to floating point operands 3 6 4 Relational operators less than lt less than or equal lt greater than gt greater than or equal gt equal not equal Relational operators all work the same way If the indicated condition is true the result of the expression is an integer 1 If it is false the result of the expression is an integer 0 In either case the memory space attribute of the result is None For example if D has a value of 3 and E has a value of 5 then the result of the expression D lt E is 1 and the result of the expression D gt E is 0 Each operand of the conditional op erators can be either floating point or integer Test f
49. source statements into object programs compatible with other Freescale DSP software and hardware products 1 2 Assembly Language The assembly language provides mnemonic operation codes for all machine instructions in the digital signal processor instruction set In addition the assembly language contains mnemonic directives which specify auxiliary actions to be performed by the assembler These directives are not always translated into machine language The assembly lan guage enables the programmer to define and use macro instructions which replace a sin gle statement with a predefined sequence of statements found in the macro definition Conditional assembly also is supported 1 3 Installing the Assembler The assembler is distributed on various media and in different formats depending on the host environment 1 4 Running the Assembler The general format of the command line to invoke the assembler is ASM56300 options lt filenames gt where ASM56300 The name of the Freescale DSP assembler program appropriate for the tar get processor For the Freescale DSP56300 processor the name of the as sembler executable is ASM56300 Freescale DSP Assembler Reference Manual 1 Chapter 1 Freescale DSP Assembler Running the Assembler options Any of the following command line options These can be in any order but must precede the list of source filenames Some options can be given more than once the individual descriptions indicat
50. specified in the instruction Absolute address too large to use I O short long substituted The absolute address is not within the range specifying an I O short address even though the I O short forcing operator has been used The assembler substitutes long absolute addressing Absolute address too large to use short long substituted The absolute address value being forced short will not fit in the storage allocated for a short address The assembler substitutes long absolute addressing Absolute address too small to use I O short long substituted The absolute address is not within the range specifying an I O short address even though the I O short forcing operator has been used The assembler substitutes long absolute addressing Address involves incompatible memory spaces The memory space attribute is regarded by the assembler as a type in the same sense that high level languages use type for variables Symbols may have memory space attributes of X Y L P rogram or N one only N is fully compatible with all other attributes In this case an operand was evaluated with a different memory space attribute than that specified in the instruction Cannot force short addressing for source and destination In a MOVEP or MOVES instruction an attempt was made to force both operands to short or I O short The second operand defaults to long Cannot force short immediate with this parallel move The immediate operand in the X fi
51. symbols used elsewhere in the source program even if the symbol name is the same This is true as long as the section name associated with each symbol is unique the symbol is not declared public XDEF GLOBAL and the GLOBAL or LOCAL qualifier is not used in the section declaration Symbols that are defined outside of a section are considered global symbols and have no explicit section name associated with them Global symbols may be referenced freely from inside or outside of any section as long as the global symbol name does not conflict with another symbol by the same name in a given section If the GLOBAL qualifier follows the lt section name gt in the SECTION directive then all symbols defined in the section until the next ENDSEC directive are considered global The effect is as if every symbol in the section were declared with GLOBAL This is useful when a section needs to be independently relocatable but data hiding is not desired If the STATIC qualifier follows the lt section name gt in the SECTION directive then all code and data defined in the section until the next ENDSEC directive are relocated in terms of the immediately enclosing section The effect with respect to relocation is as if all code and data in the section were defined within the parent section This is useful when a sec tion needs data hiding but independent relocation is not required If the LOCAL qualifier follows the lt section name gt in the SECTION directi
52. the I option was used on the command line that invoked the assembler then the string specified with the I op tion is prefixed to lt string gt and that directory is searched If the lt lt string gt gt syntax is given the file is searched for only in the directories specified with the I option Refer to Chapter 1 Running the Assembler A label is not allowed with this directive See also MACLIB EXAMPLE INCLUDE headers io asm Unix example INCLUDE storage mem asm MS DOS example INCLUDE lt data asm gt Do not look in current directory Freescale DSP Assembler Reference Manual 125 Chapter 6 Assembler Significant Characters and Directives Assembler Directives LIST List the Assembly LIST Print the listing from this point on The LIST directive will not be printed but the subse quent source lines will be output to the source listing The default is to print the source listing If the IL option has been specified the LIST directive has no effect when encoun tered within the source program The LIST directive actually increments a counter that is checked for a positive value and is symmetrical with respect to the NOLIST directive Note the following sequence Counter value currently 1 LIST Counter value 2 LIST Counter value 3 NOLIST Counter value 2 NOLIST Counter value 1 The listing still would not be disabled until another NOLIST directive was issued A label is not allowed with t
53. the count of sections in the object module created via the assembler SECTION directive see Chapter 6 The counter count represents the number of COFF sections in the file analogous to the file header f_nscns field The relocation entry and line number counts hold the number of all relocation entries and line number records in the file The 234 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Components buffer and overlay counts give counts for each instance of a buffer or overlay in the mod ule The major version minor version and revision number fields reflect the assembler and linker versions to insure linker backward compatibility The optional header flags hold special mode flags for the linker Declaration Name Description long int modsize Object module size long int datasize Module raw data size long int endstr End directive expression string long int secnt Logical section count long int ctrent Counter count long int relocnt Relocation entry count long int Inocnt Line number entry count long int bufcnt Buffer count long int ovicnt Overlay count long int majver Major version number long int minver Minor version number long int revno Revision number long int optflags Optional header flags Figure E 4 Freescale DSP Optional Link Header Format Figure E 5 illustrates the runtime optional header This heade
54. the following statements DUPC VALUE 123 DC VALUE ENDM then the assembled source listing would show DUPC VALUE 123 DC 1 DC 2 DC 3 ENDM Note that the lines DUPC VALUE 123 ENDM will only be shown on the source listing if the MD option is enabled The lines DC 1 DC 2 DC 3 will only be shown on the source listing if the MEX option is enabled See the OPT directive in this chapter for more information on the MD and MEX options 108 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives DUPF Duplicate Sequence In Loop lt label gt DUPF lt dummy gt lt start gt lt end gt lt increment gt ENDM The block of source statements defined by the DUPF and ENDM directives will be repeat ed in general lt end gt lt start gt 1 times when lt increment gt is 1 lt start gt is the starting value for the loop index lt end gt represents the final value lt increment gt is the increment for the loop index it defaults to 1 if omitted as does the lt start gt value The lt dummy gt parameter holds the loop index value and may be used within the body of instructions lt label gt if present will be assigned the value of the runtime location counter at the start of the DUPF directive processing See also DUP DUPA DUPC ENDM MACRO EXAMPLE If input source file contained the following statements DUPF NUM 0 7 MOVE
55. the listing file CEX Print DC expansions CL Print conditional assembly directives CRE Print symbol cross reference DXL Expand DEFINE directive strings in listing HDR Generate listing headers IL Inhibit source listing LOC Print local labels in cross reference MC Print macro calls MD Print macro definitions MEX Print macro expansions MU Print memory utilization report NL Print conditional assembly and section nesting levels S Print symbol table U Print skipped conditional assembly lines Message Control These options control the types of assembler messages that are generated AE Check address expressions MSW Warn on memory space incompatibilities UR Flag unresolved references Ww Display warning messages Symbol Options These options deal with the handling of symbols by the assembler DEX Expand DEFINE symbols within quoted strings IC Ignore case in symbol names NS Support symbol scoping in nested sections SCL Scope structured control statement labels SCO Structured control statement labels to listing object file SO Write symbols to object file XLL Write local labels to object file XR Recognize XDEFed symbols without XREF 136 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives Assembler Operation Miscellaneous options having to do with internal assembler operation cc Enable cyc
56. the source file will be aligned with the label field in the listing file Otherwise the comment will be shifted right and aligned with the comment field in the listing file EXAMPLE 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 72 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives Unreported Comment Delimiter Characters Unreported comments are any number of characters preceded by two consecutive semi colons that are not part of a literal string Unreported comments are not considered significant by the assembler and can be included in the source statement following the same rules as normal comments However unreported comments are never reproduced on the assembler output listing and are never saved as part of macro definitions EXAMPLE 35 THESE LINES WILL NOT BE REPRODUCED 3 IN THE SOURCE LISTING Freescale DSP Assembler Reference Manual 73 Chapter 6 Assembler Significant Characters and Directives Assembler Directives Line Continuation Character or Macro Argument Concatenation Character Line Continuation The backslash character if used as the last character on a line indicates to the assem bler that the source statement is continued on the following line The continuation line will be concatenated to the pr
57. tion will be used as the load location counter In addition the ORG directive can be used to specify a physical mapping to DSP memory and to assign initial values to the runtime and load location counters The names of the counters High Low and default are symbolic only and the assembler performs no checks to insure that the value assigned to the High counter is greater than the Low Moreover there is no inherent relationship among numbered counters except that counters 0 1 and 2 correspond to the default Low and High counters respectively Counters are useful for providing mnemonic links between runtime and load memory spaces or among individual memory blocks Separate counters can be used to obtain blocks within a common section which are accessed from one memory space but mapped to separate physical memories Also counters are necessary for handling relocatable overlays at link time as the DSP linker does not support the notion of separate load and runtime counters See the examples below for more information on location counter us age The ORG directive is organized as follows ORG lt rms gt lt rlc gt lt rmp gt lt exp1 gt lt Ims gt lt Ilc gt lt Imp gt lt exp2 gt Freescale DSP Assembler Reference Manual 43 Chapter 4 Software Project Management Address Assignment or alternatively lt rms gt lt rlc gt lt rmp gt lt rce gt lt exp1 gt lt Ims gt lt llc gt 44 ORG
58. to aid de bugging This option if used must be specified before the first symbol in the source program is defined Causes XDEFed symbols to be recognized within other sections without be ing XREFed This option if used must be specified before the first symbol in the source program is encountered OPT CEX MEX Turn on DC and macro expansions OPT CRE MU Cross reference memory utilization DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives ORG Initialize Memory Space and Location Counters ORG lt rms gt lt rlc gt lt rmp gt lt exp1 gt lt Ims gt lt llc gt lt Imp gt lt exp2 gt ORG lt rms gt lt rmp gt lt rce gt lt exp1 gt lt Ims gt lt Imp gt lt Ilce gt lt exp2 gt The ORG directive is used to specify addresses and to indicate memory space and map ping changes It also can designate an implicit counter mode switch in the assembler and serves as a mechanism for initiating overlays A label is not allowed with this directive lt rms gt lt rlc gt lt rmp gt lt rce gt lt exp1 gt lt Ims gt Freescale Which memory space X Y L or P will be used as the runtime memory space If the memory space is L any allocated datum with a value greater than the target word size will be extended to two words otherwise it is trun cated Which runtime counter H L or default if neith
59. upper or lower case alphabetic character or the underscore character _ SYMOBJ symbol must be a global symbol name Arguments to the SYMOBYJ directive cannot be preceded by an underscore Syntax error expected In an ORG directive using numeric counter designations the parenthesis colon pair separating the load or runtime address from the memory space counter or map ping characters was not found Syntax error expected In an ORG directive the colon separating the load or runtime address from the memory space counter or mapping characters was not found Freescale DSP Assembler Reference Manual 221 Appendix C Assembler Messages Errors Syntax error expected gt The closing angle bracket in a non local INCLUDE directive argument was not found Syntax error expected comma The comma separating operands in an instruction or directive was not found Syntax error expected keyword BY In a FOR structured control statement something other than the optional step clause preceded by the keyword BY was encountered Syntax error expected keyword DO In a WHILE structured control statement something other than the optional DO keyword was encountered at the end of the statement Syntax error expected keyword TO or DOWNTO In a FOR structured control statement something other than the loop target clause preceded by the keyword TO or DOWNTO was encountered Syntax error expected quote The assembler wa
60. 0 173 183 assembly control 68 181 BADDR 69 91 182 BSB 69 92 182 BSC 69 93 182 BSM 69 94 182 BUFFER 69 95 182 COBJ 70 96 183 COMMENT 68 97 181 data definition 69 182 DC 69 98 182 DCB 69 99 182 DEFINE 3 68 79 100 138 181 DS 69 101 182 DSM 69 102 182 DSR 69 103 182 DUP 65 70 104 183 DUPA 65 70 106 183 DUPC 65 70 108 183 DUPF 65 70 109 183 END 68 111 181 ENDBUF 69 112 182 ENDIF 70 113 183 274 DSP Assembler Reference Manual Freescale ENDM 58 70 114 183 ENDSEC 69 115 182 EQU 69 116 182 EXITM 70 117 183 FAIL 68 118 181 FORCE 68 119 181 GLOBAL 69 120 182 GSET 69 121 182 HIMEM 68 122 181 IDENT 70 123 183 IF 65 70 124 183 inloop 138 INCLUDE 68 125 181 LIST 69 126 182 listing control 69 182 LOCAL 69 127 182 LOMEM 68 128 181 LSTCOL 69 129 182 MACLIB 6 58 70 130 183 MACRO 58 70 131 183 macro 70 183 MODE 41 68 132 181 MSG 68 133 181 NOLIST 69 134 182 object file 70 183 OPT 6 69 135 182 ORG 43 68 143 181 PAGE 69 147 182 PMACRO 70 149 183 PRCTL 69 150 182 RADIX 68 151 181 RDIRECT 57 68 152 181 SCSJMP_ 68 153 181 SCSREG 68 154 181 SECTION 69 155 182 SET 39 69 158 182 STITLE 69 159 182 structured control 70 183 symbol definition 69 182 SYMOBJ 70 160 183 TABS 69 161 182 TITLE 69 162 182 UNDEF 68 163 181 WARN 68 164 181 XDEF 38 69 165 182 XREF 38 69 166 182 DSP56300 26
61. 1 ENDSEC MOVE SYM2 R2 SYM1 is first defined outside of any section Then in section SECT1 SYM2 is declared public with an XDEF directive SYM1 is also defined locally to section SECT1 In section SECT2 SYM2 is declared external via the XREF directive followed by a move of SYM1 to RO Since SYM1 was defined locally to section SECT1 the assembler uses the global value and moves a 1 to RO Because SYM2 was declared external in section SECT1 the value moved to R1 is 3 If SYM2 had not been XREFed in section SECT2 the value moved to R1 would have been unknown at this point In the last instruction it is not known what value will be moved to R2 since SYM2 was not defined outside of any section or was not declared GLOBAL within a section If the GLOBAL qualifier follows the lt section name gt in the SECTION directive then all symbols defined in the section until the next ENDSEC directive are considered global The effect is as if every symbol in the section were declared with the GLOBAL directive This is useful when a section needs to be independently relocatable but data hiding is not required If the LOCAL qualifier follows the lt section name gt in the SECTION directive then all sym bols defined in the section until the next ENDSEC directive are visible to the immediately enclosing section The effect is as if every symbol in the section were defined within the parent section This is useful when a section needs to be independently relocatabl
62. 2 Symbol Table Entry Format srscinc pct ecie wesc a cetheietaiegeigesnsaectspetemiesss uctiae 243 F ndamental TYPOS stasis cain etd eh a ne aati 245 Derved ue 246 Eet 247 eene KEE 249 Filename Symbol Auxiliary Entry AEN 251 Section Symbol Auxiliary Entry EEN 251 Relocatable Section Auxiliary Entre 252 Relocatable Buffer Overlay Auxiliary Entry ccccsseeceeeeeeeeeeeeeeeeeeeee 252 Tag Name Symbol Auxiliary Entry 0 cecccceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaees 253 End of Structure Auxiliary Entry EE 254 Function Symbol Auxiliary Entry ccccceececeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 254 Array Symbol Auxiliary ENY EE 255 End of Block or Function Auxiliary Entry eeeeeseeesesseseeeeeererrrrrreesssssssseee 255 DSP Assembler Reference Manual xiii A 26 A 27 A 28 A 29 A 30 xiv List of Figures continueo Beginning of Block or Function Auxiliary Entry 0 0 ceeeeeeeteeeeeeeeeeee 256 Structure Union or Enumeration Name Auxiliary Entry eeee 257 CORE ADDR ei 258 Memory Mapping Enumerations 0 cccceeeeeceeeeeeeeeeeeeeeeeeeeeeeeeeeeeneeea 259 Freescale DSP COFF Byte Ordering AAA 260 DSP Assembler Reference Manual Freescale Chapter 1 Freescale DSP Assembler 1 1 Introduction The Freescale DSP Assemblers are programs that process assembly language source statements written for Freescale s family of digital signal processors The assembler translates these
63. 3 2 6 3 3 6 3 4 6 3 5 6 3 6 6 3 7 7 1 7 2 7 3 7 3 1 7 3 2 7 3 3 7 3 4 7 3 5 7 3 6 7 3 7 7 4 7 4 1 7 4 1 1 7 4 1 2 7 4 2 7 5 7 5 1 7 5 2 7 5 3 7 6 viii Table of Contents continued Assembler Significant Characters 0 ccceeeesseecceeeeeeeessaeeeeeneeeeessneeeeeees 67 Assembler RE 68 leede EE 68 Symbol Definition EE 69 Data Definition Storage AllOCallOn EE 69 Listing Control and Options oc chepiccheteeedeceelors dente hecuebys alder eegene 69 Object FING CG Omi Age EEN 70 Macros and Conditional Assembly ceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 70 Structured EES TIPS 70 Chapter 7 Structured Control Statements attente EE 167 Structured Control Directives 0 0 cccccscccccccccceceeeceeeeeeeeeeeesseeeseeeseesnsnteeeeeees 167 SIE Abee EE 168 GREEN E E 168 CONTINUE Statement EE 169 POR Slalemient eene ee 170 DP SLALOM IG Ml ner viedtanutn scene e Eden 171 LOOP Statement EE 172 BRESSLER EA ebe 173 WHILE ENEE 173 Simple and Compound Expressions ccccececeeeeeeeeeeeeeeeeeeeeeeeeensnneaeeeees 174 Simple Expressions narobia eS Ad ee aati a E 174 Condition Code Expressions ssssssseeeeeeerrrnrrnnrrnnnrrnnnnnrrrerrree nnee 174 Operand Comparison Expressions csscccccceceeeeeeeeeeeseeeeesseee 175 Compound E ee 176 Statement el te WEE 176 Expression Formatting EE 176 PORELOOP FOMMetING asec cccrtetsuetee carte Gcrtcenees ua doua wecuee saver uensaee 177
64. 49 Appendix D Freescale DSP Object File Format COFF Object File Components Storage Class Value A_FILE see below A_SECT String table offset to section name A_BLOCK Relocatable address A_MACRO String table offset to macro name A_GLOBAL Relocatable address A_XDEF Relocatable address A_XREF String table offset to symbol name A_SLOCAL Relocatable address A_ULOCAL Relocatable address A_MLOCAL Relocatable address Figure E 16 Storage Class and Value continued If asymbol has storage class C_FILE or A_FILE the value of that symbol equals the sym bol table entry index of the next C_FILE or A_FILE symbol That is the C_FILE and A_FILE entries form a one way linked list in the symbol table If there are no more C_FILE or A_FILE entries in the symbol table the value of the symbol is the index of the first global symbol Relocatable symbols have a value equal to the relocatable address of that symbol When the section is relocated by the linker the value of these symbols changes D 3 4 6 Auxiliary Entries Every symbol table entry may have zero one or more auxiliary entries These auxiliary entries are used to hold additional information about the primary symbol The number of auxiliary entries associated with a given symbol can be determined by examining the n_numawux field of the main symbol entry An auxiliary symbol table entry contains the same number of bytes as its associated sym bol tab
65. 7 condition code 270 instruction set 267 register 270 DSPASMOPT 2 Environment variable 2 Error command line 186 fatal 226 output 4 Expression 17 absolute 17 address 137 compound 176 condition code 174 constant 19 formatting 176 function 23 internal representation 19 object file 261 Operand comparison 175 Operator 20 radix 151 relative 17 simple 174 F File command line 4 include 5 125 input 11 listing 5 15 139 Freescale DSP Assembler Reference Manual 275 Index macro 6 object 3 231 output 7 source 7 11 Function 23 81 ABS 24 26 ACS 24 26 ARG 25 26 ASN 24 27 AT2 24 27 ATN 24 27 CCC 26 27 CEL 24 27 CHK 26 CNT 25 28 COH 24 28 conversion 25 COS 24 28 CTR 26 28 CVF 25 29 CVI 25 29 CVS 25 29 DEF 26 29 EXP 26 29 FLD 25 30 FLR 24 30 FRC 25 30 INT 26 30 L10 24 30 LCV 26 31 LEN 25 31 LFR 25 31 LNG 25 31 LOG 24 32 LST 26 32 LUN 25 32 MAC 25 32 macro 25 mathematical MAX 24 32 276 24 MIN 24 33 miscellaneous 26 MSP 26 33 MXP 25 33 POS 25 POW 24 33 34 REL 26 34 RND 24 34 RVB 25 34 SCP 25 34 SGN 24 35 SIN 24 35 SNH 24 35 SQT 24 35 string 25 TAN 24 35 TNH 24 36 UNF 25 36 XPN 24 36 Include file 5 125 E Label 13 local 13 59 64 139 142 Label field 13 Line continuation 74 Line number 240 Listing file 5 15 139 format 129 138 141 147 161 sub title 159 tile 162 Load address 8 Load location
66. 8 4E 79 4F 80 50 81 51 82 52 83 53 84 54 85 55 86 56 87 57 88 58 89 59 90 5A 91 5B 92 5C 93 5D 94 5E 95 5F 96 60 97 61 98 62 99 63 gt N lt XXS lt CHHDOVOZZE AC ITOMMIODFE oog 179 Appendix A ASCII Character Codes Decimal Hex ASCII Decimal Hex ASCII 36 24 100 64 d 37 25 101 65 e 38 26 amp 102 66 f 39 27 103 67 g 40 28 104 68 h 41 29 105 69 i 42 2A i 106 6A j 43 2B 107 6B k 44 2C 108 6C 45 2D 109 6D m 46 2E 110 6E n 47 2F 111 6F o 48 30 0 112 70 p 49 31 1 113 71 q 50 32 2 114 72 r 51 33 3 115 73 S 52 34 4 116 74 t 53 35 5 117 75 u 54 36 6 118 76 V 55 37 7 119 77 W 56 38 8 120 78 X 57 39 9 121 79 y 58 3A 122 7A Z 59 3B 123 7B 60 3C lt 124 7C 61 3D 125 7D 62 3E gt 126 7E 63 3F 127 7F DEL 180 DSP Assembler Reference Manual Freescale Appendix B Directive Summary Assembler directives can be grouped by function into seven types Assembly control Symbol definition Data definition storage allocation Listing control and options Object file control Macros and conditional assembly Structured programming NOOO BR WON B 1 Assembly Control The directives used for assembly control are COMMENT Start comment lines DEFINE Define substitution string END End of source program FAIL Programmer generated error message FORCE Set operand forcing mode HIMEM Set high memory bounds INCLUDE Include second
67. Assembler Directives lt Immediate Short Addressing Mode Force Operator Many DSP instructions allow a short immediate form of addressing If the immediate data is known to the assembler on pass one not a forward or external reference or the FORCE SHORT directive is active then the assembler will always pick the shortest form of immediate addressing consistent with the instruction Ifthe 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 lt See also 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 DO L CNST EQU 5 Because the long immediate addressing mode makes the instruction two words long in stead of one word for the immediate short addressing mode it may be desirable to force the immediate short addressing mode as shown below MOVE lt CNST DO L CNST EQU 5 Freescale DSP Assembler Reference Manual 89 Chapter 6 Assembler Significant Characters and Directives Assembler Directives gt Immediate Long Addressing Mode Force Operator Many DSP instructions allow a long immediate form of addressing If the immediate data is kn
68. B VAL STMT LAB VAL STMT ENDM This macro generates a label consisting of the concatenation of the label prefix argument and a value that is interpreted as hexadecimal If this macro were called as follows NUM SET 10 GEN_LAB HEX NUM NOP the macro processor would first substitute the characters HEX for LAB then it would re place VAL with the character A since A is the hexadecimal representation for the dec imal integer 10 Next the macro processor would apply the concatenation operator Finally the string NOP would be substituted for the STMT argument The resulting ex pansion as it would appear in the listing file would be HEXA NOP The percent sign is also the character used to indicate a binary constant If a binary con stant is required inside a macro it may be necessary to enclose the constant in parenthe ses or escape the constant by following the percent sign by a backslash 5 5 4 Dummy Argument String Operator Another dummy argument operator is the double quote This character is replaced with a single quote by the macro processor but following characters are still examined for dummy argument names The effect in the macro call is to transform any enclosed dummy arguments into literal strings For example consider the following macro definition STR_MAC MACRO STRING DC STRING ENDM If this macro were called with the following macro expansion line STR_MAC ABCD then the resulting macro expa
69. Begin JE condition LOOP Begin hardware loop REPEAT Begin REPEAT loop UNTIL End of REPEAT loop WHILE Begin WHILE loop 70 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives Individual descriptions of each of the assembler special characters and directives follow They include usage guidelines functional descriptions and examples Some directives require a label field while in many cases a label is optional If the description of an as sembler directive does not indicate a mandatory or optional label field then a label is not allowed on the same line as the directive Structured programming directives are dis cussed separately in Chapter 7 Freescale DSP Assembler Reference Manual 71 Chapter 6 Assembler Significant Characters and Directives Assembler Directives Comment Delimiter Character Any number of 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 normally preserved in macro definitions but this option can be turned off see the OPT directive this chapter Comments can occupy an entire line or can be placed after the last assembler significant field in a source statement A comment starting in the first column of
70. D4 L R REG2 ENDM 114 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives ENDSEC End Section ENDSEC Every SECTION directive must be terminated by an ENDSEC directive A label is not allowed with this directive See also SECTION EXAMPLE SECTION COEFF ORG K VALUES BSC 100 Initialize to zero ENDSEC Freescale DSP Assembler Reference Manual 115 Chapter 6 Assembler Significant Characters and Directives Assembler Directives EQU Equate Symbol to a Value lt label gt EQU X Y L P lt expression gt The EQU directive assigns the value and memory space attribute of lt expression gt to the symbol lt label gt If lt expression gt has a memory space attribute of None then it can op tionally be preceded by any of the indicated memory space qualifiers to force a memory space attribute An error will occur if the expression has a memory space attribute other than None and it is different than the forcing memory space attribute The optional forcing memory space attribute is useful to assign a memory space attribute to an expression that consists only of constants but is intended to refer to a fixed address in a memory space The EQU directive is one of the directives that assigns a value other than the program counter to the label The label cannot be redefined anywhere else in the program or sec tion if SECTION directives are bein
71. DO loop is greater than or equal to the end address of the loop enclosing it The end address of a nested DO instruction must be less than the end address of the enclosing loop Instruction cannot appear in interrupt vector locations Some instructions cannot be used reliably as interrupt code These instructions in clude RTI RTS DO and ENDDO Instruction does not allow data movement specified using MOVE encoding Instruction does not allow data movement specified using MOVEP encoding Instruction does not allow data movement specified using MOVES encoding An inappropriate MOVE type instruction was written given the type of the oper ands The assembler substitutes a valid encoding for the operands in question Invalid destination register for this instruction using TFR3 encoding The destination register for a TFR2 instruction was not either X or Y Invalid interrupt vector address using SWI address Currently only the SWI address is supported by the TRAPcc instruction UO short absolute address cannot be forced I O short absolute addressing is not valid for this operation An appropriate ad dressing mode long absolute short jump short absolute is substituted UO short absolute address cannot be forced long substituted I O short absolute addressing is not valid for this operation The assembler substi tutes long absolute addressing UO short address cannot be forced I O short addressing is not valid for this operatio
72. EF The X space data will be addressed through the Low 48 DSP Assembler Reference Manual Freescale Chapter 4 Software Project Management Example 1 Multi Programmer Environment runtime counter The P memory code is also private to the _O section and uses the de fault runtime location counter for address generation In the discussion below assume that the programmers responsible for the FILTER and MAIN sections have similar program structures located in files named FILTER ASM and MAIN ASM respectively The program units can be combined either by invoking a final assembly step to assign absolute addresses or by assembling the modules separately and then linking 4 6 1 Absolute Mode Implementation To assemble the entire project source code a new file called PROJECT ASM would be created and would have the form ORG XLE 0000 SE low memory X storage declarations if any gt ORG YLE 0000 BE low memory Y storage declarations if any gt ORG YH FFCO lt olobal high memory Y storage declarations if any gt ORG XH FFCO zabal high memory X storage declarations if any gt initialize internal low Program memory location counter ORG PL 1000 initialize external high Program memory location counter ORG PHE F000 INCLUDE MAIN ASM INCLUDE IO ASM INCLUDE FILTER ASM END ENTRY This file provides the project manager with a mechanism to organize memory utilization to suit the application For example the external
73. ENDSEC directive was encountered without a preceding SECTION directive ENDW without associated WHILE directive An end of loop directive was encountered before a matching loop structured con trol statement EQU requires label The EQU directive must have a label to associate with the equated expression EXITM without associated MACRO directive An EXITM directive was encountered without a preceding MACRO directive Expression cannot have a negative value Some directives do not allow negative expression arguments as for example in the PAGE directive controls Expression contains forward references Some directives do not allow expression arguments which have not yet been de fined in the source as for example in the IF EQU or SET directives Expression involves incompatible memory spaces The memory space attribute is regarded by the assembler as a type in the same sense that high level languages use type for variables Symbols may have memory space attributes of X Y L P rogram or N one only N is fully compatible with all other attributes In this case two operands were evaluated with different memory space attributes neither of which was N Expression must be greater than zero Some directives require a nonzero argument as for example in the BSC directive 200 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Expression result must be absolute Certain directives and some assembl
74. Figure E 21 Tag Name Symbol Auxiliary Entry D 3 4 6 4 End of Structures The format for C language end of structure auxiliary entries is given in Figure E 22 Note that the size of the structure union or enumeration is given in words rather than bytes The tag index holds the symbol table index for the tag record associated with this struc ture Freescale DSP Assembler Reference Manual 253 Appendix D Freescale DSP Object File Format COFF Object File Components Declaration Name Description long int x_tagndx Tag index Unused zero filled unsigned long Size of structure union or enumeration in words Unused zero filled Figure E 22 End of Structure Auxiliary Entry D 3 4 6 5 Functions Function auxiliary entries have the format shown in Figure E 23 Note that the size of the function is given in words rather than bytes The function tag index holds the symbol table index to the begin function symbol for this function The x_endndx field points to the next function symbol table entry The x_Innoptr field contains a byte offset pointer within the object file to the line number entry that signals the start of this function see section D 3 3 3 Line Numbers for more information Declaration Name Description long int x_tagndx Tag index long int Size of function in words Unused zero filled long int x_Innoptr File pointer to line number entry long int x_endndx Index of
75. Freescale Digital Signal Processing Development Software Freescale DSP Assembler Reference Manual DSPASMRM e z freescale semiconductor How to Reach Us Home Page www freescale com E mail support freescale com USA Europe or Locations Not Listed Freescale Semiconductor Technical Information Center CH370 1300 N Alma School Road Chandler Arizona 85224 1 800 521 6274 or 1 480 768 2130 support freescale com Europe Middle East and Africa Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen Germany 44 1296 380 456 English 46 8 52200080 English 49 89 92103 559 German 33 1 69 35 48 48 French support freescale com Japan Freescale Semiconductor Japan Ltd Headquarters ARCO Tower 15F 1 8 1 Shimo Meguro Meguro ku Tokyo 153 0064 Japan 0120 191014 or 81 3 5437 9125 support japan freescale com Asia Pacific Freescale Semiconductor Hong Kong Ltd Technical Information Center 2 Dai King Street Tai Po Industrial Estate Tai Po N T Hong Kong 800 2666 8080 support asia freescale com For Literature Requests Only Freescale Semiconductor Literature Distribution Center P O Box 5405 Denver Colorado 80217 1 800 521 6274 or 303 675 2140 Fax 303 675 2150 LDCForFreescaleSemiconductor hibbertgroup com Information in this document is provided solely to enable system and software implementers to use Freescale Semi
76. 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 Freescale DSP Assembler Reference Manual 77 Chapter 6 Assembler Significant Characters and Directives Assembler Directives A Macro Local Label Override The circumflex when used as a unary expression operator in a macro expansion will cause any local labels in its associated term to be evaluated at normal scope rather than macro scope This means that any underscore labels in the expression term following the circumflex will not be searched for in the macro local label list The operator has no effect on normal labels or outside of a macro expansion The circumflex 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 EXAMPLE Consider the following macro definition LOAD MACRO ADDR MOVE P ADDR RO 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 recognizes the _LOCAL symbol outside the macro expansion and uses that value in the MOVE instruction 78 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Charact
77. I FUNCTION If lt expression gt is true execute lt stmtlist gt following THEN the keyword THEN is optional if lt expression gt is false execute lt stmtlist gt following ELSE if present otherwise advance to the instruction following ENDI DSP Assembler Reference Manual 171 Chapter 7 Structured Control Statements Syntax NOTES In the case of nested IF THEN ELSE statements each ELSE refers to the most recent IF THEN sequence EXAMPLE JE lt EQ gt zero bit set ENDI 7 3 5 LOOP Statement SYNAX LOOP lt cnt gt lt stmtlist gt ENDL FUNCTION Execute lt stmtlist gt lt cnt gt times This is similar to the FOR loop construct except that the initial counter and step value are implied to be 1 It is ac tually a shorthand method for setting up a hardware DO loop on the DSP without having to worry about addressing modes or label placement NOTES Since the LOOP statement generates instructions for a hardware DO loop the same restrictions apply as to the use of certain instructions near the end of the loop nesting restrictions etc One or more CONTINUE directives inside a LOOP construct will generate a NOP instruction just before the loop address EXAMPLE LOOP LPCNT hardware loop LPCNT times ENDL 172 DSP Assembler Reference Manual Freescale Chapter 7 Structured Control Statements Syntax 7 3 6 REPEAT Statement SYNTAX REPEAT lt stmtlist gt UNTIL
78. INTR 137 139 LB 137 139 LDB 137 139 listing format 135 LOC 136 139 MC 136 139 MD 136 139 message 136 MEX 136 139 MI 137 139 MSW _ 136 139 MU 136 139 NL 136 139 NOAE 139 NOCC 139 NOCEX 139 NOCK 139 NOCL 139 NOCM 140 NODEX 140 NODLD 140 NODXL 140 NOFC 140 NOFF 140 NOFM 140 NOGS 140 NOHDR 140 NOINTR 140 NOMC 140 NOMD 140 NOMEX 140 NOMI 140 NOMSW_ 140 NONL 140 NONS 140 NOPP 140 NOPS 140 NORC 140 NORP 140 278 NOSCL 140 NOSI 140 NOU 141 NOUR 141 NOW 141 NS 136 141 PP 135 141 PS 137 141 PSM 137 RC 135 141 reporting 136 RP 1387 141 RSV 137 S 136 141 SCL 136 141 SCO 136 141 SI 137 141 SO 136 141 SVO 137 symbol 136 U 136 142 UR 136 142 W 136 142 WEX 142 XLL 136 142 XR 136 142 Overlay 8 45 51 bootstrap 54 P Program counter 82 143 R Relative expression 17 Relative mode 9 Relocation 239 260 Runtime address 8 Runtime location counter 9 Runtime memory space 8 9 DSP Assembler Reference Manual Freescale D Section 37 155 block data 261 data hiding 38 end 115 fragmented 40 global 39 120 138 155 header 237 local 39 127 155 macro 40 nested 40 141 relocation 41 static 42 138 155 symbol 38 Source file 7 11 end 111 format 12 String 11 concatenation 12 83 84 delimiter 79 packed 141 position 33 substring 12 Symbol 11 case 138 cross reference 138 equate 116 138 global 138 listing 141 set 121 158 strip 7 undefined 142
79. NITIALIZE COUNT Freescale DSP Assembler Reference Manual 121 Chapter 6 Assembler Significant Characters and Directives Assembler Directives HIMEM Set High Memory Bounds HIMEM lt mem gt lt rl gt lt expression gt The HIMEM directive establishes an absolute high memory bound for code and data gen eration lt mem gt corresponds to one of the DSP memory spaces X Y L P lt rl gt is one of the letters R for runtime counter or L for load counter The lt expression gt is an absolute integer value within the address range of the machine If during assembly the specified location counter exceeds the value given by lt expression gt a warning is issued A label is not allowed with this directive See also LOMEM EXAMPLE HIMEM XR 7FFF YR 7FFF SET X Y RUN HIGH MEM BOUNDS 122 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives IDENT Object Code Identification Record lt label gt IDENT lt expression1 gt lt expression2 gt The IDENT directive is used to create an identification record for the object module If lt la bel gt is specified it will be used as the module name If lt label gt is not specified then the filename of the source input file is used as the module name lt expression1 gt is the ver sion number lt expression2 gt is the revision number The two expressions must each evaluate to an integer result The co
80. R Shift right then add ASL Arithmetic shift accumulator left ASR Arithmetic shift accumulator right CLR Clear accumulator CMP Compare CMPM Compare magnitude Instruction allows parallel data move Freescale DSP Assembler Reference Manual 267 Appendix E Instruction Set Information DSP56300 Information DEC Decrement accumulator DIV Divide iteration INC Increment accumulator MAC Signed multiply accumulate MACR Signed multiply accumulate and round MPY Signed multiply MPYR Signed multiply and round NEG Negate accumulator NORM Normalize accumulator iteration RND Round accumulator SUB Subtract SUBL Shift left then subtract SUBR Shift right then subtract Tee Transfer conditionally TFR Transfer data ALU register TST Test E 1 1 2 Logical Instructions The DSP56300 instructions used for logical operations are AND Logical AND ANDI AND Immediate with control register EOR Logical exclusive OP LSL Logical shift accumulator left LSR Logical shift accumulator right NOT Logical complement on accumulator OR Logical inclusive OR ORI OR immediate with control register ROL Rotate accumulator left ROL Rotate accumulator right E 1 1 3 Bit Manipulation Instructions The DSP56300 instructions used for bit manipulation are BCHG Bit test and change BCLR Bit test and clear BSET Bit test and set BTST Bit test on memo
81. 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 then the sequence of events would be as follows the macro processor would first substi tute the characters AREG for each occurrence of REG1 and BREG for each occurrence of REG2 For discussion purposes this would never appear on the source listing the intermediate macro expansion would be MOVE R AREG X0 MOVE R BREG R AREG MOVE X0 R BREG The macro processor would then replace 7AREG with the character 0 and BREG with the character 1 since 0 is the value of the symbol AREG and 1 is the value of BREG The resulting intermediate expansion would be MOVE R O X0 MOVE R 1 R 0 MOVE XO0 R 1 Next the macro processor would apply the concatenation operator and the resulting expansion as it would appear on the source listing would be MOVE RO X0 MOVE Ri1 RO MOVE X0O R1 62 DSP Assembler Reference Manual Freescale Chapter 5 Macro Operations and Conditional Assembly Dummy Argument Operators 5 5 3 Return Hex Value operator The percent sign is similar to the standard return value operator except that it returns the hexadecimal value of a symbol When the macro processor encounters this operator the lt symbol gt sequence is converted to a character string representing the hexadecimal value of the lt symbol gt Consider the following macro definition GEN_LAB MACRO LA
82. R X CNT 0 TO Y targ 2 1 BY CVI POW 2 0 CVF R In the example above the FOR loop operands represented as assembler expressions symbol function do not have embedded white space whereas the loop operands are always separated from structured control statement keywords by white space The count field of a LOOP statement must be separated from the LOOP directive by white space The count itself may be any arbitrary assembler expression and therefore must not contain embedded blanks 7 5 3 Assembly Listing Format Structured control statements begin with the directive in the opcode field any optional la bel is output in the label field The rest of the statement is left as is in the operand field except for any trailing comment the X and Y data movement fields are ignored Com ments following the statement are output in the comment field unless the unreported comment delimiter is used see Chapter 6 Statements are expanded using the macro facilities of the assembler Thus the generated code can be sent to the listing by specifying the MEX assembler option either via the OPT directive Chapter 6 or the O command line option Chapter 1 7 6 Effects on the Programmer s Environment During assembly global labels beginning with Z_L are generated They are stored in the symbol table and should not be duplicated in user defined labels Because these non lo cal labels ordinarily are not visible to the programmer there can
83. SE directives will be skipped and the statements between the ELSE and ENDIF directives will be assembled The lt expression gt must have an absolute integer result and is considered true if it has a nonzero result The lt expression gt is false only if it has a result of 0 Because of the nature of the directive lt expression gt must be known on pass one no forward references al lowed IF directives can be nested to any level The ELSE directive will always refer to the nearest previous IF directive as will the ENDIF directive A label is not allowed with this directive See also ENDIF EXAMPLE IF LST gt 0 DUP LST Unwind LIST directive stack NOLIST ENDM ENDIF 124 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives INCLUDE Include Secondary File INCLUDE lt string gt lt lt string gt gt This directive is inserted into the source program at any point where a secondary file is to be included in the source input stream The string specifies the filename of the secondary file The filename must be compatible with the operating system and can include a direc tory specification If no extension is given for the filename a default extension of ASM is supplied The file is searched for first in the current directory unless the lt lt string gt gt syntax is used or in the directory specified in lt string gt If the file is not found and
84. T1 CLN The listing file shows that the starting address of the section is zero howev er because of the LB option on the command line the load counter will increment at three times the rate of the runtime counter assuming a 24 bit DSP56300 family target proces sor A similar command is used to assemble the SECT2 module The two files are linked as follows DSPLNK BBOOTPROJ CLD OPI 1 100 OPE 2 CO00 SECT1 SECT2 The linker scans the command line and sets the base addresses for P internal and exter nal memory The quotes around the O options are necessary to avoid interpretation of parentheses by some host command interpreters Here the P counter number 1 is set to hex 100 and mapped to internal memory likewise the P counter number 2 is set to hex C000 and mapped to external memory Base addresses can also be established with the linker memory control file Since no explicit overlay base addresses were encountered in the source files both load and runtime addresses for the sections will be adjacent and non overlapping Assuming a code size of 2 for each section and a 16 bit word size the value for label START1 will be hex 100 and the value for START2 will be hex 102 the corresponding load addresses will be C000 hex and C004 hex respectively The execut able output will be written to the file BOOTPROJ CLD 56 DSP Assembler Reference Manual Freescale Chapter 5 Macro Operations and Conditional Assembly 5 1 Macro Operations Progr
85. TH lt exp2 gt Page length in terms of total number of lines per page default 66 min 10 max 255 As a special case a page length of 0 zero turns off all headers titles sub titles and page breaks BLANK_TOP lt exp3 gt Blank lines at top of page default 0 min 0 max see below BLANK_BOTTOM lt exp4 gt Blank lines at bottom of page default 0 min 0 max see below BLANK_LEFT lt exp5 gt Blank left margin Number of blank columns at the left of the page default 0 min 0 max see below Freescale DSP Assembler Reference Manual 147 Chapter 6 Assembler Significant Characters and Directives Assembler Directives The following relationships must be maintained BLANK_TOP BLANK_BOTTOM lt PAGE_LENGTH 10 BLANK_LEFT lt PAGE_WIDTH See also LSTCOL EXAMPLE PAGE 132 3 3 Set width to132 3 line top bottom margins PAGE Page eject 148 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives PMACRO Purge Macro Definition PMACRO lt symbol gt lt symbol gt lt symbol gt The specified macro definition will be purged from the macro table allowing the macro ta ble space to be reclaimed A label is not allowed with this directive See also MACRO EXAMPLE PMACRO MAC1 MAC2 This statement would cause the macros named MAC1 and MAC2 to be purged Freescale DSP Assembler Reference Manual 149 Chapter 6 Assembler Sig
86. U COH VAL compute hyperbolic cosine COS lt expression gt Returns the cosine of lt expression gt as a floating point value The memory space attribute of the result will be None Example DC COS CVF COUNT FREQ compute cosine value CTR L R If L is specified as the argument returns the counter number of the load location counter If R is specified returns the counter number of the runtime location counter The counter number is returned as an integer value with memory space of None Example CNUM CTR R runtime counter number 28 DSP Assembler Reference Manual Freescale Chapter 3 Expressions Functions CVF lt expression gt Converts the result of lt expression gt to a floating point value The memory space attribute of the result will be None Example FLOAT SET CVF 5 FLOAT 5 0 CVI lt expression gt Converts the result of lt expression gt to an integer value This function should be used with caution since the conversions can be inexact e g floating point values are truncated The memory space attribute of the result will be None Example INT SET CVI 1 05 INT 1 CVS X Y L P N lt expression gt Converts the memory space attribute of lt expression gt to that specified by the first argument returns lt expression gt See section 3 3 for more information on memory space attributes The lt expression gt may be relative or absolute Example
87. UNT ASR BY COUNT ASR DO ENDM would generate the following in the source listing COUNT SET 3 DUP COUNT ASR BY COUNT ASR DO ASR DO ASR DO ENDM 104 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives Note that the lines DUP COUNT ASR BY COUNT ENDM will only be shown on the source listing if the MD option is enabled The lines ASR DO ASR DO ASR DO will only be shown on the source listing if the MEX option is enabled See the OPT directive in this chapter for more information on the MD and MEX options Freescale DSP Assembler Reference Manual 105 Chapter 6 Assembler Significant Characters and Directives Assembler Directives DUPA Duplicate Sequence With Arguments lt label gt DUPA lt dummy gt lt arg gt lt lt arg gt lt arg gt ENDM The block of source statements defined by the DUPA and ENDM directives will be repeat ed for each argument For each repetition every occurrence of the dummy parameter within the block is replaced with each succeeding argument string If the argument string is a null then the block is repeated with each occurrence of the dummy parameter re moved If an argument includes an embedded blank or other assembler significant char acter it must be enclosed with single quotes lt label gt if present will be assigned the value of the runtime location counter at the start of the DUPA directive
88. Union or Enumeration Name Auxiliary Entry D 3 4 7 Object File Comments Object file comments are stored in a single COFF symbol table entry The symbol name field contains the special comment string cmt The n_address field points to the com ment text as an offset into the string table Comments generated automatically by the as sembler or via the IDENT directive have an n_scnum field with value of 1 Comments produced with the COBJ directive generally have the section number of the COFF section in which they reside The type and storage class fields are both zero D 3 5 String Table Symbol and section names longer than seven characters and comment text are stored contiguously in the string table with each string delimited by a zero byte The first four bytes represent the size of the string table in bytes offsets into the string table therefore are always greater than or equal to 4 An empty string table has a length field with value zero D 4 Differences in DSP Object Format and Standard COFF Freescale DSP COFF is substantially the same as generic COFF and usage of format el ements is similar However the original COFF specification did not envision aspects of machine architecture which the Freescale DSP family possesses Moreover standard COFF encompasses a file format which is quite adaptable among host processors but is not necessarily portable among those hosts It is straightforward enough to adapt COFF to a new host machine
89. Y S cavanwectrcsutie suas dbacertazetiandeesesVaesayiayivariaaseuseunts meter aeaa 255 D 3 4 6 7 End of Blocks and Functions c cccecceeeeeeeeeeeeeeeeeeeeeeeeeeeeees 255 D 3 4 6 8 Beginning of Blocks and Functions 256 D 3 4 6 9 Structure Union and Enumeration Names sssssseeeeennnnnneeeeea 256 D 3 4 7 Object File Comments EE 257 D 3 5 Sting RE i nee ee errr er eee eer meer ene RRC Teen en 257 D 4 Differences in DSP Object Format and Standard COFF ssnsssneaaeaaaeeene 257 D 4 1 Multiple Memory Spaces ele Wi aia 258 D 4 2 Object File TranS Portability 7 sinc ceteeseiasesasuashaavavaisecspccabueddeaylaaeasnvueseoaerxs 259 D 4 3 Structure Size Fields sscse sccccct cccessesdeaccdddedaceaassassuscccdectdcabaseassanseuscadtoasaes 260 D 4 4 Relocation tele RE 260 D 4 5 Gelee 261 D 4 6 er beer 261 D 5 Object File Data Expression Fomat 261 D 5 1 Data Expression Generation etiscesczssceaxneoinac des tenragssaeaesiaiylaaitenaesaesteens 262 D 5 2 Data Expression Ioterpretaton E 262 D 5 2 1 User Expression E ace E 263 D 5 2 2 Relocatable Expression TL 263 D 5 2 3 Memory Space Operator 0 263 D 5 2 4 Bit Size Oper tor EE 263 D 5 2 5 Memory Attribute Operator 264 D 5 2 6 Line Number Operator 1 264 x DSP Assembler Reference Manual Freescale Table of Contents continued D 5 2 7 BFxxx Instruction Mask Function GrEBEI 264 D 5 2 8 Local Relocatable Reference Function oLPDEI 264 D 5 2 9 Alternate En
90. age length of zero Explicit top margin ignored with page length of zero The top or bottom margin parameters to a PAGE directive are ignored because the page length parameter was zero Expression involves incompatible memory spaces The memory space attribute is regarded by the assembler as a type in the same sense that high level languages use type for variables Symbols may have memory space attributes of X Y L P rogram or N one only N is fully compatible with all other attributes In this case two operands were evaluated with different memory space attributes neither of which was N Expression value outside fractional domain The expected fractional value was not within the range 1 0 lt m lt 1 Extra dimensions ignored A source level debug DIM directive contained more than four arguments specify ing the dimensions of an array Freescale DSP Assembler Reference Manual 189 Appendix C Assembler Messages Warnings FMPY suffix ignored using secondary opcode suffix The single or extended precision suffix on a dual opcode instruction has been ig nored The precision is taken from the suffix on the secondary opcode Immediate value too large to use short long substituted An immediate data value being forced short is too large to fit in the space allocated for a short immediate value The assembler substitutes long immediate address ing Improper nesting of DO loops The end address of a subordinate nested
91. alue of zero is assumed If the runtime location counter is not zero this directive first advances the runtime location counter to a base address that is a multiple of 2 where 2 is greater than or equal to the value of the first expression An error will occur if the first expression contains symbols that are not yet defined forward references or if the expression has a value of less than or equal to zero Also if the first expression is not a power of two a warning will be gener ated Both expressions can have any memory space attribute lt label gt if present will be assigned the value of the runtime location counter after a valid base address has been established Only one word of object code will be shown on the listing regardless of how large the first expression is However the runtime location counter will be advanced by the number of words generated See also BSC BSM DC EXAMPLE BUFFER BSB BUFSIZ INITIALIZE BUFFER TO ZEROS 92 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives BSC Block Storage of Constant lt label gt BSC lt expression gt lt expression gt The BSC directive causes the assembler to allocate and initialize a block of words The number of words in the block is given by the first expression which must evaluate to an absolute integer Each word is assigned the initial value of the second expression If there is no se
92. ame section name The reuse of the section name is allowed to permit the program source to be arranged in an arbitrary manner for example all statements that reserve X space storage locations grouped together but re tain the privacy of the symbols for each section 40 DSP Assembler Reference Manual Freescale Chapter 4 Software Project Management Sections and Relocation 4 4 Sections and Relocation When the assembler operates in relative mode the default sections act as the basic grouping for relocation of code and data blocks For every section defined in the source a set of location counters is allocated for each DSP memory space These counters are used to maintain offsets of data and instructions relative to the beginning of the section At link time sections can be relocated to an absolute address loaded in a particular order or linked contiguously as specified by the programmer Sections which are split into parts or among files are logically recombined so that each section can be relocated as a unit Sections may be relocatable or absolute In the assembler absolute mode command line A option all sections are considered absolute In relative mode all sections are initially relocatable However a section or a part of a section may be made absolute either im plicitly by using the ORG directive or explicitly through use of the MODE directive If the assembler encounters an ORG directive with an absolute runtime address spe
93. amming applications frequently involve the coding of a repeated pattern or group of instructions 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 in struction group In either case macros provide a shorthand notation for handling these instruction patterns Having determined the iterated pattern the programmer can within the macro designate selected fields of any statement as variable Thereafter by invoking a macro the programmer can use the entire pattern as many times as needed substituting different parameters for the designated variable portions of the statements When the pattern is defined it is given a name This name becomes the mnemonic by which the macro is subsequently invoked called If the name of the macro is the same as an existing assembler directive or mnemonic opcode the macro will replace the direc tive or mnemonic opcode and a warning will be issued The warning can be avoided by the use of the RDIRECT directive which is used to remove entries from the assembler s directive and mnemonic tables If directives or mnemonics are removed from the assem bler s tables then no warning will be issued when the assembler processes macros whose names are the same as the removed directive or mnemonic entries However if a macro is defined through the MACLIB directive which has the same name as an existing directive or o
94. an include any legal source code statements Multiple MACLIB directives may be given in which case the assembler will search each directory in the order in which it is encountered A label is not allowed with this directive See also INCLUDE EXAMPLE MACLIB macros mymacs IBM PC example MACLIB fftlib UNIX example 130 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives MACRO Macro Definition lt label gt MACRO lt dummy argument list gt lt macro definition statements gt ENDM The dummy argument list has the form lt dumarg gt lt dumarg gt lt dumarg gt The required label is the symbol by which the macro will be called If the macro is named the same as an existing assembler directive or mnemonic a warning will be issued This warning can be avoided with the RDIRECT directive The definition of a macro consists of three parts the header which assigns a name to the macro and defines the dummy arguments the body which consists of prototype or skel eton source statements and the terminator The header is the MACRO directive its label and the dummy argument list The body contains the pattern of standard source state ments The terminator is the ENDM directive The dummy arguments are symbolic names that the macro processor will replace with ar guments when the macro is expanded called Each dummy argument must obey the
95. an insure that all section symbols are global GLOBAL without preceding SECTION directive A GLOBAL directive was encountered outside any previously defined section GS option must be used before any section The GS option must be activated before any explicit sections are encountered so that the assembler can use the appropriate counters for section relocation 202 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Hex constant expected A character other than ASCII 0 through 9 a through f or A through F either followed the hexadecimal constant delimiter or appeared in an expression where a hexadecimal value was expected by default IC option must be used before any symbol section or macro definition The IC option must be activated before any symbols sections or macros are de fined so that the assembler can remain consistent when storing label names in the symbol table IDENT directive must contain revision number IDENT directive must contain version number The version and revision numbers are both required arguments for the IDENT di rective Illegal directive in buffer declaration A directive was encountered between a BUFFER ENDBUF pair that is not allowed in that context Some invalid directives include any other buffer type directive DSM DSR etc section directives or any directive which alters the current loca tion counter designation MODE ORG illegal directi
96. anded argument has a leading underscore If there is no leading underscore on the actual argument then the override operator has no effect Consider the following macro call _LOCAL LOAD _LOCAL Without the local label override in the macro definition an error would occur at the macro call because a symbol _LOCAL was not defined in the body of the macro Because the circumflex was used the value of LLOCAL gets moved to RO Note that any arbitrary string may be used as the actual parameter to the LOAD macro The override operator has an effect only with underscore labels Care must be exercised however in not defining a 64 DSP Assembler Reference Manual Freescale Chapter 5 Macro Operations and Conditional Assembly DUP DUPA DUPC DUPF Di macro label called _LOCAL and attempting to reference it as in the above example In that case the macro local label override operator prevents the assembler from seeing the local label definition for that reference and an error would result 5 6 DUP DUPA DUPC DUPF Directives The DUP DUPA DUPC and DUPF directives are specialized macro forms They can be thought of as a simultaneous definition and call of an unnamed macro The source state ments between the DUP DUPA DUPC and DUPF directives and the ENDM directive fol low the same rules as macro definitions including in the case of DUPA DUPC and DUPF the dummy operator characters described previously For a detailed description of thes
97. apter 6 Assembler Significant Characters and Directives Assembler Directives UNDEF Undefine DEFINE Symbol UNDEF lt symbol gt The UNDEF directive causes the substitution string associated with lt symbol gt to be re leased and lt symbol gt will no longer represent a valid DEFINE substitution See the DE FINE directive for more information A label is not allowed with this directive See also DEFINE EXAMPLE UNDEF DEBUG _ UNDEFINES THE DEBUG SUBSTITUTION STRING Freescale DSP Assembler Reference Manual 163 Chapter 6 Assembler Significant Characters and Directives Assembler Directives WARN Programmer Generated Warning WARN lt str gt l lt exp gt lt str gt l lt exp gt lt str gt l lt exp gt The WARN directive will cause a warning message to be output by the assembler The total warning count will be incremented as with any other warning The WARN directive is normally used in conjunction with conditional assembly directives for exceptional con dition checking The assembly proceeds normally after the warning has been printed An arbitrary number of strings and expressions in any order but separated by commas with no intervening white space can be specified optionally to describe the nature of the gen erated warning A label is not allowed with this directive See also FAIL MSG EXAMPLE WARN parameter too large 164 DSP Assembler Reference Manual Freescale Chapter 6 Assembler S
98. ary file LOMEM Set low memory bounds MODE Change relocation mode MSG Programmer generated message ORG Initialize memory space and location counters RADIX Change input radix for constants RDIRECT Remove directive or mnemonic from table SCSJMP Set structured control branching mode SCSREG Reassign structured control statement registers UNDEF Undefine DEFINE symbol WARN Programmer generated warning Freescale DSP Assembler Reference Manual 181 Appendix B Directive Summary Symbol Definition B 2 Symbol Definition The directives used to control symbol definition are ENDSEC End section EQU Equate symbol to a value GLOBAL Global section symbol declaration GSET Set global symbol to a value LOCAL Local section symbol declaration SECTION Start section SET Set symbol to a value XDEF External section symbol definition XREF External section symbol reference B 3 Data Definition Storage Allocation The directives used to control constant data definition and storage allocation are BADDR Set buffer address BSB Block storage bit reverse BSC Block storage of constant BSM Block storage modulo BUFFER Start buffer DC Define constant DCB Define constant byte DS Define storage DSM Define modulo storage DSR Define reverse carry storage ENDBUF End buffer B 4 Listing Control and Options The directives used to control the output listing are LIST List the assembly
99. as the load location counter lt Imp gt Indicates the load physical mapping to DSP memory internal E exter nal R ROM A port A B port B If not present no explicit mapping is done lt Ice gt Non negative absolute integer expression representing the counter number to be used as the load location counter Must be enclosed in parentheses Should not exceed the value 65535 lt exp2 gt Initial value to assign to the load counter used as the Je If lt exp2 gt isa relative expression the assembler uses the relative location counter If lt exp2 gt is an absolute expression the assembler uses the absolute location counter If lt exp2 gt is not specified then the last value and mode that the counter had will be used If the last half of the operand field in an ORG directive dealing with the load memory space and counter is not specified then the assembler will assume that the load memory space and load location counter are the same as the runtime memory space and runtime loca tion counter In this case object code is being assembled to be loaded into the address and memory space where it will be when the program is run and is not an overlay If the load memory space and counter are given in the operand field then the assembler always generates code for an overlay Whether the overlay is absolute or relocatable de pends upon the current operating mode of the assembler and whether the load counter value is an absolute or
100. be output unless the RDIRECT directive has been used to remove the directive or mnemonic name from the assembler s tables Additionally if a macro is defined through the MACLIB directive which has the same name as an existing directive or opcode it will not automat ically replace that directive or opcode as previously described In this case the RDIRECT directive must be used to force the replacement Since the effect of this directive is global it cannot be used in an explicitly defined section see SECTION directive An error will result if the RDIRECT directive is encountered in a section A label is not allowed with this directive EXAMPLE RDIRECT PAGE MOVE This would cause the assembler to remove the PAGE directive from the directive table and the MOVE mnemonic from the mnemonic table 152 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives SCSJMP Set Structured Control Statement Branching Mode SCSJMP SHORT LONG NONE The SCSJMP directive is analogous to the FORCE directive but it only applies to branch es generated automatically by structured control statements see Chapter 7 There is no explicit way as with a forcing operator to force a branch short or long when it is produced by a structured control statement This directive will cause all branches resulting from subsequent structured control statements to be forced to the specified mode
101. be problems when local Freescale DSP Assembler Reference Manual 177 Chapter 7 Structured Control Statements Effects on the Programmer s Environment underscore labels are interspersed among structured control statements The SCL op tion see the OPT directive Chapter 6 causes the assembler to maintain the current local label scope when a structured control statement label is encountered In the FOR loop lt op1 gt is a user defined symbol When exiting the loop the memory register assigned to this symbol contains the value which caused the exit from the loop A compare instruction is produced by the assembler whenever two operands are tested in a structured statement At runtime these assembler generated instructions set the condition codes of the CCR in the case of a loop the condition codes are set repeatedly Any user written code either within or following a structured statement that references CCR directly move or indirectly conditional jump transfer should be attentive to the ef fect of these instructions Jumps or branches generated by structured control statements are forced long because the number and address of intervening instructions between a control statement and its termination are not known by the assembler The programmer may circumvent this be havior by use of the SCSJMP directive see Chapter 6 In all structured control statements except those using only a single condition code ex pression regis
102. ber of symbol table entries unsigned long f_opthdr Number of bytes in the optional header unsigned long Flags see Figure E 3 Figure E 2 File Header Format The magic number is a special code indicating the target machine for the object file DSP56300 etc The number of sections is useful for scanning the list of section head ers The date and time stamp is kept in binary form and may contain a host dependent time value The f_symptr field contains a file byte offset to the beginning of the symbol table The number of symbol table entries provides an upper bound for looping through the symbol table and an indirect means for accessing the start of the string table The size of the optional header allows for jumping to the start of the section header list Freescale DSP Assembler Reference Manual 233 Appendix D Freescale DSP Object File Format COFF Object File Components The flags field is a set of bit flags which convey status information about the object file It is used primarily by linkers debuggers and other loader software to determine whether the file is valid for a particular requested operation The individual bit flags are shown in Figure E 3 Mnemonic Flag Meaning F_RELFLG 0000001 Relocation information stripped from file F_EXEC 0000002 File is executable no unresolved external references F_LNNO 0000004 Line numbers stripped from file F_LSYMS 0000010 Local symbols stripped from
103. bject File SYMOBJ lt symbol gt lt symbol gt lt symbol gt The SYMOBJ directive causes information for each lt symbol gt to be written to the object file This directive is recognized but currently performs no operation in COFF assemblers see Appendix D A label is not allowed with this directive EXAMPLE SYMOBJ XSTART HIRTN ERRPROC 160 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives TABS Set Listing Tab Stops TABS lt tabstops gt The TABS directive allows resetting the listing file tab stops from the default value of 8 A label is not allowed with this directive See also LSTCOL EXAMPLE TABS 4 Set listing file tab stops to 4 Freescale DSP Assembler Reference Manual 161 Chapter 6 Assembler Significant Characters and Directives Assembler Directives TITLE Initialize Program Title TITLE lt string gt The TITLE directive initializes the program title to the string in the operand field The pro gram title will be printed on the top of all succeeding pages until another TITLE directive is encountered The title is initially blank The TITLE directive will not be printed in the source listing A TITLE directive with no string argument will cause the current title to be blank A label is not allowed with this directive See also STITLE EXAMPLE TITLE FIR FILTER 162 DSP Assembler Reference Manual Freescale Ch
104. bject File Data Expression For cards the reference symbol When the relocation entries are processed the resolved symbol value is used to modify the raw data indicated by the relocation entry at r_vaddr In Freescale DSP COFF r_symndkx is an offset into the string table which points to a re location expression The linker interprets this expression and updates the entire word at r_vaddr with the result of the expression evaluation The relocation type is always zero See section D 5 Object File Data Expression Format for more information on relocation expressions D 4 5 Block Data Sections Generic COFF does not make allowance for a block data section A block data section results from use of the assembler BSC directive where a large block of memory is initial ized with a single value Block data sections are handled in Freescale DSP COFF by making special use of the section s_vaddr field and adding an informative flag In most cases the section virtual address is the same as the physical address However for block data sections in Freescale DSP object files the virtual address field holds the re peat count for the single raw data value associated with the section For example if the assembly language source file included a directive of the form BSC 400 FFFF the s_vaddr field would contain the value 400 the s_size field would be 1 or 2 if in L mem ory and the single raw data word associated with the section would be FFFF In add
105. bler Reference Manual 45 Chapter 4 Software Project Management Address Assignment The values and memory space attributes of both the load and runtime location counters can be accessed with the LCV function see Section 3 8 This is particularly useful when assigning the load location counter value to a label as a reference point for the over lay manager part of the program The High Low default or numbered counter assign ment can be determined by using the CTR function Section 3 8 4 5 3 Address Assignment Examples Some examples of the ORG directive are as follows 46 ORG P 1000 Sets the runtime memory space to P Selects the default runtime counter counter 0 associated with P space to use as the runtime location counter and initializes it to 1000 The load memory space is implied to be P and the load location counter is assumed to be the same as the runtime location counter ORG PHE Sets the runtime memory space to P Selects the H load counter counter 2 as sociated with P space to use as the runtime location counter The H counter will not be initialized and its last value will be used Code generated hereafter will be mapped to external E memory The load memory space is implied to be P and the load location counter is assumed to be the same as the runtime location counter ORG PI OVL1 Y Indicates code will be generated for an overlay The runtime memory space is P and the default counter is use
106. buffer the remaining buffer locations will be uninitialized If more data is allocated than the specified size of the buffer an error is issued The BUFFER directive sets the runtime location counter to the address of a buffer of the given type the length of which in words is equal to the value of lt expression gt The buffer type may be either Modulo or Reverse carry If the runtime location counter is not zero this directive first advances the runtime location counter to a base address that is a mul tiple of 2K where 2k gt lt expression gt An error will be issued if there is insufficient memory remaining to establish a valid base address Unlike other buffer allocation directives the runtime location counter is not advanced by the value of the integer expression in the op erand field the location counter remains at the buffer base address The result of lt expression gt may have any memory space attribute but must be an abso lute integer greater than zero and cannot contain any forward references symbols that have not yet been defined If a Modulo buffer is specified the expression must fall within the range 2 lt lt expression gt lt m where m is the maximum address of the target DSP If a Reverse carry buffer is designated and lt expression gt is not a power of two a warning will be issued A label is not allowed with this directive See also BADDR BSM BSB DSM DSR ENDBUF EXAMPLE ORG X 100 BUFFER M 24
107. but the intent is that the derived host format will be recognized and executed only on that target host For Freescale DSP COFF the format had to be extend ed for cross development such that a given object file would be usable on all targeted host systems The following sections outline the differences and changes between standard COFF and Freescale DSP COFF Freescale DSP Assembler Reference Manual 257 Appendix D Freescale DSP Object File Format COFF Differences in DSP Object For D 4 1 Multiple Memory Spaces Standard COFF has no built in mechanism for accommodating multiple memory spaces It does handle the notion of separate text and data sections and a possible extension would have been to define section types for the new memory areas This quickly be comes unwieldy when mapping information internal external port A B is considered as well The solution was to extend addressing information to include the memory and mapping with the address value itself This is done by defining a C language typedef called CORE_ADDR which holds both the memory and mapping data along with the memory ad dress For any address context in the COFF file a CORE_ADDR is used rather than for example an unsigned long A description of the CORE_ADDR format is shown in Figure E 28 Declaration Name Description long w0 Memory address enum w1 mape Memory mapping Figure E 28 CORE_ADDR Format The enumeration values for the mem
108. cal negate operator relational operators and some functions return values that have a mem ory space attribute of N The result of an expression that has only one operand and pos sibly the unary negate or unary minus operator always has the memory attribute of that Freescale DSP Assembler Reference Manual 17 Chapter 3 Expressions Expression Memory Space Attribute operand Expressions that involve two or more operands and operators other than those mentioned above derive the memory space attribute of the result by examining the oper ands on the left and right side of an operator as shown in the following chart Left Operand Memory Space Attribute X Y L P N Right Operand X X 2 A X Memory Space Attribute Y Y Y j Y P g KR P P N X Y L P N Represents an illegal operation that will result in an error Notice that L memory space is regarded as a union of both X and Y space In expressions that have one element that has a memory space attribute of L and another element with a memory space attribute of either X or Y the result will have the more restrictive memory space attribute X or Y The memory space attribute is regarded by the assembler as a type in the same sense that high level languages use type for variables Symbols that are assigned memory space attributes of X Y L or P are assumed to be addresses and therefore can only have values between zero and the maximum address value of the DSP inclusive Only sy
109. cation ex pression The line number operator assists the linker in correlating source line numbers to expression terms which could be evaluated erroneously at link time e g forced oper ands which do not fit into the instruction word after relocation D 5 2 7 BFxxx Instruction Mask Function FBF The FBF function is generated by the assembler when the mask operand for a bitfield instruction is external The assembler passes a relocation expression to the function as an argument The linker evaluates the expression in parentheses and adjusts the associ ated instruction accordingly D 5 2 8 Local Relocatable Reference Function LRF The LRF function attempts to encapsulate more detail about a relocatable expression than is generated with other operators such as and Its main purpose is to provide sufficient information for evaluating local relocatable expressions that are referenced out side a defining context For example the assembler might produce an LRF function for a reference to an underscore label that is outside its defining section The function ar guments consist of the original relocatable expression the memory space mapping value the location counter designation the defining and relocation section numbers and any buffer or overlay sequence numbers associated with the expression 264 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Data Expression For
110. ce Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Components Mnemonic Meaning STYP_REG Regular section STYP_DSECT Dummy section STYP_NOLOAD Noload section STYP_GROUP Grouped section STYP_PAD Padding section STYP_COPY Copy section STYP_TEXT STYP_DATA Executable text section Initialized data section STYP_BSS Uninitialized data section STYP_BLOCK STYP_OVERLAY Block data section Overlay section STYP_MACRO Macro section Figure E 7 Section Header Flags Text sections are reserved for code to be loaded into program memory P space Data sections hold initialized data generated by assembler DC directives for example bound for data X Y L memory Bss sections are used for uninitialized blocks resulting from assembler DS and similar directives Padding sections are generated to provide align ment when a modulo or reverse carry buffer is declared The block section attribute flags a block data section described above The overlay flag indicates the section is part of an overlay Macro sections represent code and data generated during a macro expansion Dummy sections are used internally by the assembler to mark empty sections after the first assembly pass Empty sections may still appear in the object file if a symbol is asso ciated with a section which contains no data The noload group and copy attributes are
111. cifi cation it switches to absolute mode and begins generating absolute addresses within the enclosing section Note that the mode change is effective only if the assembler was start ed in relative mode if the A command line option is used the assembler always gener ates absolute addresses The assembler continues to generate absolute code until an ENDSEC directive is encountered or the mode is explicitly changed via the MODE direc tive The MODE directive allows for arbitrary switching between absolute and relocatable code generation MODE lt ABS OLUTE REL ATIVE gt The MODE directive may be issued at any time in the assembly source to alter the set of location counters used for section addressing Code generated while in absolute mode will be placed in memory at the location determined during assembly Relocatable code and data within a section are combined at link time even if absolute blocks are inter Freescale DSP Assembler Reference Manual 41 Chapter 4 Software Project Management Address Assignment spersed among relocatable blocks The MODE directive has no effect when the com mand line A option is active The following is an example SECTION EXAMPLE relocatable section code data generated here is relocatable MODE ABSOLUTE code data generated here is absolute it will be placed in memory at the location specified during assembly MODE REL back to relocatable code data generated here will be
112. coding Function GEN 265 Appendix E Instruction Set Information E 1 DSP56300 Be Weiden dE E 267 Ei Instruction Set SUMIMANys E 267 E 1 1 1 Arithmetic Geen EG 267 E 1 1 2 Logical Instructions sa taatieterc ct tt teste reretdacnabee rt itm eto nnn 268 E 1 1 3 Bit Manipulation Juegt EE ee 268 E 1 1 4 BOOP MSIMUCHONS Ragegebeeteeegndeee eteg tee eebe ege ege 269 E 1 1 5 Move Instructions Aere 269 E 1 1 6 Program Control Instructions ccceceeeeeeeeeeeeeeeeeetneeeeeeeeeeeeees 269 E 1 2 Register Names and Usage 2 2 ccccccceeeeeeeceeeeeeeeeeeeeeseseeeeeeeeeeeneees 270 E 1 3 Condition Code Mnemonice 270 Index Freescale DSP Assembler Reference Manual xi Table of Contents continued xii DSP Assembler Reference Manual Freescale A 1 A 3 A 4 A 6 A 7 A 9 A 10 A 11 A 12 A 13 A 14 A 15 A 16 A 17 A 18 A 19 A 20 A 21 A 22 A 23 A 24 A 25 Freescale List of Figures COFF Fil Basie Stu Cnure iif ies chrettebevenigealciniee hordes lick itveseedete hecevenendelerbenss 232 File Header Freet et edel 233 File Header Eeer 234 Freescale DSP Optional Link Header Format cccccccccccceeeeeeeeeeseeees 235 Freescale DSP Optional Runtime Header Format 0000000nnnnnnnnnnnennennne 236 Section Header et EE 237 Section Header Flags ENEE 239 Relocation Entry Formal isinira ineeie aiis 240 Line Number Entry Format EE 240 Line Number Grouping EE 241 COFF Symbol Table Ordering uk 24
113. combined with the previous relocatable block as long as memory space and mappings are compatible ORG P 200 code data generated here will be absolute until ENDSEC directive is found ENDSEC More information on the ORG and MODE directives can be found in Address Assignment and under the individual directive descriptions in Chapter 6 If the STATIC qualifier follows the lt section name gt in the SECTION directive then all code and data defined in the section until the next ENDSEC directive are relocated in terms of the immediately enclosing section The effect with respect to relocation is as if all code and data in the section were defined within the parent section This is useful when a sec tion needs data hiding but independent relocation is not required 4 5 Address Assignment The Freescale DSP assembler can support absolute address assignment at assembly time or generation of relocatable program addresses which are resolved during the linking phase The ORG directive is used to specify memory space changes mappings to phys ical memory and absolute address assignment 42 DSP Assembler Reference Manual Freescale Chapter 4 Software Project Management Address Assignment Various memory layouts require special handling for data generation or location counter updating In the case of L memory two words of code or data are produced for each in crement of the location counter The assembler allows for two sets of pro
114. compiled or assembled with the G debug option the relocation information is followed by source line number address entries The symbol table contains information on program symbols use ful by both the linker and the debugger The string table may contain very long symbolic names comment text or relocation expressions Note that the last four groups relocation info line number entries symbol table and string table may not appear if the linker S option is used to strip symbols from the object file 232 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Components D 3 Object File Components Following are detailed descriptions of each of the DSP COFF object file components The descriptions include the purpose of the component its structure in the object file and meanings of individual fields within the component D 3 1 File Header The file header is the first component in a COFF object file It contains information about the object file itself and is used for negotiating other components within the file There is only one file header per object file Figure E 2 shows the structure of the COFF file head er Declaration Name Description unsigned long f_magic Magic number unsigned long f_nscns Number of sections long int f_timdat Time and date when file was created long int f_symptr File pointer to the start of the symbol table long int f_nsyms Num
115. cond expression an initial value of zero is assumed If the first expression contains symbols that are not yet defined forward references or if the expression has a value of less than or equal to zero an error will be generated Both expressions can have any memory space attribute lt label gt if present will be assigned the value of the runtime location counter at the start of the directive processing Only one word of object code will be shown on the listing regardless of how large the first expression is However the runtime location counter will be advanced by the number of words generated See also BSM BSB DC EXAMPLE UNUSED BSC 2FFF LCV R FFFFFFFF FILL UNUSED EPROM Freescale DSP Assembler Reference Manual 93 Chapter 6 Assembler Significant Characters and Directives Assembler Directives BSM Block Storage Modulo lt label gt BSM lt expression gt lt expression gt The BSM directive causes the assembler to allocate and initialize a block of words for a modulo buffer The number of words in the block is given by the first expression which must evaluate to an absolute integer Each word is assigned the initial value of the second expression If there is no second expression an initial value of zero is assumed If the runtime location counter is not zero this directive first advances the runtime location counter to a base address that is a multiple of 2 where 2 is greater than or equal to the value
116. conductor products There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document Freescale Semiconductor reserves the right to make changes without further notice to any products herein Freescale Semiconductor makes no warranty representation or guarantee regarding the suitability of its products for any particular purpose nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit and specifically disclaims any and all liability including without limitation consequential or incidental damages Typical parameters that may be provided in Freescale Semiconductor data sheets and or specifications can and do vary in different applications and actual performance may vary over time All operating parameters including Typicals must be validated for each customer application by customer s technical experts Freescale Semiconductor does not convey any license under its patent rights nor the rights of others Freescale Semiconductor products are not designed intended or authorized for use as components in systems intended for surgical implant into the body or other applications intended to support or sustain life or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur Sh
117. correspon dences are defined 16 16 bit signed short immediate or offset 15 15 bit signed short PC relative address 7 7 bit signed short immediate or offset 6 6 bit signed short PC relative address 5 5 bit signed short offset sl Negated immediate shift O DSP word size immediate or absolute 1 Immediate shift Freescale DSP Assembler Reference Manual 263 Appendix D Freescale DSP Object File Format COFF Object File Data Expression For 5 5 bit short absolute 6 6 bit short immediate or absolute 7 7 bit short immediate absolute or offset 8 8 bit short immediate or absolute 12 12 bit short immediate or absolute 19 19 bit short immediate 85 86 87 5 6 7 bit I O short absolute D 5 2 5 Memory Attribute Operator The colon is used to assign a memory space and counter encoded in the right operand to the left operand The low sixteen bits of the right operand contain the counter designa tor for the left operand The high sixteen bits contain the memory space designator for the left operand The value here corresponds to the memory space values given for the memory space operator described above D 5 2 6 Line Number Operator The exclamation point is a binary operator that associates the source file line number of the left operand to the value of the right operand The left operand is a decimal value representing the source file line number The right operand is an arbitrary relo
118. counter 9 Load memory space 8 9 Local label 13 macro 13 Location counter 82 143 DSP Assembler Reference Manual Freescale M Macro 57 call 60 139 comment 138 definition 58 131 139 directive 131 end 114 exit 117 expansion 60 139 file 6 library 58 130 139 purge 149 Macro argument concatenation operator 61 74 local label override 64 local label override operator 78 return hex value operator 63 77 return value operator 62 76 string operator 63 Memory limit 122 128 utilization 15 139 Memory space 8 139 143 attribute 17 Be Object file 3 auxiliary entry 250 comment 96 257 261 data expression 261 differences 257 file header 233 format 231 identification 123 line number 240 optional header 234 relocation 239 260 section 236 section number 244 storage class 246 structure 231 structure size 260 symbol 141 160 symbol name 243 symbol table 241 symbol type 244 symbol value 243 transportability 259 Operand field 14 Operation field 14 Operator 20 arithmetic 21 bitwise 22 logical 22 precedence 23 relational 22 shift 21 unary 20 Option AE 136 137 assembler operation 137 CC 137 CEX 136 137 CK 137 CL 136 137 CM 1387 138 CONST 137 138 CONTC 138 CONTCK 137 138 CRE 136 138 DEX 136 138 DLD 137 138 DXL 136 138 FC 135 138 FF 135 138 FM 135 138 GL 137 138 GS 137 138 HDR 136 138 IC 136 138 Freescale DSP Assembler Reference Manual 277 Index IL 136 139
119. d as a CORE_ADDR structure with memory and mapping attributes Otherwise the contents are stored in the n_val field Whether the symbol value is an address or not depends on the storage class of the sym bol See section D 3 4 5 for more information on the relationship of symbol value and stor age class Freescale DSP Assembler Reference Manual 243 Appendix D Freescale DSP Object File Format COFF Object File Components D 3 4 3 Section Number The section number maps a symbol to its corresponding section in the object file e g the section in which the symbol is defined A special section number 2 marks symbolic debugging symbols including structure union enumeration tag names typedefs and the name of the file A section number of 1 indicates that the symbol has a value but is not relocatable Examples of absolute valued symbols include automatic and register vari ables function arguments and end of structure symbols A section number of 0 flags a relocatable external symbol that is not defined in the current file Section numbers greater than zero correlate to the ordinal sequence of sections in the object file D 3 4 4 Symbol Type The type field in the symbol table entry contains information about the basic and derived type for the symbol This information is generated by the compiler and assembler only if the G debug option is used Each symbol has exactly one basic or fundamental type but can have more than one derived ty
120. d as the runtime location counter It will be reset to the value of OVL1 If the assembler is in absolute mode via the A command line option then OVL1 must be an absolute expression If OVL1 is an absolute expres sion the assembler uses the absolute runtime location counter If OVL1 is a relo catable value the assembler uses the relative runtime location counter In this case OVL1 must not itself be an overlay symbol e g defined within an overlay block The load memory space is Y Since neither H L nor any counter expression was specified as the load counter the default load counter counter 0 will be used as the load location counter The counter value and mode will be whatever it was the last time it was referenced ORG XL E8 Sets the runtime memory space to X Selects the L counter counter 1 associated with X space to use as the runtime location counter The L counter will not be ini tialized and its last value will be used The load memory space is set to E and the qualifier 8 indicates a bytewise RAM configuration Instructions and data will be generated eight bits per output word with byte oriented load addresses The de fault load counter will be used and there is no explicit load origin DSP Assembler Reference Manual Freescale Chapter 4 Software Project Management Address Assignment ORG P 5 Y 8000 Indicates code will be generated for an absolute overlay The runtime memory space is P and the counter used as
121. d for a particular instruction is given in Appendix A of the User Manual for the DSP in question e g DSP56300 Family Manual The operand fields of assembler directives are de scribed in Chapter 6 The operand fields of macros Chapter 5 depend on the definition of the macro 2 4 4 Data Transfer Fields Most opcodes can specify one or more data transfers to occur during the execution of the instruction These data transfers are indicated by two addressing mode operands sepa rated by a comma with no embedded blanks If two data transfers are specified they 14 DSP Assembler Reference Manual Freescale Chapter 2 Writing Assembly Language Programs Assembler Output must be separated by one or more blanks or tabs See the appropriate DSP User s Man ual for a complete discussion of addressing modes that are applicable to data transfer specifications 2 4 5 Comment Field Comments are not considered significant to the assembler but can be included in the source file for documentation purposes A comment field is composed of any characters not part of a literal string that are preceded by a semicolon Acomment starting in the first column of the source file will be aligned with the label field in the listing file Otherwise the comment will be shifted right and aligned with the comment field in the listing file un less the NOPP option is used see the OPT directive Chapter 6 Comments preceded by two consecutive semicolons
122. e C_BLOCK C_FCN Beginning and end of block Beginning and end of function C_EOS End of structure C_FILE C language source filename C_LINE C_ALIAS Duplicated tag C_HIDDEN A_FILE A_SECT Assembly source filename Beginning and end of section A_BLOCK Beginning end of COFF section A_MACRO A_GLOBAL Macro expansion Global assembly language symbol A_XDEF XDEFed symbol A_XREF XREFed symbol A_SLOCAL Section local label A_ULOCAL Underscore local label A_MLOCAL Macro local label Figure E 15 Storage Classes continued The value of a symbol depends on its storage class This relationship is summarized in Figure E 16 248 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Components Storage Class Value C_AUTO Stack offset in words Relocatable address Relocatable address Register number Relocatable address Offset in words Stack offset in words C_ENTAG 0 0 0 0 0 C_MOE Enumeration value C_REGPARAM Register number C_FIELD Bit displacement C_BLOCK Relocatable address C_FCN Relocatable address C_EOS Size of structure in words see below Tag index Relocatable address Figure E 16 Storage Class and Value Freescale DSP Assembler Reference Manual 2
123. e Chapter 6 the assembler generates a report of load and runtime memory utilization The report shows beginning and ending addresses of allocated memory areas along with their lengths and associated symbol names if applicable A separate report is generated for each memory space where data has been reserved for use by the program The assembler object file is a binary COFF Common Object File Format file with exten sions and adaptations to support symbolic debugging and to make DSP object files trans portable among host platforms COFF is a formal definition for the structure of machine code files It is derived from AT amp T Unix System V and represents a quasi de facto stan dard for object file formats Refer to Appendix D for more information on Freescale DSP COFF structure and layout Freescale DSP Assembler Reference Manual 15 Chapter 2 Writing Assembly Language Programs Assembler Output 16 DSP Assembler Reference Manual Freescale Chapter 3 Expressions 3 1 Introduction An expression represents a value which is used as an operand in an assembler instruction or directive An expression is a combination of symbols constants operators and paren theses Expressions may contain user defined labels and their associated integer or float ing point values and or any combination of integers floating point numbers or ASCII literal strings In general white space a blank or tab is not allowed between the terms and operators
124. e In order to facilitate the generation of object code for overlays the assembler maintains two different location counters the load location counter which determines the address into which the object code will be loaded and the runtime location counter which determines the address assigned to labels In addition the assembler keeps track of the load memory space which is the memory space into which the object code will be loaded and the runtime memory space which is the mem ory space to which an overlay will be transferred and the memory space attribute that will be assigned to labels See Chapter 4 for a practical discussion of the use of memory spaces and location counters The Freescale digital signal processors are capable of performing operations on modulo and reverse carry buffers two data structures useful in digital signal processing applica tions The DSP assembler provides directives for establishing buffer base addresses al locating buffer space and initializing buffer contents For a buffer to be located properly in memory the lower bits of the starting address which encompass one less than the buffer size must be zero For example the lowest address greater than zero at which a buffer of size 32 may be located is 32 20 hexadecimal More generally the buffer base address must be a multiple of 2k where 2 is greater than or equal to the size of the buffer Buffers can be allocated manually or by using the assembler buffer di
125. e but data hiding within an enclosing section is not required Symbols that are defined with the SET directive can be made visible with XDEF only in absolute mode and the section name associated with the symbol will be the section name of the section where the symbol was first defined This will be true even if the symbol value is changed in another section Freescale DSP Assembler Reference Manual 39 Chapter 4 Software Project Management Sections and Data Hiding 4 3 2 Sections and Macros The division of a program into sections controls not only labels and symbols but also mac ros and DEFINE directive symbols Macros defined within a section are private to that section and are distinct from macros defined in other sections even if they have the same macro name Macros defined outside of sections are considered global and may be used within any section Similarly DEFINE directive symbols defined within a section are pri vate to that section and DEFINE directive symbols defined outside of any section are glo bally applied There are no directives that correspond to XDEF for macros or DEFINE symbols therefore macros and DEFINE symbols defined in a section can never be ac cessed globally If global accessibility is desired the macros and DEFINE symbols should be defined outside of any section Here is an example DEFINE DEFVAL T SECTION SECT1 DEFINE DEFVAL 2 MOVE DEFVAL RO ENDSEC MOVE DEFVAL R1 The second definition of
126. e memory space to which it is bound unless the STATIC qualifier follows the SECTION di rective on the instruction line More information on the STATIC qualifier is available in Sections and Relocation below Freescale DSP Assembler Reference Manual 37 Chapter 4 Software Project Management Sections and Data Hiding 4 3 Sections and Data Hiding Symbols within a section are generally distinct from other symbols used elsewhere in the source program even if the symbol name is the same This is true as long as the section name associated with each symbol is unique the symbol is not declared public XDEF or GLOBAL and the GLOBAL or LOCAL qualifiers are not used in the section declaration see below Symbols that are defined outside of a section are considered global symbols and have no explicit section name associated with them Global symbols may be refer enced freely from inside or outside of any section as long as the global symbol name does not conflict with another symbol by the same name in a given section Consider the fol lowing example SYM1 EQU 1 SYM2 EQU 2 SECTION EXAMPLE SYM1 EQU 3 MOVE SYM1 RO MOVE SYM2 R1 ENDSEC MOVE SYM1 R2 SYM1 and SYM2 are global symbols initially defined outside of any section Then in sec tion EXAMPLE another instance of SYM1 is defined with a different value Because SYM1 was redefined inside the section the value moved to RO will be 3 Since SYM2 is a global symbol the value moved t
127. e reported to Freescale File not encountered on pass 1 The file in the source input list was never processed by the assembler during pass 1 This is an internal error that should be reported to Freescale Immediate mode select error The mode indicator passed to the immediate addressing mode selection logic was not valid This is a serious internal error that should be reported to Freescale Input mode stack out of sequence The stack for recording whether input is from a file or a macro expansion has been corrupted This is an internal error that should be reported to Freescale Invalid DO loop range check The value passed to the end of DO loop verification logic is bad This is an internal error that should be reported to Freescale Invalid instruction class The saved MAC type instruction class has been corrupted This is an internal error that should be reported to Freescale Invalid tag storage class The saved tag storage class has been corrupted This is an internal error that should be reported to Freescale UO error writing data word to object file An I O error occurred which prevented the assembler from writing data to the out put object file Location bounds selection failure The logic for selecting the appropriate bounds array based on the current memory space has returned a bad value This is an internal error that should be reported to Freescale Option select error The option indicator passed to the
128. e DS directive reserves a block of memory the length of which in words is equal to the value of lt expression gt This directive causes the runtime location counter to be advanced by the value of the absolute integer expression in the operand field lt expression gt can have any memory space attribute The block of memory reserved is not initialized to any value The expression must be an integer greater than zero and cannot contain any for ward references symbols that have not yet been defined lt label gt if present will be assigned the value of the runtime location counter at the start of the directive processing See also DSM DSR EXAMPLE S BUF DS 12 SAMPLE BUFFER Freescale DSP Assembler Reference Manual 101 Chapter 6 Assembler Significant Characters and Directives Assembler Directives DSM Define Modulo Storage lt label gt DSM lt expression gt The DSM directive reserves a block of memory the length of which in words is equal to the value of lt expression gt If the runtime location counter is not zero this directive first advances the runtime location counter to a base address that is a multiple of 2k where 2k gt lt expression gt An error will be issued if there is insufficient memory remaining to es tablish a valid base address Next the runtime location counter is advanced by the value of the integer expression in the operand field lt expression gt can have any memory space attribute The block o
129. e DSP Assembler Reference Manual 97 Chapter 6 Assembler Significant Characters and Directives Assembler Directives DC Define Constant lt label gt DC lt arg gt lt arg gt lt arg gt The DC directive allocates and initializes a word of memory for each lt arg gt argument lt arg gt may be anumeric constant a single or multiple character string constant a symbol or an expression The DC directive may have one or more arguments separated by com mas Multiple arguments are stored in successive address locations If multiple argu ments are present one or more of them can be null two adjacent commas in which case the corresponding address location will be filled with zeros If the DC directive is used in L memory the arguments will be evaluated and stored as long word quantities Other wise an error will occur if the evaluated argument value is too large to represent in a sin gle DSP word lt label gt if present will be assigned the value of the runtime location counter at the start of the directive processing Integer arguments are stored as is floating point numbers are converted to binary values Single and multiple character strings are handled in the following manner 1 Single character strings are stored in a word whose lower seven bits repre sent the ASCII value of the character EXAMPLE R 000052 2 Multiple character strings represent words whose bytes are composed of concatenated sequenc
130. e assembly LSTCOL Set listing field widths NOLIST Stop assembly listing OPT Assembler options PAGE Top of page size page PRCTL Send control string to printer STITLE Initialize program subtitle TABS Set listing tab stops TITLE Initialize program title Freescale DSP Assembler Reference Manual 69 Chapter 6 Assembler Significant Characters and Directives Assembler Directives 6 3 5 Object File Control The directives used for control of the object file are COBJ Comment object code IDENT Object code identification record SYMOBJ Write symbol information to object file 6 3 6 Macros and Conditional Assembly The directives used for macros and conditional assembly are DUP Duplicate sequence of source lines DUPA Duplicate sequence with arguments DUPC Duplicate sequence with characters DUPF Duplicate sequence in loop ENDIF End of conditional assembly ENDM End of macro definition EXITM Exit macro IF Conditional assembly directive MACLIB Macro library MACRO Macro definition PMACRO Purge macro definition 6 3 7 Structured Programming The directives used for structured programming are BREAK Exit from structured loop construct CONTINUE Continue next iteration of structured loop ELSE Perform following statements when IF false ENDF End of FOR loop ENDI End of IF condition ENDL End of hardware loop ENDW End of WHILE loop FOR Begin FOR loop JE
131. e directives refer to Chapter 6 5 7 Conditional Assembly Conditional assembly facilitates the writing of comprehensive source programs that can cover many conditions Assembly conditions may be specified through the use of argu ments in the case of macros and through definition of symbols via the DEFINE SET and EQU directives Variations of parameters can then cause assembly of only those parts necessary for the given conditions The built in functions of the assembler provide a ver satile means of testing many conditions of the assembly environment see Section 3 8 for more information on the assembler built in functions Conditional directives can also be used within a macro definition to ensure at expansion time that arguments fall within a range of allowable 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 lt expression gt ELSE the ELSE directive is optional ENDIF A section of a program that is to be conditionally assembled must be bounded by an IF ENDIF directive pair If the optional ELSE directive is not present then the source state ments following the IF directive and up to the next ENDIF directive will be included as part of the source file being assembled only if the lt expression gt had a nonzero result If the lt expression gt has a value of zero the source file will be assembled as i
132. e file Unrecognized transformation mnemonic The lookup of an FADD or FSUB secondary operand failed This is an internal error that should be reported to Freescale Freescale DSP Assembler Reference Manual 229 Appendix C Assembler Messages Fatal Errors 230 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF D 1 Introduction The Freescale DSP assembler and linker produce a binary object file in a modified form of the AT amp T Common Object File Format COFF COFF is a formal definition for the structure of machine code files It originated with Unix System V but has sufficient flexi bility and generality to be useful in non hosted environments In particular COFF sup ports user defined sections and contains extensive information for symbolic software testing and debugging Later sections describe the COFF implementation for the Freescale family of digital signal processors The DSP COFF format has been altered to support multiple memory spaces and normalized to promote transportability of object files among host processors See section D 4 for a list of differences between the Freescale DSP object file format and stan dard COFF For a more general discussion of COFF the following reference may be use ful Gintaras R Gircys Understanding and Using COFF O Reilly amp Associates 1988 ISBN 0 937175 31 5 D 2 Object File Structure A DSP COFF object file consists of up to eight
133. e which options may be speci fied multiple times Option letters can be in either upper or lower case Command options that are used regularly may be placed in the environment variable DSPASMOPT If the variable is found in the environment the as sembler adds the associated text to the existing command line prior to pro cessing any options See your host documentation for instructions on how to define environment variables Option arguments may immediately follow the option letter or may be sepa rated from the option letter by blanks or tabs However an ambiguity arises if an option takes an optional argument Consider the following command line ASM56300 B MAIN IO In this example it is not clear whether the file MAIN is a source file or is meant to be an argument to the B option If the ambiguity is not resolved the assembler will assume that MAIN is a source file and attempt to open it for reading This may not be what the programmer intended There are several ways to avoid this ambiguity If MAIN is supposed to be an argument to the B option it can be placed immediately after the option letter ASM56300 BMAIN IO If there are other options on the command line besides those that take op tional arguments the other options can be placed between the ambiguous option and the list of source file names ASM56300 B MAIN V IO An alternative is to use two successive hyphens to indicate the end of the option list ASM56300 B
134. ective is used to assign the value of the expression in the operand field to the label The SET directive functions somewhat like the EQU directive However labels de fined via the SET directive can have their values redefined in another part of the program but only through the use of another SET directive The SET directive is useful in estab lishing temporary or reusable counters within macros The expression in the operand field of a SET must be absolute and cannot include a symbol that is not yet defined no forward references are allowed See also EQU GSET EXAMPLE COUNT SET 0 INITIALIZE COUNT 158 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives STITLE Initialize Program Sub Title STITLE lt string gt The STITLE directive initializes the program subtitle to the string in the operand field The subtitle will be printed on the top of all succeeding pages until another STITLE directive is encountered The subtitle is initially blank The STITLE directive will not be printed in the source listing An STITLE directive with no string argument will cause the current subtitle to be blank A label is not allowed with this directive See also TITLE EXAMPLE STITLE COLLECT SAMPLES Freescale DSP Assembler Reference Manual 159 Chapter 6 Assembler Significant Characters and Directives Assembler Directives SYMOBJ Write Symbol Information to O
135. ectly to DSP machine instructions Directive Special operation codes known to the assembler which control the assembly process Macro call Invocation of a previously defined macro which is to be inserted in place of the macro call The assembler first searches for operation codes in an internal macro definition table If no match is found the table of machine operation codes and assembler directives is searched If neither of the tables holds the specified operation code an error message is generated this sequence can be altered with the MACLIB directive Macro names can therefore replace standard machine operation codes and assembler directives although a warning will be issued if such a replacement occurs The warning can be avoided by use of the RDIRECT directive See Chapter 6 for more information on the MACLIB and RDIRECT directives 2 4 3 Operand Field The interpretation of the operand field is dependent on the contents of the operation field The operand field if present must follow the operation field and must be preceded by at least one space or tab The operand field may contain a symbol an expression or a com bination of symbols and expressions separated by commas There should be no inter vening whitespace characters separating operand elements The operand field of machine instructions is used to specify the addressing mode of the instruction as well as the operand of the instruction The format of the operand fiel
136. ed Gechons 40 Sections and Relocation EE 41 DSP Assembler Reference Manual Freescale 4 5 4 5 1 4 5 2 4 5 3 4 5 4 4 6 4 6 1 4 6 2 4 7 4 7 1 4 7 2 4 8 4 8 1 4 8 2 5 1 5 2 5 3 5 4 5 5 5 5 1 5 5 2 5 5 3 5 5 4 5 5 5 5 6 5 7 6 1 Table of Contents continued Address Zelt DEET sorires aiiai 42 The ORG Eelere AE 43 OV OTA Eege e 45 Address Assignment Exvamples A 46 Eeer EE 47 Example 1 Multi Programmer Environment AA 48 Absolute Mode Implementaton nn nnnernneeenne 49 Relative Mode Immplementaton rnrn nnn nnnnnnnnennneennn nnn 50 Example e EE 51 Absolute Mode Implementaton EEN 52 Relative Mode Implementatpon EEN 53 Example 3 Bootstrap Overlay ccccceceeeeeeeessnnnncncaeeeeeeeeeeeeeeeeeeeseeeeeeeseees 54 Absolute Mode Implementaton REENEN 55 Relative Mode Implementatpon REENEN 56 Chapter 5 Macro Operations and Conditional Assembly Macro Operations EE 57 Macro UE sese Ee ee 58 M cr Definito EE 58 Ee RTE 60 Dummy Argument Operators EEN 61 Dummy Argument Concatenation Operator A 61 Ret rn Value E Eeer 62 Return Hex Value operator 6 63 Dummy Argument String Operator A 63 Macro Local Label Override Operator 3 64 DUP DUPA DUPC DUPF DiIreClive sss seceitvcieetedeectediystvieteeteebehesceatvbeachenetes 65 ei Leute GIE LEE 65 Chapter 6 Assembler Significant Characters and Directives INTFODUCTION EE 67 Freescale DSP Assembler Reference Manual vii 6 2 6 3 6 3 1 6
137. ed by the as sembler will be loaded are referred to as the load memory space and load address re spectively Because the DSP architecture allows data transfers between memory spaces sometimes object code is loaded into an address of one memory space but will later be transferred to a different memory space and address before the program is run One ex ample of this might be a program located in an external EPROM that will be transferred into external program RAM before it is run The transfer of code data from one memory space address to a different memory space address is called an overlay When the object code for a part of the program is generated that later will be used as an overlay the load memory space and load address do not correspond to the memory space and address where the program will be run The memory space and address loca tion where the code data will be located when the program is run are referred to as the runtime memory space and runtime address respectively If the assembler only used the load address to assign values to labels then the program would not contain the cor 8 DSP Assembler Reference Manual Freescale Chapter 1 Freescale DSP Assembler Assembler Support for Digital Signal Processing rect label references when it was transferred to the runtime memory space and the run time address During the assembly process the assembler uses location counters to record the ad dresses associated with the object cod
138. ed control statements This op tion causes the assembler to maintain the current local label scope when a structured control statement label is encountered Send structured control statement labels to object and listing files Normally the assembler does not externalize these labels This option must appear be fore any symbol definition DSP56300 only Interpret an eight bit short immediate value moved to a frac tional register as a long unless forced short Write symbol information to object file This option is recognized but performs no operation in COFF assemblers Preserve object file on errors Normally any object file produced by the as sembler is deleted if errors occur during assembly This option must be given before any code or data is generated DSP Assembler Reference Manual 141 Chapter 6 Assembler Significant Characters and Directives Assembler Directives U UR W WEX XLL XR EXAMPLE 142 Print the unassembled lines skipped due to failure to satisfy the condition of a conditional assembly directive Generate a warning at assembly time for each unresolved external reference This option works only in relocatable mode default reset Print all warning messages Add warning count to exit status Ordinarily the assembler exits with a count of errors This option causes the count of warnings to be added to the error count Write underscore local labels to object file This is primarily used
139. eld of a parallel X memory and register move cannot be forced short The mode is changed to long immediate Contents of assigned register in previous instruction not available generating NOP instruction Due to pipelining if an address register Rn or Nn is changed in the previous in struction the new contents are not available for use as a pointer until the next in struction If the RP option is in effect see the OPT directive Chapter 6 the 188 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Warnings assembler produces this warning and generates a NOP prior to the offending in struction Debug directives ignored use command line debug option A source level debug directive was encountered but the assembler command line G option was not given Destination operand assumed I O short Neither operand in a MOVEP instruction is explicitly declared I O short however the source operand does not qualify so the destination operand is assumed to be the I O short operand Directive not allowed in command line absolute mode The MODE directive is ignored when the assembler command line A option is ac tive Duplicate listing file specified ignored Duplicate object file specified ignored The B or L command line options were given more than once ENDDO instruction not inside DO loop An ENDDO instruction was found outside the scope of an active DO loop Explicit bottom margin ignored with p
140. embly Language Programs 2 1 Input File Format Programs written in assembly language consist of a sequence of source statements 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 A source statement first line and any continuation lines can be a maximum of 255 characters long 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 If the source file contains horizontal tabs ASCII 09 the assembler will expand these to the next fixed tab stop located at eight character intervals column 1 9 17 unless reset using the TAB directive see Chapter 6 This is only significant if tab characters are em bedded within literal strings 2 2 Symbol Names Symbol names can be from one to 512 characters long The first character of a symbol must be alphabetic upper or lower case any remaining characters can be either alpha numeric A Z a z 0 9 or the underscore character _ Upper and lower case letters in symbols are considered distinct unless the IC option is in effect see the OPT directive Chapter 6 Valid loop_1 Invalid 1_loop ENTRY loop e a_B_c Certain identifiers are reserved by the assembler and cannot be used These identifiers are the upper or lower case name of any Freescale DSP processor
141. emory space can never be specified as the load memory space if runtime mem ory space is X Y or P LB option must be used before any code or data generation The LB option must be specified before any code or data in order for the assembler to increment the location counter appropriately LDB option must be used before any code or data generation The LDB option must be specified before any code or data in order for the assem bler to establish the debug source file appropriately Freescale DSP Assembler Reference Manual 209 Appendix C Assembler Messages Errors Left margin exceeds page width The blank left margin value in the PAGE directive exceeds the default or specified page width parameter Length value greater than string size The length parameter in a substring construct is larger than the composite length of the input string argument Line too long Source statements including continuation lines cannot exceed 512 characters in length LOC option must be used before any local label The LOC option must appear before any local label so that the assembler can keep the local label lists synchronized LOCAL directive not valid in global section The LOCAL directive is not allowed inside an implicit or explicit global section Local symbol names cannot be used with GLOBAL Local symbol names cannot be used with LOCAL Local symbol names cannot be used with XDEF Local symbol names cannot be used with XREF Undersc
142. en a structured control statement is expanded and an improper register reassignment has occurred It is recom mended that the MEX option see the OPT directive be used to examine structured con trol statement expansion for relevant constructs to determine default register usage and applicable reassignment strategies See also OPT MEX SCSJMP A label is not allowed with this directive EXAMPLE SCSREG _ YO B reassign SCS source and dest registers 154 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives SECTION Start Section SECTION lt symbol gt GLOBAL STATIC LOCAL lt section source statements gt ENDSEC The SECTION directive defines the start of a section All symbols that are defined within a section have the lt symbol gt associated with them as their section name This serves to protect them from like named symbols elsewhere in the program By default a symbol defined inside any given section is private to that section unless the GLOBAL or LOCAL qualifier accompanies the SECTION directive Any code or data inside a section is considered an indivisible block with respect to relo cation Code or data associated with a section is independently relocatable within the memory space to which it is bound unless the STATIC qualifier follows the SECTION di rective on the instruction line Symbols within a section are generally distinct from other
143. ence Manual 111 Chapter 6 Assembler Significant Characters and Directives Assembler Directives ENDBUF End Buffer ENDBUF The ENDBUF directive is used to signify the end of a buffer block The runtime location counter will remain just beyond the end of the buffer when the ENDBUF directive is en countered A label is not allowed with this directive See also BUFFER EXAMPLE ORG X 100 BUF BUFFER R 64 uninitialized reverse carry buffer ENDBUF 112 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives ENDIF End of Conditional Assembly ENDIF The ENDIF directive is used to signify the end of the current level of conditional assembly Conditional assembly directives can be nested to any level but the ENDIF directive al ways refers to the most previous IF directive A label is not allowed with this directive See also IF EXAMPLE IF REL SAVEPC SET Save current program counter ENDIF Freescale DSP Assembler Reference Manual 113 Chapter 6 Assembler Significant Characters and Directives Assembler Directives ENDM End of Macro Definition ENDM Every MACRO DUP DUPA and DUPC directive must be terminated by an ENDM direc tive A label is not allowed with this directive See also DUP DUPA DUPC MACRO EXAMPLE SWAP_SYM MACRO REG1 REG sswap REG1 REG2 using D4 L as temp MOVE R REG1 D4 L MOVE R REG2 R REG1 MOVE
144. ent delimiter Line continuation character or Macro dummy argument concatenation operator Macro value substitution operator Macro hex value substitution operator A Macro local label override operator g Macro string delimiter or Quoted string DEFINE expansion character Function delimiter 2 Location counter substitution String concatenation operator Substring delimiter lt lt I O short addressing mode force operator lt Short addressing mode force operator gt Long addressing mode force operator Immediate addressing mode operator Freescale DSP Assembler Reference Manual 67 Chapter 6 Assembler Significant Characters and Directives Assembler Directives lt Immediate short addressing mode force operator gt Immediate long addressing mode force operator 6 3 Assembler Directives Assembler directives can be grouped by function into seven types Assembly control Symbol definition Data definition storage allocation Listing control and options Object file control Macros and conditional assembly Structured programming NO oR WD 6 3 1 Assembly Control The directives used for assembly control are COMMENT Start comment lines DEFINE Define substitution string END End of source program FAIL Programmer generated error message FORCE Set operand forcing mode HIMEM Set high memory bounds INCLUDE Include secondary file LOMEM Set lo
145. ent is the source string lt offset gt is the substring starting position within lt string gt lt length gt is the length of the desired substring lt string gt may be any legal string combination including another substring An error is issued if either lt offset gt or lt length gt exceed the length of lt string gt EXAMPLE DEFINE ID DSP56300 3 5 ID 56300 84 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives lt lt UO 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 lt lt EXAMPLE Since the symbol IOPORT is a forward reference in the following sequence of source lines the assembler would pick the long absolute form of addressing by default BTST 4 Y IOPORT IOPORT EQU Y FFF3 Because the long absolute addressing mode would cause the instruction to be two w
146. equent addresses will be based from OVLBASE at runtime The size of the overlay block 01SIZE is computed by subtracting the START label value from the END label address Assume for purposes of discussion that there are other files containing similar overlay code with names OVER2 ASM and OVER3 ASM 4 7 1 Absolute Mode Implementation In order to avoid binding addresses within the individual overlay modules the programmer could devise a preamble file called OVLPROJ ASM which sets the appropriate counters and establishes the overlay base address SECTION OVLPROJECT XDEF OVLBASE XREF OVL1 O1SIZE XREF OVL2 02SIZE XREF OVL3 O03SIZE ORG XE 100 set absolute base for overlay sections ORG P1 200 set absolute base address for overlay OVLBASE DS 400 reserve space for overlay area MOVEOV1 code to move first overlay segment MOVE OVL1 RO load overlay code address MOVE OVLBASE R1 load overlay base address MOVE O01SIZE R2 load overlay code size DO R2 ENDLOOP loop to move data words into P memory MOVE X RO X0O get word of overlay from data memory MOVE X0 P R1 store word of overlay into P memory _ENDLOOP ENDSEC The overlay base address OVLBASE is made global with the XDEF statement The over lay segments and their sizes are made visible to the project section by using the XREF directive The first ORG establishes where the overlay segments will be placed in mem ory contiguously at load time The second ORG s
147. er H or L is specified that is associated with the lt rms gt will be used as the runtime location counter Indicates the runtime physical mapping to DSP memory internal E ex ternal R ROM A port A B port B If not present no explicit mapping is done Non negative absolute integer expression representing the counter number to be used as the runtime location counter Must be enclosed in parenthe ses Should not exceed the value 65535 Initial value to assign to the runtime counter used as the lt rlc gt If lt exp1 gt is a relative expression the assembler uses the relative location counter If lt exp1 gt is an absolute expression the assembler uses the absolute location counter If lt exp1 gt is not specified then the last value and mode that the counter had will be used Which memory space X Y L or P will be used as the load memory space If the memory space is L any allocated datum with a value greater than the target word size will be extended to two words otherwise it is truncated If DSP Assembler Reference Manual 143 Chapter 6 Assembler Significant Characters and Directives Assembler Directives the memory space is E then depending on the memory space qualifier any generated words will be split into bytes one byte per word or a 16 8 bit combination lt llc gt Which load counter H L or default if neither H or L is specified that is as sociated with the lt Ims gt will be used
148. er greater than zero and cannot contain any for ward references symbols that have not yet been defined Since the DSR directive is use ful mainly for generating FFT buffers if lt expression gt is not a power of two a warning will be generated lt label gt if present will be assigned the value of the runtime location counter after a valid base address has been established See also DS DSM EXAMPLE ORG X 100 R_BUF DSR 8 REVERSE CARRY BUFFER FOR 16 POINT FFT Freescale DSP Assembler Reference Manual 103 Chapter 6 Assembler Significant Characters and Directives Assembler Directives DUP Duplicate Sequence of Source Lines lt label gt DUP lt expression gt ENDM The sequence of source lines between the DUP and ENDM directives will be duplicated by the number specified by the integer lt expression gt lt expression gt can have any mem ory space attribute If the expression evaluates to a number less than or equal to 0 the sequence of lines will not be included in the assembler output The expression result must be an absolute integer and cannot contain any forward references symbols that have not already been defined The DUP directive may be nested to any level lt label gt if present will be assigned the value of the runtime location counter at the start of the DUP directive processing See also DUPA DUPC DUPF ENDM MACRO EXAMPLE The sequence of source input statements COUNT SET 3 DUP CO
149. er names in either upper or lower case cannot be used as symbol names in an assembly language source file X A AB A0 AO BA X1 A1 A10 Y B B10 YO BO A2 Y1 B1 B2 RO NO MO MR R1 N1 M1 CCR R2 N2 M2 SR R3 N3 M3 LC R4 N4 M4 LA R5 N5 M5 SSH R6 N6 M6 SSL R7 N7 M7 OMR The following DSP56300 registers are used by the assembler in structured control state ment processing Chapter 7 A X0 YO E 1 3 Condition Code Mnemonics Following are the DSP56300 condition code mnemonics which correspond to the condi tional instructions based on the CCR condition codes These tests may be used in an op erand comparison expression within a structured control statement Chapter 7 lt CC gt carry clear lt CS gt carry set lt EC gt extension clear lt EQ gt equal lt ES gt extension set lt GE gt greater or equal lt GT gt greater than lt HS gt higher or same lt LC gt limit clear lt LE gt less or equal lt LO gt lower lt LS gt limit set 270 DSP Assembler Reference Manual Freescale Appendix E Instruction Set Information DSP56300 Information lt LT gt less than lt MI gt minus lt NE gt not equal lt NN gt not normalized lt NR gt normalized lt PL gt plus Freescale DSP Assembler Reference Manual 271 Appendix E Instruction Set Information DSP56300 Information 272 DSP Assembler Reference Manual Freescale 20 20 21 l 22 67 79 67 88
150. er usage require absolute values as argu ments or operands Expression result must be integer Certain directives and some assembler usage require integer values as arguments or operands Expression result too large The expression evaluated to a value greater than the acceptable range This error can occur when an expression result exceeds the native word size of the target DSP External reference not allowed in expression References to external symbols e g symbols not defined in the current assembly source input are not allowed in some types of byte or integer expressions External reference not allowed in function References to external symbols e g symbols not defined in the current assembly source input are not allowed as direct or indirect arguments to any built in function Extra characters beyond expression The expression evaluator found extra characters after the end of a valid expres sion Unbalanced parentheses can cause this error Extra characters following string An end of string delimiter was followed by unexpected characters on the source line Extra characters following symbol name A non alphanumeric character other than the underscore _ was encountered ina symbol name Extra characters in function argument or missing for function Mismatched parentheses or wrong number of parameters in a function invocation Extra characters in operand field The PAGE directive contains too many operands E
151. error that should be reported to Freescale Debug symbol type failure The symbol type indicator passed to the debug selection logic was not valid This is a serious internal error that should be reported to Freescale Directive select error The directive indicator passed to the directive selection logic was not valid This is a serious internal error that should be reported to Freescale DO stack out of sequence The assembler maintains an internal stack representing DO loop nesting levels The internal stack pointers have been corrupted Error in mnemonic table The indicator passed to the instruction processing logic was not valid This is a se rious internal error that should be reported to Freescale Expression operator failure Expression operator lookup has failed This is a serious internal error that should be reported to Freescale Expression stack underflow An attempt has been made to free an expression when there are none to be freed This is an internal error that should be reported to Freescale Fatal segmentation or protection fault Contact Freescale DSP Operation A program error has caused the assembler to access an invalid host system ad dress This generally indicates a bug in the assembler software Freescale DSP Assembler Reference Manual 227 Appendix C Assembler Messages Fatal Errors File info out of sequence File debug information is scrambled This is a serious internal error that should b
152. ers and Directives Assembler Directives Macro String Delimiter or Quoted String DEFINE Expansion Character Macro String The double quote when used in macro definitions is transformed by the macro pro cessor 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 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 Freescale DSP Assembler Reference Manual 79 Chapter 6 Assembler Significant Characters and Directives Assembler Directives 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 H this macro were invoked as follows STR_MAC sentence then the resulting expansion would be MSG This i
153. es is assembled separately to create individual ob ject files The object files are combined to build a single executable file A preamble file OVLPROJ ASM containing overlay management code might appear as follows SECTION OVLPROJECT XDEF OVLBASE XREF OVL1 O1SIZE XREF OVL2 02SIZE XREF OVL3 O03SIZE ORG PI set base address for overlay MOVEOV1 code to move first overlay segment MOVE OVL1 RO load overlay code address MOVE OVLBASE R1 load overlay base address MOVE 01SIZE R2 load overlay code size DO R2 ENDLOOP loop to move data words into P memory MOVE X RO X0O get word of overlay from data memory MOVE X0 P R1 store one word of overlay into P memory _ENDLOOP OVLBASE DS 400 reserve space for overlay area ENDSEC START Note that the ORG to P space does not specify an absolute address In order to obtain the same result from these files as in an absolute mode implementation the following link er command line would be used DSPLNK B M OXE 100 OPI 200 OVLPROJ OVER1 OVER2 OVER3 Freescale DSP Assembler Reference Manual 53 Chapter 4 Software Project Management Example 3 Bootstrap Overlay The linker scans the command line and sets the base addresses for X and P memory Here the X default counter is set to hex 100 and mapped to external memory likewise the P default counter is set to hex 200 and mapped to internal memory Base addresses can also be established with the linker memory control file The lin
154. es not allow enough room on the listing line for the remaining fields to be output Invalid XY address register specification In some XY memory parallel data moves if the register forming the effective ad dress of the X data field is from the set RO R3 the effective address register in the Y field must be from the set R4 R7 Conversely if the register forming the effective address of the X data field is from the set R4 R7 the effective address register in the Y field must be from the set RO R3 Invalid XY data register specification In some XY memory parallel data moves if the data register of the X data field is from the set DO D3 the data register in the Y field must be from the set D4 D7 Conversely if the data register of the X data field is from the set D4 D7 the data register in the Y field must be from the set DO D3 UO short addressing mode not allowed An operand was forced I O short when I O short addressing was not allowed Jump based on SSH or SSL cannot follow update of SP Jump via SSH or SSL cannot follow write to SP A JSET JCLR JSSET or JSCLR instruction which tested a bit in either the SSH or SSL register was immediately preceded by a MOVE to the SP register L space specified for load but not for runtime L space specified for runtime but not for load Since L memory space is the only double wide memory space if L memory space is the runtime memory space the only valid load memory space is L Likewise L m
155. es of the ASCII representation of the characters in the string unless the NOPS option is specified see the OPT directive If the number of characters is not an even multiple of the number of bytes per DSP word then the last word will have the remaining characters left aligned and the rest of the word will be zero filled If the NOPS option is given each character in the string is stored in a word whose lower seven bits represent the ASCII value of the character EXAMPLE ABCD 414243 440000 See also BSC DCB EXAMPLE TABLE DC 1426 253 2662 ABCD CHARS DC A B C D 98 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives DCB Define Constant Byte lt label gt DCB lt arg gt lt arg gt lt arg gt The DCB directive allocates and initializes a byte of memory for each lt arg gt argument lt arg gt may be a byte integer constant a single or multiple character string constant a symbol or a byte expression The DCB directive may have one or more arguments sep arated by commas Multiple arguments are stored in successive byte locations If multi ple arguments are present one or more of them can be null two adjacent commas in which case the corresponding byte location will be filled with zeros lt label gt if present will be assigned the value of the runtime location counter at the start of the directive processing Integer a
156. ess Unlike other buffer allocation directives the runtime location counter is not advanced by the value of the integer expression in the op erand field the location counter remains at the buffer base address The block of memory intended for the buffer is not initialized to any value The result of lt expression gt may have any memory space attribute but must be an abso lute integer greater than zero and cannot contain any forward references symbols that have not yet been defined If a Modulo buffer is specified the expression must fall within the range 2 lt lt expression gt lt m where mis the maximum address of the target DSP If a Reverse carry buffer is designated and lt expression gt is not a power of two a warning will be issued A label is not allowed with this directive See also BSM BSB BUFFER DSM DSR EXAMPLE ORG X 100 M_BUF BADDR M 24 CIRCULAR BUFFER MOD 24 Freescale DSP Assembler Reference Manual 91 Chapter 6 Assembler Significant Characters and Directives Assembler Directives BSB Block Storage Bit Reverse lt label gt BSB lt expression gt lt expression gt The BSB directive causes the assembler to allocate and initialize a block of words for a reverse carry buffer The number of words in the block is given by the first expression which must evaluate to an absolute integer Each word is assigned the initial value of the second expression If there is no second expression an initial v
157. et of location counters is allocated for each DSP memory space These counters are used to maintain offsets of data and instructions relative to the beginning of the section At link time sections can be relocated to an absolute address loaded in a particular order or linked contiguously as specified by the programmer Sections which are split into parts or among files are logically recombined so that each section can be relocated as a unit Sections may be relocatable or absolute In the assembler absolute mode command line A option all sections are considered absolute A full set of locations counters is reserved for each absolute section unless the GS option is given see the OPT directive this chap ter In relative mode all sections are initially relocatable However a section or a part of 156 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives a section may be made absolute either implicitly by using the ORG directive or explicitly through use of the MODE directive A label is not allowed with this directive See also MODE ORG GLOBAL LOCAL XDEF XREF EXAMPLE SECTION TABLES TABLES will be the section name Freescale DSP Assembler Reference Manual 157 Chapter 6 Assembler Significant Characters and Directives Assembler Directives SET Set Symbol to a Value lt label gt SET lt expression gt SET lt label gt lt expression gt The SET dir
158. ets up the absolute base address for the overlay area common to all of the overlay segments Uninitialized space is allocated for the overlay area immediately followed by code to move the overlay segments into the common area at runtime The following assembler command line will process the header file and all overlay segments ASM56300 A B L OVLPROJ OVER1 OVER2 OVER3 START 52 DSP Assembler Reference Manual Freescale Chapter 4 Software Project Management Example 2 Overlays The assembler is invoked in absolute mode A option and generates an executable and listing file All files on the command line are processed as a single assembly run and all are used to produce the output OVLPROUJ ASM is read first and sets up the appropriate absolute addresses for later sections Then each overlay file is read and loaded one after the other at external X memory address 100 hexadecimal However since each overlay module was intended to run starting at OVLBASE in P memory all labels and jumps to those labels within the overlay code will be relative to the overlay base address This means that the code in each of the overlay modules when loaded by the overlay manage ment code in the OVLPROJECT section will start executing at internal P memory address 200 hexadecimal The file START ASM contains an END directive which indicates the program start address after loading 4 7 2 Relative Mode Implementation In relative mode each of the overlay fil
159. evious line of the source statement and the result will be pro cessed 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 dum my arguments they must normally be separated from other alphanumeric characters by anon 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 be hind some other symbol characters then it must be followed by or preceded by the back slash respectively EXAMPLE Suppose the source input file contained the following macro definition SWAP_REG MACRO REG1 REG2_ swap REG1 REG2 using D4 L as temp MOVE R REG1 D4 L MOVE R REG2 R REG1 MOVE D4 L R REG2 ENDM 74 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives The concatenation operator indicates to the macro processor that the substitution char acters 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 e
160. f memory reserved is not initialized to any given value The result of lt expression gt must be an absolute integer greater than zero and cannot contain any for ward references symbols that have not yet been defined The expression also must fall within the range 2 lt lt expression gt lt m where m is the maximum address of the target DSP lt label gt if present will be assigned the value of the runtime location counter after a valid base address has been established See also DS DSR EXAMPLE ORG X 100 M_BUF DSM 24 CIRCULAR BUFFER MOD 24 102 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives DSR Define Reverse Carry Storage lt label gt DSR lt expression gt The DSR directive reserves a block of memory the length of which in words is equal to the value of lt expression gt If the runtime location counter is not zero this directive first ad vances the runtime location counter to a base address that is a multiple of 2k where 2k gt lt expression gt An error will be issued if there is insufficient memory remaining to establish a valid base address Next the runtime location counter is advanced by the value of the integer expression in the operand field lt expression gt can have any memory space attribute The block of memory reserved is not initialized to any given value The result of lt expression gt must be an absolute integ
161. f those statements between the IF and the ENDIF directives were never encountered If the ELSE directive is present and lt expression gt has a nonzero result then the statements between the IF and ELSE directives will be assembled and the statements between the ELSE and ENDIF directives will be skipped Alternatively if lt expression gt has a value of zero then Freescale DSP Assembler Reference Manual 65 Chapter 5 Macro Operations and Conditional Assembly Conditional Assembly the statements between the IF and ELSE directives will be skipped and the statements between the ELSE and ENDIF directives will be assembled 66 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives 6 1 Introduction This chapter describes the directives that are recognized by the Freescale DSP Assem bler The assembler directives are instructions to the assembler rather than instructions to be directly translated into object code In addition this chapter describes special char acters that are considered significant to the assembler 6 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 3 Other as sembler significant characters are S Comment delimiter 5 Unreported comm
162. file F_CC 0010000 File produced by C compiler Freescale DSP only Figure E 3 File Header Flags D 3 2 Optional Header The COFF optional header ordinarily is used to hold system dependent or runtime infor mation This allows different operating environments to store data that only that environ ment uses without forcing all COFF files to save space for that information General utility programs can be made to work properly with any common object file This is done by seeking past the optional header using the f_opthdr size field in the file header record The optional header in a Freescale DSP object file may contain two distinct types of infor mation depending upon how the file was generated If the file is a relocatable object file it will have an optional header containing linker information If the file is an absolute object file it will have an optional header containing runtime information The runtime header is similar to standard COFF a out optional header formats Figure E 4 shows the linker optional header The module size field gives the size of the entire object module The data size field reflects the size of the entire raw data block with inthe module The endsttr field points to an expression in the string table which originated with the assembler END directive see Chapter 6 it indicates the starting address of the module If this field is negative or zero there is no end expression The logical section count is
163. first unary plus unary minus one s complement logical negation multiplication division mod addition subtraction shift relational operators less less or equal greater greater or equal relational operators equal not equal bitwise AND OR EOR logical AND OR CON oe YS Operators of the same precedence are evaluated left to right Valid operands include nu meric constants literal ASCII strings and symbols The one s complement shift and bit wise operators cannot be applied to floating point operands That is if the evaluation of an expression after operator precedence has been applied results in a floating point number on either side of any of these operators an error will be generated 3 8 Functions The assembler has several built in functions to support data conversion string compari son and transcendental math computations Functions may be used as terms in any ar bitrary expression Functions may have zero or more arguments but must always be followed by open and closed parentheses Function arguments which are expressions must be absolute expressions except where noted Arguments containing external refer ences are not allowed There must be no intervening spaces between the function name and the opening parenthesis and there must be no spaces between comma separated arguments Assembler functions can be grouped into five types Mathematical functions Conversion functions String functions Macro
164. ftware Project Management Example 3 Bootstrap Overlay than words Consider the following section fragments contained in two files called SECT1 ASM and SECT2 ASM respectively SECTION SECT1 ORG Pl 1 PE 2 START1 lt source statements gt END1 ENDSEC SECTION SECT2 ORG Pl 1 PE 2 START2 lt source statements gt END2 ENDSEC 4 8 1 Absolute Mode Implementation In order to avoid binding addresses within the individual modules the programmer could devise a preamble file called BOOTPROJ ASM which sets the appropriate options and establishes load and runtime base addresses OPT LB increment load counter by bytes ORG PI 1 100 PE 2 C000 set runtime RAM address bytewide load ROM address The OPT directive with the LB option indicates that the assembler should increment the load counter by the number of bytes in the target processor word This guarantees that the EPROM addresses will be correct for bytewide loading during bootstrap processing In the ORG directive the runtime location counter tagged as 1 and mapped to internal memory is set to hex 100 The load counter is tagged as 2 mapped to external memory and set to hex C000 where the built in bootstrap program will begin loading bytes after processor reset The files are assembled using the command below ASM56300 A B L BOOTPROJ SECT1 SECT2 Freescale DSP Assembler Reference Manual 55 Chapter 4 Software Project Management Example 3 Bootstrap Ove
165. functions Assembler mode functions oe NS Freescale DSP Assembler Reference Manual 23 Chapter 3 Expressions Functions 3 8 1 Mathematical Functions The mathematical functions comprise transcendental random value and min max func tions among others ABS Absolute value ACS Arc cosine ASN Arc sine AT2 Arc tangent ATN Arc tangent CEL Ceiling function COH Hyperbolic cosine COs Cosine FLR Floor function L10 Log base 10 LOG Natural logarithm MAX Maximum value MIN Minimum value POW Raise to a power RND Random value SGN Return sign SIN Sine SNH Hyperbolic sine SQT Square root TAN Tangent TNH Hyperbolic tangent XPN Exponential function 24 DSP Assembler Reference Manual Freescale Chapter 3 Expressions Functions 3 8 2 Conversion Functions The conversion functions provide conversion between integer floating point and fixed point fractional values CVF Convert integer to floating point CVI Convert floating point to integer Cvs Convert memory space FLD Shift and mask operation FRC Convert floating point to fractional LFR Convert floating point to long fractional LNG Concatenate to double word LUN Convert long fractional to floating point RVB Reverse bits in field UNF Convert fractional to floating point 3 8 3 String Functions String functions compare strings return the length of a string and return the position of a substrin
166. g it cannot be an immediate val ue The initial value of the FOR loop counter The effective address may be any mode and may represent an arbitrary assembler ex pression Chapter 3 The terminating value of the FOR loop counter The effective ad dress may be any mode and may represent an arbitrary assem bler expression Chapter 3 The step increment decrement of the FOR loop counter each time through the loop If not specified it defaults to a value of 1 The effective address may be any mode and may represent an arbitrary assembler expression Chapter 3 The terminating value in a LOOP statement This can be any ar bitrary assembler expression Chapter 3 All structured control statements may be followed by normal assembler comments on the same logical line 7 3 1 BREAK Statement SYNTAX BREAK 168 DSP Assembler Reference Manual Freescale Chapter 7 Structured Control Statements Syntax FUNCTION The BREAK statement causes an immediate exit from the innermost en closing loop construct WHILE REPEAT FOR LOOP NOTES A BREAK statement does not exit an IF THEN ELSE construct If a BREAK is encountered with no loop statement active a warning is issued BREAK should be used with care near ENDL directives or near the end of DO loops It generates a jump instruction which is illegal in those contexts EXAMPLE WHILE x r1 lt GT gt 0 sloop until zero is found JE lt cs gt
167. g used The lt expression gt may be relative or abso lute but cannot include a symbol that is not yet defined no forward references are allowed See also SET EXAMPLE A_D_PORT EQU X 4000 This would assign the value 4000 with a memory space attribute of X to the symbol A_D_PORT COMPUTE EQU LCV L LCV L is used to refer to the value and memory space attribute of the load location counter This value and memory space attribute would be assigned to the symbol COM PUTE 116 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives EXITM Exit Macro EXITM The EXITM directive will cause immediate termination of a macro expansion It is useful when used with the conditional assembly directive IF to terminate macro expansion when error conditions are detected A label is not allowed with this directive See also DUP DUPA DUPC MACRO EXAMPLE CALC MACRO XVAL YVAL IF XVAL lt 0O FAIL Macro parameter value out of range EXITM Exit macro ENDIF ENDM Freescale DSP Assembler Reference Manual 117 Chapter 6 Assembler Significant Characters and Directives Assembler Directives FAIL Programmer Generated Error FAIL lt str gt l lt exp gt lt str gt l lt exp gt lt str gt l lt exp gt The FAIL directive will cause an error message to be output by the assembler The total error count will be incremented as with any other e
168. g within a string LEN Length of string POS Position of substring in string SCP Compare strings 3 8 4 Macro Functions Macro functions return information about macros ARG Macro argument function CNT Macro argument count MAC Macro definition function MXP Macro expansion function Freescale DSP Assembler Reference Manual 25 Chapter 3 Expressions Functions 3 8 5 Assembler Mode Functions Miscellaneous functions having to do with assembler operation CCC Cumulative cycle count CHK Current instruction data checksum CTR Location counter type DEF Symbol definition function EXP Expression check INT Integer check LCV Location counter value LST LIST directive flag value MSP Memory space REL Relative mode function Individual descriptions of each of the assembler functions follow They include usage guidelines functional descriptions and examples ABS lt expression gt Returns the absolute value of lt expression gt as a floating point value The memory space attribute of the result will be None Example MOVE ABS VAL D4 S load absolute value ACS lt expression gt Returns the arc cosine of lt expression gt as a floating point value in the range zero to pi The result of lt expression gt must be between 1 and 1 The memory space attribute of the result will be None Example ACOS ACS 1 0 ACOS 3 141593 ARG lt symbol gt lt expression gt
169. gram counters per memory space a set of load counters and a set of runtime counters The distinction between load and runtime counters is maintained so that the assembler can support overlays or runtime transfers of code data from one memory space to another In these cases code or data might be loaded in one memory space at a given address but then copied to a different memory space and address for execution The assembler can produce output for either absolute or relocatable overlays Freescale DSPs are capable of performing special purpose addressing on data structures suited to digital signal processing applications Two such data structures are the modulo buffer and the reverse carry buffer collectively referred to as circular buffers Due to the way they are accessed and manipulated these buffers generally are constrained to a par ticular size or starting address The assembler provides directives for aligning buffer base addresses allocating buffer space and initializing buffer contents 4 5 1 The ORG Directive The ORG directive specifies which memory space will be the runtime memory space and which counter the H L default or numbered runtime counter associated with that mem ory space and section will be the runtime location counter At the same time the ORG directive indicates which memory space will be the load memory space and which counter the H L default or numbered load counter associated with that memory space and sec
170. groups of object file information Some of these groups are optional depending on the type of object file generated and others may have repeating occurrences The basic object file components are e File header e Optional header e Section headers e Section data e Relocation information e Line numbers e Symbol table e String table Freescale DSP Assembler Reference Manual 231 Appendix D Freescale DSP Object File Format COFF Object File Structure The general layout of the object file is illustrated in Figure E 1 FILE HEADER OPTIONAL HEADER Section 1 Header Section n Header Section 1 Contents Section n Contents Section 1 Relocation Info Section n Relocation Info Section 1 Line Numbers Section n Line Numbers SYMBOL TABLE STRING TABLE Figure E 1 COFF File Basic Structure The file header contains object file information such as timestamp number of sections pointer to the symbol table and file status flags Depending on how the object file was generated the optional header holds link or run time information The optional header is followed by a list of section headers Each section header contains pointers to section data relocation information and line number entries After the section headers comes the raw data for all sections If the object file is relocatable the raw data may be followed by a block of relocation entries for all sections If the original source file was
171. hapter 5 4 7 Example 2 Overlays An overlay is a transfer of code or data from one memory space or address to another memory space or address at runtime Often the transfer involves copying different blocks of code or data over a common storage area as runtime circumstances dictate hence the name overlay Overlays are useful for moving code into internal program memory from an external memory source such as EPROM They are also effective when implementing large programs with multiple segments which do not need to be accessed concurrently Consider the following program fragment contained in a file called OVER1 ASM SECTION OVERLAY1 XREF OVLBASE XDEF OVL1 O1SIZE ORG X OVL1 ORG P OVLBASE X START lt overlay source statements gt END O1SIZE EQU END START ENDSEC This is a sample of overlay code bounded by a SECTION directive The overlay base or the place to which this block of code will be moved for execution is declared external at OVLBASE OVLBASE is actually defined elsewhere The label OVL1 is XDEFed to pro vide a handle for moving the block at runtime and O1SIZE is also XDEFed so that the overlay management code knows how many words to move Note that the OVL1 label is placed before the ORG for the overlay so that it remains a valid address in X memory dur Freescale DSP Assembler Reference Manual 51 Chapter 4 Software Project Management Example 2 Overlays ing execution The overlay ORG directive insures that subs
172. he DSM or DSR directive and the runtime location counter value exceed avail able memory in the current memory space Structure or union tag mismatch A matching tag name could not be found for the current source level debug struc ture or union declaration Subroutine branch to loop address not allowed A BSR BScc BSSET or BSCLR instruction cannot have as its target the loop ad dress of the current DO loop Subroutine jump to loop address not allowed A JSR JScc JSSET or JSCLR instruction cannot have as its target the loop ad dress of the current DO loop SVO option must be used before any code or data generation The SVO option must be given before any data allocation directive BSC DC DS DSM DSR or any instruction appears in the source file Symbol already defined as GLOBAL Symbol already defined as LOCAL Symbol already defined as XDEF Symbol already defined as XREF The symbol used in an GLOBAL LOCAL XDEF or XREF directive has already been defined in a previous directive of the same type Symbol already defined as global A symbol specified in an XDEF directive has already been defined as global out side the current section Symbol already defined in current section A symbol specified in an XREF directive has already been defined as private within the current section Symbol already used as SET symbol The label has already been used in a SET directive A symbol defined with SET cannot be redefined exce
173. he argument to a DUPA or DUPC directive was not found Missing definition string The substitution string for a DEFINE directive is missing Missing delimiter in substring A substring construct was missing the closing square bracket Missing dimension The DIM directive had no arguments Missing directive name The argument to an RDIRECT directive is missing Missing expression An expression was expected by the expression evaluator Freescale DSP Assembler Reference Manual 211 Appendix C Assembler Messages Errors Missing filename No filename was provided as an argument to the INCLUDE directive Missing line number No line number was provided as an argument to the LINE directive Missing macro name A MACRO directive was encountered without a label or the macro name was omit ted from a PMACRO directive Missing memory space specifier One of the operands of an instruction was expected to have a memory space spec ifier X Y L or P preceding the address mode specifier Missing option The OPT directive was specified without an argument Missing or illegal memory space specifier One of the operands of an instruction was expected to have a memory space spec ifier X Y L or P preceding the address mode specifier Missing or mismatched quote A single or double quote character was expected by the string parsing routines Missing pathname No pathname was provided as an argument to the MACLIB directive Mis
174. he assembler as a type in the same sense that high level languages use type for variables Symbols may have memory space attributes of X Y L P rogram or N one only N is fully compatible with all other attributes In this case an operand was evaluated with a different memory space attribute than that specified in the directive Freescale DSP Assembler Reference Manual 193 Appendix C Assembler Messages Warnings Runtime reserved address space violation The runtime location counter has incremented into a reserved area of data address space Short absolute address cannot be forced Short absolute addressing is not valid for this operation An appropriate addressing mode long absolute is substituted Short absolute address cannot be forced long substituted Short absolute addressing is not valid for this operation The assembler substitutes long absolute addressing Short immediate cannot be forced Short immediate data is not valid for this operation An appropriate size is substi tuted Short PC relative address cannot be forced Short PC relative addressing is not valid for this operation An appropriate ad dressing mode long PC relative is substituted Signed operand must come first in signed unsigned combinations Ina MPYSU MACSU or DMACSU instruction the signed operand must come first in the operand ordering Source operand assumed I O short Neither operand in a MOVEP instruction is explicitly decla
175. he boolean values of the simple expressions and the nature of the logical operator Note that the result of mixing logical operators in a compound expression is un defined IF X1 lt GT gt B AND lt LS gt AND R1 lt NE gt R2 this is OK IF X1 lt LE gt B AND lt LC gt OR R5 lt GT gt R6 undefined The simple expressions are evaluated left to right Note that this means the result of one simple expression could have an impact on the result of subsequent simple expressions because of the condition code settings stemming from the assembler generated com pare If the compound expression is an AND expression and one of the simple expressions is found to be false any further simple expressions are not evaluated Likewise if the com pound expression is an OR expression and one of the simple expressions is found to be true any further simple expressions are not evaluated In these cases the compound ex pression is either false or true respectively and the condition codes reflect the result of the last simple expression evaluated 7 5 Statement Formatting The format of structured control statements differs somewhat from normal assembler us age Whereas a standard assembler line is split into fields separated by blanks or tabs with no white space inside the fields structured control statement formats vary depending on the statement being analyzed In general all structured control directives are placed in the opcode field with an opti
176. hey must be preceded either by a label a space or a tab BREAK ENDI LOOP CONTINUE ENDL REPEAT ELSE ENDW UNTIL ENDF FOR WHILE JE In addition the following keywords are used in structured control statements AND DOWNTO TO BY OR DO THEN Note that AND DO and OR are reserved assembler instruction mnemonics Freescale DSP Assembler Reference Manual 167 Chapter 7 Structured Control Statements Syntax 7 3 Syntax The formats for the BREAK CONTINUE FOR IF LOOP REPEAT and WHILE statements are given in sections 7 3 4 through 7 3 2 Syntactic variables used in the for mats are defined as follows lt expression gt lt stmtlist gt A simple or compound expression section 7 4 Zero or more assembler directives structured control statements or executable instructions Note than an assembler directive Chapter 6 occurring within a structured control statement is examined exactly once at assembly time Thus the presence of a directive within a FOR LOOP REPEAT or WHILE statement does not imply re peated occurrence of an assembler directive nor does the presence of a directive within an IF THEN ELSE structured control statement imply conditional assem bly lt op1 gt lt op2 gt lt op3 gt lt op4 gt lt cnt gt A user defined operand whose register memory location holds the FOR loop counter The effective address must use a memo ry alterable addressing mode e
177. high P memory initialization statement might correspond to the memory location of an external EPROM Freescale DSP Assembler Reference Manual 49 Chapter 4 Software Project Management Example 1 Multi Programmer Environment After the location counters corresponding to the X Y and P rogram memory spaces are initialized the assembler is directed to take input from the MAIN ASM file with the IN CLUDE directive Within the MAIN ASM file the source statements are assembled and object code is generated The X Y L and P rogram location counters High Low are advanced corresponding to the number of words generated for each memory space and location counter in use When the end of the MAIN ASM file is encountered the assembler returns to the next se quential statement in the PROJECT ASM file This directs the assembler to start taking input from the 1O ASM file Within this file the ORG PL statement directs the assembler to set the current memory space to P rogram and restore the last used P rogram L ow location counter The JO source program statements gt shown previously will be assem bled at the next available Low Program memory space When the end of the IO ASM file is encountered the X Y and P rogram location counters High and Low will have been advanced corresponding to the number of words generated for each memory space In a similar manner the file FILTER ASM will be assembled The last statement of the PROJECT ASM f
178. his case an operand was evaluated with a different memory space attribute than that specified in the instruction PC relative address too large to use short long substituted The PC relative offset is not within the range specifying a short PC relative offset even though the short forcing operator has been used The assembler substitutes long PC relative addressing Post update operation will not occur on destination register If the source operand in a MOVE operation specifies a post update addressing mode and the destination register is the same as the source operand register then the post update operation will not take place PRCTL directive ignored no explicit listing file The PRCTL directive takes effect only if the L option is used on the command line to explicitly specify a listing file Redefinition of symbol A symbol used in a DEFINE directive has been redefined without an intervening UNDEF directive The assembler discards the previous definition and replaces it with the new definition Rounding not available with LMS move using MAC MPY encoding A MACH or MPYR instruction was specified in conjunction with LMS move syntax Runtime location counter overflow Runtime location counter underflow The runtime location counter exceeded its maximum or minimum value The as sembler wraps the counter value around and continues Runtime origin involves incompatible memory spaces The memory space attribute is regarded by t
179. his directive See also NOLIST OPT EXAMPLE IF LISTON LIST Turn the listing back on ENDIF 126 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives LOCAL Local Section Symbol Declaration LOCAL lt symbol gt lt symbol gt lt symbol gt The LOCAL directive is used to specify that the list of symbols is defined within the current section and that those definitions are explicitly local to that section It is useful in cases where a symbol is used as a forward reference in a nested section where the enclosing section contains a like named symbol This directive is only valid if used within a program block bounded by the SECTION and ENDSEC directives The LOCAL directive must ap pear before lt symbol gt is defined in the section If the symbols that appear in the operand field are not defined in the section an error will be generated A label is not allowed with this directive See also SECTION XDEF XREF EXAMPLE SECTION IO LOCAL LOOPA LOOPA local to this section ENDSEC Freescale DSP Assembler Reference Manual 127 Chapter 6 Assembler Significant Characters and Directives Assembler Directives LOMEM Set Low Memory Bounds LOMEM lt mem gt lt rl gt lt expression gt The LOMEM directive establishes an absolute low memory bound for code and data gen eration lt mem gt corresponds to one of the DSP memory spaces X Y
180. i tion the STYP_BLOCK flag is set in the section s_flags field D 4 6 Other Extensions If the object file is relocatable there are extra structures which the assembler and linker generate to support special constructs such as logical sections buffers and overlays The optional link file header contains information which the linker requires it is described in section D 3 2 Every symbol table entry for a section in a relocatable file has an extra auxiliary entry described in section D 3 4 6 2 One special DSP COFF structure not documented elsewhere is the comment symbol A comment symbol table entry is emitted either indirectly via the assembler IDENT directive or directly with the COBJ directive see Chapter 6 A comment symbol table entry may be identified by a symbol name of cmt and a type and storage class of zero The value field of acomment symbol holds the offset into the string table of the comment text The section number for a comment symbol produced with the IDENT directive is always 1 Comment symbols generated with the COBJ directive have the section number of the section where the COBJ directive appears in the source file Comment symbols have no auxiliary entry D 5 Object File Data Expression Format Object file data expressions are used in data relocation records to represent values to be loaded into memory An expression is a combination of symbols constants operators Freescale DSP Assembler Reference Manual 261 Ap
181. ignificant Characters and Directives Assembler Directives XDEF External Section Symbol Definition XDEF lt symbol gt lt symbol gt lt symbol gt The XDEF directive is used to specify that the list of symbols is defined within the current section and that those definitions should be accessible by sections with a corresponding XREF directive This directive is only valid if used within a program section bounded by the SECTION and ENDSEC directives The XDEF directive must appear before lt sym bol gt is defined in the section If the symbols that appear in the operand field are not de fined in the section an error will be generated A label is not allowed with this directive See also SECTION XREF EXAMPLE SECTION IO XDEF LOOPA LOOPA will be accessible by sections with XREF ENDSEC Freescale DSP Assembler Reference Manual 165 Chapter 6 Assembler Significant Characters and Directives Assembler Directives XREF External Section Symbol Reference XREF lt symbol gt lt symbol gt lt symbol gt The XREF directive is used to specify that the list of symbols is referenced in the current section but is not defined within the current section These symbols must either have been defined outside of any section or declared as globally accessible within another sec tion using the XDEF directive If the XREF directive is not used to specify that a symbol is defined globally and the symbol is not defined withi
182. igure E 20 Relocatable Buffer Overlay Auxiliary Entry Buffers and overlays are mutually exclusive so their respective fields share storage space in the object file The buffer section number is really the buffer instance count in this file 252 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Components Buffer type is either modulo or reverse carry The buffer limit gives the upper bound for the buffer size even though the block may contain less initialized data than this limit sug gests The overlay memory structure gives the runtime memory attributes for this block The overlay section number is really the overlay instance count in this file The overlay origin expression is the expression given for the runtime counter in the assembler ORG directive see Chapter 6 D 3 4 6 3 Tag Names Auxiliary entries for C language structure and union tag names have the format described in Figure E 21 Note that in Freescale DSP COFF the size of the associated structure or union is in words as opposed to bytes as in standard COFF The x_endndx field is used to create a linked list of tag name entries through the symbol table Declaration Description Unused zero filled unsigned long Size of structure union or enumeration in words Unused zero filled long int x_endndx Index of next structure union or enumeration entry Unused zero filled
183. ile informs the assembler that this is the last logical source statement and the starting address for the object module will be a label called ENTRY In the exam ple above ENTRY would have been a label defined in the section MAIN and declared as global with the XDEF directive 4 6 2 Relative Mode Implementation Using the assembler default relative mode each of the source files is assembled sepa rately For each section defined in the input files a separate set of location counters is maintained such that all memory spaces for each section begin at relative address zero The linker is invoked to combine the files and establish base addresses DSPLNK B M OXLI 0 OYLI 0 OYH FFCO OXH FFCO OPL 1000 OPHE A000 MAIN IO FILTER The linker reads the command input and sets up base values for all counters specified on the command line In this example the X and Y low memory counters are initialized to ze ro whereas the X and Y high memory counters are set to FFCO hexadecimal The pro gram low and high memory counters are initialized similarly When the linker creates the executable file it reads the input files and sets the starting address for all sections relative to the values obtained from the command line As the MAIN object file is read the linker increments the section counters for all appropriate memory spaces After the MAIN object file is processed the IO object file is read The section named _O contained an ORG directive indicat
184. in any designated MACLIB di rectories default reset Issue warning on memory space incompatibilities Include a memory utilization report in the source listing This option must ap pear before any code or data generation Display conditional assembly IF ELSE ENDIF and section nesting levels on listing Do not check address expressions default reset Disable cycle counts Does not clear total cycle count default reset Do not print DC expansions default reset Disable checksumming of instruction and data values Do not print the conditional assembly directives DSP Assembler Reference Manual 139 Chapter 6 Assembler Significant Characters and Directives Assembler Directives NOCM NODEX NODLD NODXL NOFC NOFF NOFM NOGS NOHDR NOINTR NOMC NOMD NOMEX NOMI NOMSW NONL NONS NOPP NOPS NORC NORP NOSCL NOSI 140 Do not preserve comment lines of macros when they are defined default reset Do not expand DEFINE symbols within quoted strings default reset Restrict use of certain directives in DO loop Do not expand DEFINE directive strings in listing default reset Inhibit folded comments default reset Use multiple line feeds for page ejects in the listing file default reset Do not format assembler messages default reset in relative mode Do not make all sections global static Do not generate listing header This also turns off titles and subtitles default reset in relati
185. ing a switch to the low X data memory counter Recall that the assembler generated relocatable code for the _O section source such that the low X data memory counter begins at zero The linker adjusts the low X memory counter associated with section _O to reflect any previous data generation performed in low X memory e g in MAIN The FILTER module is linked in a similar fashion 50 DSP Assembler Reference Manual Freescale Chapter 4 Software Project Management Example 2 Overlays Another way for specifying base addresses instead of lengthy command line options is through a memory control file The memory control file allows the programmer to indi cate memory space starting addresses analogously to the command line approach In ad dition the memory control file offers finer control over placement of sections in memory See the Freescale DSP Linker Librarian Reference Manual for more information on the memory control file The preceding examples described two methods for organizing a software project Refer to the descriptions of the ORG and SECTION directives in Chapter 6 for a more detailed discussion See also the Freescale DSP Linker Librarian Reference Manual for more information on relocation and linking One other assembler directive that should be men tioned although not shown in the previous example is the MACLIB directive which allows sections to share a common macro library The MACLIB directive is discussed more fully in C
186. ing point value which represents the largest integer less than or equal to lt expression gt The memory space attribute of the result will be None Example FLOOR SET FLR 2 5 FLOOR 2 0 FRC lt expression gt For binary fractional DSPs DSP56300 this functions performs scaling and con vergent rounding to obtain the fractional representation of the floating point lt ex pression gt as an integer The memory space attribute of the result will be None Example FRAC EQU FRC FLT 1 compute saturation INT lt expression gt Returns an integer 1 memory space attribute N if lt expression gt has an integer re sult O otherwise The lt expression gt may be relative or absolute Example IF INT TERM insure integer value L10 lt expression gt Returns the base 10 logarithm of lt expression gt as a floating point value lt expres sion gt must be greater than zero The memory space attribute of the result will be None Example LOG EQU L10 100 0 LOG 2 30 DSP Assembler Reference Manual Freescale Chapter 3 Expressions Functions LCV L R L H lt expression gt If L is specified as the first argument returns the memory space attribute and value of the load location counter If R is specified returns the memory space attribute and value of the runtime location counter The optional second argument indicates the Low High or numbered counter and must be separated from the first arg
187. ion Example ASM56300 Fopts cmd Invoke the assembler and take command line options and source filenames from the command file OPTS CMD Send source file line number information to the object file This option is val id only in conjunction with the B command line option The generated line DSP Assembler Reference Manual Freescale Chapter 1 Freescale DSP Assembler Running the Assembler number information can be used by debuggers to provide source level de bugging Example ASM56300 B G myprog asm Assemble the file MYPROG ASM and send source file line number information to the resulting object file MYPROG CLN l lt pathname gt L lt lstfil gt Freescale When the assembler encounters INCLUDE files the current directory or the directory specified in the INCLUDE directive is first searched for the file If it is not found and the I option is specified the assembler prefixes the file name and optional pathname specified in the INCLUDE directive with lt pathname gt and searches the newly formed directory pathname for the file The pathname must be a legal operating system pathname The I option may be repeated as many times as desired The directories will be searched in the order specified on the command line Example ASM56300 I project testprog This example uses IBM PC pathname conventions and would cause the assembler to prefix any INCLUDE files not found in the current directory with the projec
188. ion of one string within anoth er See Chapter 3 for more information on string functions 2 4 Source Statement Format Each source statement may include up to six fields separated by one or more spaces or tabs a label field an operation field an operand field up to two data transfer fields and a comment field Only fields preceding the comment field are considered significant to the assembler the comment field is ignored For example the following source statement shows all six possible fields for the DSP56300 ENT FMPY D8 D6 D2 X RO D4 S D2 S Y R5 TEXT Comment Y field X field Operand Opcode Label In general the contents of each field other than the comment field cannot contain embed ded whitespace characters since these characters are used as field delimiters Two ex 12 DSP Assembler Reference Manual Freescale Chapter 2 Writing Assembly Language Programs Source Statement Format ceptions are blanks and tabs in quoted strings and the syntax of structured control statements see Chapter 7 2 4 1 Label Field The label field occurs as the first field of a source statement and can take one of the fol lowing forms 1 A space or tab as the first character on a line ordinarily indicates that the label field is empty and that the line has no label 2 An alphabetic character as the first character indicates that the line contains a symbol called a label 3 An underscore _ as the f
189. irective is used to specify that the list of symbols is defined within the cur rent section and that those definitions should be accessible by all sections This directive is only valid if used within a program block bounded by the SECTION and ENDSEC di rectives If the symbols that appear in the operand field are not defined in the section an error will be generated A label is not allowed with this directive See also SECTION XDEF XREF EXAMPLE SECTION IO GLOBAL LOOPA LOOPA will be globally accessible by other sections ENDSEC 120 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives GSET Set Global Symbol to a Value lt label gt GSET lt expression gt GSET lt label gt lt expression gt The GSET directive is used to assign the value of the expression in the operand field to the label The GSET directive functions somewhat like the EQU directive However labels defined via the GSET directive can have their values redefined in another part of the pro gram but only through the use of another GSET or SET directive The GSET directive is useful for resetting a global SET symbol within a section where the SET symbol would otherwise be considered local The expression in the operand field of a GSET must be absolute and cannot include a symbol that is not yet defined no forward references are allowed See also EQU SET EXAMPLE COUNT GSET 0 gt I
190. irst character indicates that the label is a local label Labels may be indented if the label symbol is immediately followed by a colon If the first non blank field on a line complies with either forms 2 or 3 above and the field ends with a colon the assembler regards this as the label field even if it does not start with the first character on the line However all characters preceding the label on the source line must be whitespace characters spaces or tab characters There should be no interven ing blanks or tabs between the end of the label symbol and the appended colon character Local labels are any normal symbol name preceded with no intervening blanks by an underscore _ Except for the special case of macros described below local labels have a limited scope bounded by any two non local labels The local label can be referred to or defined only in source statements that are between two source lines containing non local labels Local labels are useful in defining program locations where a unique label name is required but is not considered useful in documenting the source file for example the terminating address of a DO loop Note that the maximum length of a local label includes the leading underscore _ character Use of local labels in macros represents a special case All local labels within a macro are considered distinct for the currently active level of macro expansion unless the macro lo cal label override operator
191. is not suppressed with the IL option or if it is not redirected via the L command line option described above The standard output generally goes to the console or terminal screen by default but can be diverted to a file or to a printer by using the I O redirection facilities of the host operating system if available Error messages will always appear on the stan dard output regardless of any option settings Note that some options B L allow a hy phen as an optional argument which indicates that the corresponding output should be sent to the standard output stream Unpredictable results may occur if for example the object file is explicitly routed to standard output while the listing file is allowed to default to the same output stream Freescale DSP Assembler Reference Manual 7 Chapter 1 Freescale DSP Assembler Assembler Processing 1 5 Assembler Processing The Freescale DSP assembler is a two pass assembler During the first pass the source program is read to build the symbol and macro tables During the second pass the object file is generated assembled with reference to the tables created during pass one It is also during the second pass that the source program listing is produced Each source statement is processed completely before the next source statement is read As each line is read in any translations specified by the DEFINE directive are applied Each statement is then processed and the assembler examines the
192. is used see Chapter 5 These local labels are valid for the en tire macro expansion and are not considered bounded by non local labels Therefore all local labels within a macro must be unique This mechanism allows the programmer to freely use local labels within a macro definition without regard to the number of times that the macro is expanded Non local labels within a macro expansion are considered to be normal labels and therefore cannot occur more than once unless used with the SET di rective see Chapter 6 A label may occur only once in the label field of an individual source file unless it is used as a local label a label local to a section or is used with the SET directive If a non local label does occur more than once in a label field each reference to that label after the first will be flagged as an error Freescale DSP Assembler Reference Manual 13 Chapter 2 Writing Assembly Language Programs Source Statement Format A line consisting of a label only is a valid line and has the effect of assigning the value of the location counter to the label With the exception of some directives a label is assigned the value of the location counter of the first word of the instruction or data being assem bled 2 4 2 Operation Field The operation field appears after the label field and must be preceded by at least one space or tab Entries in the operation field may be one of three types Opcode Mnemonics that correspond dir
193. ker reads each input object file placing the header file in internal P memory and combining the overlay modules into a contiguous block loaded into external X memory at location 100 hexadecimal Any labels or jumps within the overlay blocks are resolved to addresses relative to the relocatable symbol OVLBASE Since OVLBASE is the first load P memory address it is assigned the value 200 hexadecimal The linker does not guaran tee that a given symbol or section will begin at a particular location unless that information is explicitly specified in the linker memory control file For more information on specific linker operations see the Freescale DSP Linker Librarian Reference Manual 4 8 Example 3 Bootstrap Overlay Many Freescale DSP processors specifically those with RAM based program memory support a bootstrap mode of operation This involves mapping a built in ROM based boot strap program into P memory executing the program to move user supplied code from another location usually EPROM into program RAM then transferring control to the user program Because the user program is loaded in one location e g EPROM but moved to another for execution it is a natural application for assembly language overlay seman tics Another wrinkle in bootstrap mode is that user instruction words are loaded in byte wise fashion such that the load location counter must be incremented by bytes rather 54 DSP Assembler Reference Manual Freescale Chapter 4 So
194. ksum value can be obtained using the CHK function see Chapter 3 default reset Print the conditional assembly directives Freescale DSP Assembler Reference Manual 137 Chapter 6 Assembler Significant Characters and Directives Assembler Directives CM CONST CONTC CONTCK CRE DEX DLD DXL FC FF FM GL GS HDR 138 default reset Preserve comment lines of macros when they are defined Note that any comment line within a macro definition that starts with two con secutive semicolons is never preserved in the macro definition EQU symbols are maintained as assembly time constants and will not be sent to the object file This option if used must be specified before the first symbol in the source program is defined Re enable cycle counts Does not clear total cycle counts The cycle count for each instruction will be shown on the output listing Re enable checksumming of instructions and data Does not clear cumula tive checksum value Print a cross reference table at the end of the source listing This option if used must be specified before the first symbol in the source program is de fined Expand DEFINE symbols within quoted strings Can also be done on a case by case basis using double quoted strings Do not restrict directives in DO loops The presence of some directives in DO loops does not make sense including some OPT directive variations This op tion suppresses erro
195. label operation code operand and data transfer fields The macro definition table is scanned for a match with the operation code If there is no match the operation code and directive tables are scanned for a match with a known opcode Any errors detected by the assembler are displayed before the actual line containing the error is printed Errors and warnings are accumulated and a total number of errors and warnings is printed at the end of the source listing If no source listing is produced error messages are still displayed to indicate that the assembly process did not proceed nor mally The number of errors is returned as an exit status when the assembler returns con trol to the host operating system 1 6 Definition of Terms Since the Freescale DSP architectures are different from normal microprocessors the programmer may not be familiar with some of the terms used in this document The fol lowing discussion serves to clarify some of the concepts discussed later in this manual The Freescale DSP architecture can have as many as five separate memory spaces re ferred to as the X Y L P Program L memory space is a concatenation of X and Y data memory and is considered by the assembler as a superset of the X and Y memory spaces The assembler will generate object code for each memory space but object code can only be generated for one memory space at a time The memory space and address location into which the object code generat
196. large for a short address and outside the range of valid I O short addresses Absolute address too large to use I O short Absolute address too small to use I O short The absolute address being forced short is outside the range of valid I O short ad dresses This usually means that the I O short address has not been ones extend ed Absolute address too large to use short The absolute address value is too large to be forced short Absolute addressing mode not allowed Absolute operands are not allowed with some instructions in particular parallel XY data memory moves Address mode syntax error expected Address mode syntax error expected Address mode syntax error expected or Address mode syntax error expected comma Address mode syntax error expected comma or end of field Address mode syntax error expected offset register Address mode syntax error extra characters Address mode syntax error probably missing A syntax error was detected when scanning the source line operand and or X and Y data fields These errors may indicate omission of a source operand insufficient white space between fields or improper specification of address register indirect addressing modes Argument outside function domain An argument to one of the transcendental built in functions was inappropriate Arithmetic exception An internal floating point exception occurred while evaluating an expression The result of the eval
197. le counts CK Enable checksumming CM Preserve comment lines within macros CONST Make EQU symbols assembly time constants CONTCK Continue checksumming DLD Do not restrict directives in loops GL Make all section symbols global GS Make all sections global static INTR Perform interrupt location checks LB Byte increment load counter LDB Listing file debug MI Scan MACLIB directories for include files PS Pack strings PSM Programmable short addressing mode RP Generate NOP to accommodate pipeline delay RSV Check reserve data memory locations SI Interpret short immediate as long or sign extended SVO Preserve object file on errors Following are descriptions of the individual options The parenthetical inserts specify de fault if the option is the default condition and reset if the option is reset to its default state at the end of pass one A label is not allowed with this directive AE CC CEX CK CL default reset Check address expressions for appropriate arithmetic opera tions For example this will check that only valid add or subtract operations are performed on address terms Enable cycle counts and clear total cycle count Cycle counts will be shown on the output listing for each instruction Cycle counts assume a full instruc tion fetch pipeline and no wait states Print DC expansions Enable checksumming of instruction and data values and clear cumulative checksum The chec
198. le entry and is contiguous with the primary entry in the object file Unlike primary symbol table entries however the format of an auxiliary entry depends on the type and storage class of the main symbol 250 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Components D 3 4 6 1 Filenames The auxiliary table entry for a filename contains a 14 character array followed by an un signed long integer If the integer is zero then the filename is in the array Otherwise it is in the string table at the offset given by the integer value The x_ftype field indicates the memory space used for the stack in compiled modules Declaration Name Description char x_fname Source file name unsigned long unsigned long x_foff String table offset to file name Memory space used by stack Figure E 17 Filename Symbol Auxiliary Entry D 3 4 6 2 Sections Section auxiliary entries have the format shown in Figure E 18 This information is anal ogous to selected fields in the corresponding section header If the object file is relocat able a section symbol entry will have a second auxiliary entry with the format shown in Figure E 19 Declaration long int x_scnlen Description Section length unsigned long x_nreloc Number of relocation entries unsigned long x_nlinno Number of line numbers Unused zero filled
199. llegal memory space specified Y The memory space given is either invalid or inappropriate for the desired operation Illegal move field destination specified Illegal move field destination register specified The destination operand in a data memory move is invalid for the type of instruction specified Illegal move field source specified The source operand in a data memory move is invalid for the type of instruction specified Illegal operator for floating point element Bitwise operators are invalid for floating point values Illegal option An argument to the OPT directive is invalid Illegal processor type The argument to the P command line option is invalid Illegal revision The argument to the R command line option is invalid Illegal secondary mnemonic The secondary mnemonic to an FMPY instruction was not one of FADD FSUB or FADDSUB 204 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Illegal use of SSH as loop count operand The contents of the system stack high register may not be used as the loop count operand of a DO instruction Illegal X field destination specified illegal X field destination register specified illegal Y field destination specified The destination operand in an X or Y memory data move is invalid for the type of instruction specified Illegal Y field source specified The source operand in an X memory data move is invalid for the type of instructi
200. locatable then the physical address is an offset Freescale DSP Assembler Reference Manual 237 Appendix D Freescale DSP Object File Format COFF Object File Components from the start of the logical section implicit or defined by the SECTION directive in which the section is defined In most cases the virtual address is the same as the physical address However for block data sections in Freescale DSP object files the virtual address field holds the repeat count for the single raw data value associated with this section For example if the assembly language source file included a directive of the form BSC 400 FFFF the s_vaddr field would contain the value 400 the s_size field would be 1 or 2 if in L memory and the single raw data word associated with the section would be FFFF The section size is the count of raw data words associated with the section This is in con trast to standard COFF section sizes which usually are given in bytes Raw data words currently are stored in the object file as long 4 byte integers independent of the target processor word size The file pointer fields are file byte offsets into the object file to the start of the current sec tion raw data relocation entries and line number information The counts of relocation and line number entries provide an upper bound for scanning these tables The section flags comprise the section attributes and are described in Figure E 7 238 DSP Assembler Referen
201. lt 68 89 gt 68 90 21 67 77 amp 22 amp amp 22 21 67 82 20 21 67 83 84 21 67 72 3 67 73 lt 22 67 86 lt lt 21 67 85 lt 22 22 gt 22 67 87 gt 22 gt gt 21 67 76 67 81 67 74 22 67 78 22 Il 22 20 Freescale INDEX A Absolute expression 17 Absolute mode 2 9 Address assignment 42 Addressing I O short 85 immediate 88 long 87 long immediate 90 short 86 short immediate 89 Assembler command line 1 device 267 error 196 fatal error 226 installation 1 mode 132 operation 1 option 6 135 output 15 processing 8 verbose 7 warning 142 188 Assembly language 1 Bootstrap mode 54 Buffer 9 address 91 circular 47 DSP Assembler Reference Manual 273 Index end 112 c Checksum 137 138 COFF 231 257 Command line 1 input 4 Command line option 2 A 2 B 3 D 3 Comment 97 delimiter 72 object file 96 257 261 unreported 73 Comment field 15 Conditional assembly 57 65 124 137 Constant 19 binary 19 decimal 19 define 98 99 hexadecimal 19 storage 93 string 20 Cycle count 137 138 D Data block 261 Data hiding 38 Data transfer field 14 Debug 4 Directive 67 BREAK 70 168 183 CONTINUE 70 169 183 ELSE 70 183 ENDF 70 183 ENDI 70 183 ENDL 70 183 ENDW 70 183 FOR 70 170 183 JE 70 171 183 LOOP 70 172 183 REPEAT 70 173 183 UNTIL 70 183 WHILE 7
202. lt errfil gt must be present as an argument but can be any legal operating system file name including an optional pathname The EA option causes the standard error stream to be written to lt errfil gt if lt errfil gt exists the output stream is appended to the end of the file The EW option also writes the standard error stream to lt errfil gt if lt errfil gt exists it is rewound truncated to zero and the output stream is written from the be ginning of the file Example ASM56300 EWerrors prog asm Redirect the standard error output to the file ERRORS If the file al ready exists it will be overwritten Indicates that the assembler should read command line input from lt argfil gt lt argfil gt can be any legal operating system filename including an optional pathname lt argfil gt is a text file containing further options arguments and filenames to be passed to the assembler The arguments in the file need be separated only by some form of white space blank tab newline A semi colon on a line following white space makes the rest of the line a com ment The F option was introduced to circumvent the problem of limited line lengths in some host system command interpreters It may be used as often as desired including within the argument file itself Command options may also be supplied using the DSPASMOPT environment variable See the dis cussion of DSPASMOPT under options at the beginning of this sect
203. mbols that have a memory space attribute of N can have values greater than the maximum ad dress of the target processor Memory space attributes become important when an expression is used as an address Errors will occur when the memory space attribute of the expression result does not match the explicit or implicit memory space specified in the source code Memory spaces are explicit when the address has any of the following forms X lt address expression gt Y lt address expression gt L lt address expression gt P lt address expression gt The memory space is implicitly P when an address is used as the operand of a DO branch or jump type instruction Expressions used for immediate addressing can have any memory space attribute 18 DSP Assembler Reference Manual Freescale Chapter 3 Expressions Internal Expression Representation 3 4 Internal Expression Representation Expression value representation internal to the assembler is dependent on the word size of the target processor The assembler supports a word and a double word integer format internally The actual storage size of an expression value is dependent upon the magni tude of the result but the assembler is capable of representing signed integers up to 64 bits in length These longer integer representations are useful when performing data ini tialization in L memory space Internal floating point representation is almost entirely dependent upon the host environ
204. mment field of the IDENT directive will also be passed on to the object module See also COBJ EXAMPLE If the following line was included in the source file FFILTER IDENT 1 2 FIR FILTER MODULE then the object module identification record would include the module name FFILTER the version number 1 the revision number 2 and the comment field FIR FILTER MODULE Freescale DSP Assembler Reference Manual 123 Chapter 6 Assembler Significant Characters and Directives Assembler Directives IF Conditional Assembly Directive IF lt expression gt ELSE the ELSE directive is optional ENDIF Part of a program that is to be conditionally assembled must be bounded by an IF ENDIF directive pair If the optional ELSE directive is not present then the source statements following the IF directive and up to the next ENDIF directive will be included as part of the source file being assembled only if the lt expression gt has a nonzero result If the lt expres sion gt has a value of zero the source file will be assembled as if those statements be tween the IF and the ENDIF directives were never encountered If the ELSE directive is present and lt expression gt has a nonzero result then the statements between the IF and ELSE directives will be assembled and the statements between the ELSE and ENDIF di rectives will be skipped Alternatively if lt expression gt has a value of zero then the state ments between the IF and EL
205. mode as shown below MOVE DO L Y lt DATAST DATAST EQU Y 23 86 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives gt Long Addressing Mode Force Operator Many DSP instructions allow a long form of addressing If the value of an absolute ad dress 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 LONG 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 op erator gt See also FORCE EXAMPLE Since the symbol DATAST is a not a forward reference in the following sequence of source lines the assembler would pick the short absolute form of addressing DATAST EQU Y 23 MOVE DO L Y DATAST If this is not desirable then the long absolute addressing mode can be forced as shown below DATAST EQU Y 23 MOVE DO L Y gt DATAST Freescale DSP Assembler Reference Manual 87 Chapter 6 Assembler Significant Characters and Directives Assembler Directives 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 DO L 88 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives
206. mory space of the left operand by the right The pound sign is a binary operator signifying the size in bits of the left operand by the right More information on these special operators and their operands is given below Here is another example of data expression generation JCLR 1 X LOC LABEL For this conditional jump the assembler produces the following object file code 02A00481 amp 0 lt lt 8 lt lt 12 I LOC 1 8 amp 0 lt lt 8 lt lt 12 LABEL 0 0 The first expression is evaluated such that the relative address LOC resolved at link time is shifted and masked into the middle eight bits of the base instruction word 02A00481 The expression could have been more complex if the bit number was an external refer ence The relative value of the symbol LABEL occupies the second instruction word D 5 2 Data Expression Interpretation Object file data expressions are similar to standard assembler expressions which gener ally follow the rules of algebra and boolean arithmetic They are written using infix nota tion in conjunction with unary and binary operators and parentheses There are also extensions to the usual set of assembler arithmetic and grouping operators These are control constructs that assist the linker in determining the size type and characteristics of an expression operand 262 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Data Expressi
207. n An appropriate addressing mode long short short jump is substituted 190 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Warnings UO short address cannot be forced long substituted I O short addressing is not valid for this operation The assembler substitutes long addressing Label field ignored The assembler directive does not allow a label so the assembler will not store the label value in the symbol table Load location counter overflow Load location counter underflow The load location counter exceeded its maximum or minimum value The assem bler wraps the counter value around and continues Load origin involves incompatible memory spaces The memory space attribute is regarded by the assembler as a type in the same sense that high level languages use type for variables Symbols may have memory space attributes of X Y L P rogram or N one only N is fully compatible with all other attributes In this case an operand was evaluated with a different memory space attribute than that specified in the directive Load reserved address space violation The load location counter has incremented into a reserved area of data address space Long absolute address cannot be forced Long absolute addressing is not valid for this operation An appropriate addressing mode I O absolute short jump short absolute is substituted Long absolute address cannot be forced substituting I O shor
208. n is generally two moves a compare and a conditional jump Jumps or branches generated by structured control statements are forced long because the number and address of intervening instructions between a control statement and its termination are not known by the assembler The programmer may circumvent this be havior by use of the SCSJMP directive see Chapter 6 Any immediate operands must be preceded by a pound sign Memory references must be preceded by a memory space qualifier X Y or P L memory references are not allowed Operands must be or refer to single word values Freescale DSP Assembler Reference Manual 175 Chapter 7 Structured Control Statements Statement Formatting Note that values in the lt regi gt and lt reg2 gt data registers are not saved before expression evaluation This means that any user data in those registers will be overwritten each time the expression is evaluated at runtime The programmer should take care either to save needed contents of the registers reassign data registers using the SCSREG directive or not use them at all in the body of the particular structured construct being executed The data registers used by the structured control statements are listed in Appendix E 7 4 2 Compound Expressions A compound expression consists of two or more simple expressions section 7 4 1 joined by a logical operator AND or OR The boolean value of the compound expression is de termined by t
209. n the current section an error will be generated and all references within the current section to such a symbol will be flagged as undefined The XREF directive must appear before any reference to lt symbol gt in the section A label is not allowed with this directive See also SECTION XDEF EXAMPLE SECTION FILTER XREF AA CC DD XDEFed symbols within section ENDSEC 166 DSP Assembler Reference Manual Freescale Chapter 7 Structured Control Statements 7 1 Introduction An assembly language provides an instruction set for performing certain rudimentary op erations These operations in turn may be combined into control structures such as loops FOR REPEAT WHILE or conditional branches IF THEN IF THEN ELSE The as sembler however accepts formal high level directives that specify these control struc tures generating the appropriate assembly language instructions for their efficient implementation This use of structured control statement directives improves the read ability of assembly language programs without compromising the desirable aspects of programming in an assembly language 7 2 Structured Control Directives The following directives are used for structured control Note the leading period which distinguishes these keywords from other directives and mnemonics Structured control directives may be specified in either upper or lower case but they must appear in the op code field of the instruction line e g t
210. nal element is shown the required element separators are indicated All elements outside of the angle brackets lt gt must be specified as they appear For example the syntacti cal element lt number gt requires the comma to be specified if the optional element lt number gt is selected Freescale DSP Assembler Reference Manual iii Preface The element names are printed in lower case and contained in angle brackets Some common elements used to describe directives are lt comment gt A statement comment lt label gt A statement label lt expr gt or An assembler expression lt expression gt lt number gt A numeric constant lt string gt A string of ASCII characters enclosed in quotes lt delimiter gt A delimiter character lt option gt An assembler option lt sym gt or An assembler symbol lt symbol gt Supporting Publications DSP56300 Family Manual Freescale Inc DSP Linker Librarian Reference Manual Freescale Inc iv DSP Assembler Reference Manual Freescale Table of Contents Preface Chapter 1 Freescale DSP Assembler 1 1 INtrodUCtOR DEE 1 1 2 Assembly LanQuage EE 1 1 3 installing the Assembler scmuitvennermibeelteutalvewovsrtevavalenunusencterebeddearueiuveoelnies 1 1 4 Running the Assembler EE 1 1 5 Assembler Processing E 8 1 6 Definition Of KEE 8 1 7 Assembler Support for Digital Signal Processing cccceeeeeeeeeeteeeeeeees 9 Chapter 2 Writing Assembly Language Programs
211. nce Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives MSG Programmer Generated Message MSG lt str gt l lt exp gt lt str gt l lt exp gt lt str gt l lt exp gt The MSG directive will cause a message to be output by the assembler The error and warning counts will not be affected The MSG directive is normally used in conjunction with conditional assembly directives for informational purposes The assembly proceeds normally after the message has been printed An arbitrary number of strings and expres sions in any order but separated by commas with no intervening white space can be specified optionally to describe the nature of the message A label is not allowed with this directive See also FAIL WARN EXAMPLE MSG Generating sine tables Freescale DSP Assembler Reference Manual 133 Chapter 6 Assembler Significant Characters and Directives Assembler Directives NOLIST Stop Assembly Listing NOLIST Do not print the listing from this point on including the NOLIST directive Subsequent source lines will not be printed The NOLIST directive actually decrements a counter that is checked for a positive value and is symmetrical with respect to the LIST directive Note the following sequence Counter value currently 1 LIST Counter value 2 LIST Counter value 3 NOLIST Counter value 2 NOLIST Counter value 1 The listing still would no
212. ncorrect for this instruction Invalid relative expression The terms of a relative expression may only participate in addition and subtraction operations and must have opposing signs Invalid secondary opcode The opcode in the second operation field is not one of the instructions FADD FSUB or FADDSUB Invalid section directive modifier The qualifier specified in a SECTION directive was not either GLOBAL or STATIC Invalid section name Section names cannot be local symbols e g they cannot begin with the under score _ character Invalid shift amount A shift expression must evaluate to within the range 0 lt n lt m where mis the maximum address of the target DSP Invalid source address mode The source address mode in a MOVEP instruction was not valid Invalid source address register Invalid source register The source register in a double memory read operation was not valid Invalid storage class The storage class given in a source level debug symbol declaration is unknown Invalid tabs stops specified The argument to the TAB directive is out of range Invalid X field destination address mode Invalid X field source address mode The address mode in the source or destination of the X data move field was invalid 208 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Invalid X field width specified Invalid Y field width specified The argument given to the LSTCOL directive do
213. nificant Characters and Directives Assembler Directives PRCTL Send Control String to Printer PRCTL lt exp gt I lt string gt lt exp gt I lt string gt PRCTL simply concatenates its arguments and ships them to the listing file the directive line itself is not printed unless there is an error lt exp gt is a byte expression and lt string gt is an assembler string A byte expression would be used to encode non printing control characters such as ESC The string may be of arbitrary length up to the maximum as sembler defined limits PRCTL may appear anywhere in the source file and the control string will be output at the corresponding place in the listing file However if a PRCTL directive is the last line in the last input file to be processed the assembler insures that all error summaries symbol ta bles and cross references have been printed before sending out the control string This is so a PRCTL directive can be used to restore a printer to a previous mode after printing is done Similarly if the PRCTL directive appears as the first line in the first input file the control string will be output before page headings or titles The PRCTL directive only works if the L command line option is given otherwise it is ig nored See Chapter 1 for more information on the L option A label is not allowed with this directive EXAMPLE PRCTL 1B E Reset HP LaserJet printer 150 DSP Assembler Reference Manual Freescale
214. nsion would be DC ABCD Freescale DSP Assembler Reference Manual 63 Chapter 5 Macro Operations and Conditional Assembly Dummy Argument Operators Double quotes also make possible DEFINE directive expansion within quoted strings Be cause of this overloading of the double quotes care must be taken to insure against inap propriate expansions in macro definitions Since DEFINE expansion occurs before macro substitution any DEFINE symbols are replaced first within a macro dummy argument string DEFINE LONG _ short STR_MAC MACRO STRING MSG This is a LONG STRING MSG This is a LONG STRING ENDM H 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 5 5 5 Macro Local Label Override Operator It may be desirable to pass a local label as a macro argument to be used as an address reference within the macro body If a circumflex precedes an expression containing an underscore label during macro expansion the associated term will be evaluated with normal local label scope rather than macro call scope Such interpretation disables the usual local label semantics for this particular reference within the macro call Here is an example LOAD MACRO ADDR MOVE P AADDR RO ENDM The macro local label override operator causes the ADDR argument to be interpreted as a local label outside the macro if the exp
215. nternal op code type has been corrupted This is an internal error that should be reported to Freescale Cannot seek to start of line number entries Cannot seek to start of object data Cannot seek to start of object file Cannot seek to start of relocation entries Cannot seek to start of section headers Cannot seek to start of string table Cannot seek to start of symbol table An UO error occurred which prevented the assembler from positioning correctly in the output object file Cannot write file header to object file Cannot write line number entries to object file Cannot write optional header to object file Cannot write relocation entries to object file Cannot write section headers to object file Cannot write string table to object file Cannot write symbols to object file An I O error occurred which prevented the assembler from writing data to the out put object file 226 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Fatal Errors Cannot write control string to listing file Cannot write left margin to listing file Cannot write new line to listing file Cannot write new page to listing file Cannot write page header to listing file Cannot write string to listing file An I O error occurred which prevented the assembler from writing data to the out put listing file Compare select error The comparison indicator passed to the evaluator selection logic was not valid This is a serious internal
216. nts all field widths are reset to their default values A label is not allowed with this directive See also PAGE EXAMPLE LSTCOL 40 20 20 Reset label X and Y data field widths Freescale DSP Assembler Reference Manual 129 Chapter 6 Assembler Significant Characters and Directives Assembler Directives MACLIB Macro Library MACLIB lt pathname gt This directive is used to specify the lt pathname gt as defined by the operating system of a directory that contains macro definitions Each macro definition must be in a separate file and the file must be named the same as the macro with the extension ASM added For example BLOCKMV ASM would be a file that contained the definition of the macro called BLOCKMV If the assembler encounters a directive in the operation field that is not contained in the directive or mnemonic tables the directory specified by lt pathname gt will be searched for a file of the unknown name with the ASM extension added If such a file is found the current source line will be saved and the file will be opened for input as an INCLUDE file When the end of the file is encountered the source line is restored and processing is re sumed Because the source line is restored the processed file must have a macro defi nition of the unknown directive name or else an error will result when the source line is restored and processed However the processed file is not limited to macro definitions and c
217. o R1 will be 2 The last move to R2 is outside of any section and thus the global instance of SYM1 is used the value moved to R2 is 1 4 3 1 Sections and Symbols Symbols may be shared among sections through use of the XDEF and XREF directives The XDEF directive instructs the assembler that certain symbol definitions that occur within the current section are to be accessible by other sections XDEF lt symbol gt lt symbol gt lt symbol gt The XREF directive instructs the assembler that all references to lt symbol gt within the cur rent section are references to a symbol that was declared public within another section with the XDEF directive XREF lt symbol gt lt symbol gt lt symbol gt 38 DSP Assembler Reference Manual Freescale Chapter 4 Software Project Management Sections and Data Hiding XDEFed symbols by default are recognized only in other sections which XREF them They can be made fully global recognizable by sections which do not XREF them by use of the XR option see the OPT directive Chapter 6 Alternatively the GLOBAL directive see Chapter 6 may be used within a section to make the named symbols visible outside of the section Both the XDEF and XREF directives must be used before the symbols to which they refer are defined or used in the section Here is another example SYM1 EQU 1 SECTION SECT1 XDEF SYM2 SYM1 EQU 2 SYM2 EQU 3 ENDSEC SECTION SECT2 XREF SYM2 MOVE SYM1 RO MOVE SYM2 R
218. o definition of the unknown name or an error will result when the source line is restored and processed However the processed file is not limited to macro definitions and can include any legal source code statements Multiple MACLIB directives may be given in which case the as sembler will search each directory in the order in which they were specified 5 3 Macro Definition The definition of a macro consists of three parts the header which assigns a name to the macro and defines the dummy arguments the body which consists of prototype or skel eton source statements and the terminator The header is the MACRO directive its label and the dummy argument list The body contains the pattern of standard source state ments The terminator is the ENDM directive The header of a macro definition has the form lt label gt MACRO lt dummy argument list gt lt comment gt 58 DSP Assembler Reference Manual Freescale Chapter 5 Macro Operations and Conditional Assembly Macro Definition The required label is the symbol by which the macro will be called The dummy argument list has the form lt dumarg gt lt dumarg gt lt dumarg gt The dummy arguments are symbolic names that the macro processor will replace with ar guments when the macro is expanded called Each dummy argument must obey the same rules as global symbol names Dummy argument names that are preceded by an underscore are not allowed Dummy arguments
219. of the DO instruction loop address These instructions include DO ENDDO JMP Jcc JCLR JSET and moves to or from particular control registers Instruction cannot appear immediately after control register access Some instructions must not appear immediately after certain control registers have been accessed These instructions include RTI RTS DO and ENDDO Instruction does not allow data movement specified The desired operation may only be done with a MOVE instruction Invalid address expression An attempt was made to evaluate an expression consisting of two relative terms with the same sign Invalid addressing mode The addressing mode of one of the operands in the instruction was not recognized Invalid buffer type The buffer type specified ina BADDR or BUFFER directive was not one of M mod ulo or R reverse carry Invalid conditional register transfer syntax The syntax for an IFec or Fee conditional address register move was incorrect Invalid destination register The first data move destination register in a double memory read operation was not valid Invalid dummy argument name Macro argument names cannot be local symbols e g they cannot begin with the underscore _ character 206 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Invalid force type The argument to a FORCE directive must be SHORT LONG or NONE Invalid function name The name following the function invoca
220. of the first expression An error will occur if the first expression contains symbols that are not yet defined forward references has a value of less than or equal to zero or falls outside the range 2 lt lt expression gt lt m where mis the maximum address of the target DSP Both expressions can have any memory space attribute lt label gt if present will be assigned the value of the runtime location counter after a valid base address has been established Only one word of object code will be shown on the listing regardless of how large the first expression is However the runtime location counter will be advanced by the number of words generated See also BSC BSB DC EXAMPLE BUFFER BSM BUFSIZ FFFFFFFF INITIALIZE BUFFER TO ALL ONES 94 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives BUFFER Start Buffer BUFFER lt M R gt lt expression gt The BUFFER directive indicates the start of a buffer of the given type Data is allocated for the buffer until an ENDBUF directive is encountered Instructions and most data def inition directives may appear between the BUFFER and ENDBUF pair although BUFF ER directives may not be nested and certain types of directives such as MODE ORG SECTION and other buffer allocation directives may not be used The lt expression gt rep resents the buffer size If less data is allocated than the size of the
221. ol C 186 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Command Line Errors LDB option with no listing file specified using source file The LDB option was given on the command line without a corresponding L to gen erate a listing file If a listing file is not produced debugging packages cannot use it for source tracking Therefore the assembler uses the default assembly language file as input for source tracking Missing command line option argument The expected arguments following a command line option specifier were missing Missing source filename There must be at least one source filename specified on the command line Source file name same as listing file name Source file name same as object file name One of the source files appeared to the assembler to have the same name as the specified listing or object file The assembler aborts rather than potentially writing over a source input file Freescale DSP Assembler Reference Manual 187 Appendix C Assembler Messages Warnings C 3 Warnings Absolute address involves incompatible memory spaces The memory space attribute is regarded by the assembler as a type in the same sense that high level languages use type for variables Symbols may have memory space attributes of X Y L P rogram or N one only N is fully compatible with all other attributes In this case an operand was evaluated with a different memory space attribute than that
222. on specified Immediate addressing mode not allowed Immediate operands are not allowed with some instructions in particular program memory moves MOVEM Immediate operand not allowed Immediate operands are not allowed with some instructions in particular program memory moves MOVEM Immediate operand required The ANDI and ORI instructions must have an immediate value as the source op erand Immediate value too large The immediate operand value is too large for the space allotted in the instruction Immediate value too large to use short The immediate value being forced short is too large to fit into the instruction word Increment value cannot be zero The increment parameter to a DUPF directive must be greater than zero Indexed address mode not allowed XY parallel data moves and the LEA instruction do not allow indexed addressing mode Freescale DSP Assembler Reference Manual 205 Appendix C Assembler Messages Errors Initial debug directive must be FILE In a source file containing debug directives being assembled with the G option the FILE directive must be the first source level debug directive in the input stream Instruction cannot appear at last address of a DO loop Instruction cannot appear at next to last address of a DO loop Instruction cannot appear within last 2 words of a DO loop Instruction cannot appear within last 3 words of a DO loop Some instructions are restricted within a variable range
223. on For D 5 2 1 User Expression The curly braces delimit a user expression within a data expression A user expres sion is that part of a data expression that was written by the programmer and not gener ated by the assembler or linker as part of its control requirements It is useful to isolate the user expression in order to check for relationships among absolute and relative terms In all other respects the curly braces behave like parentheses D 5 2 2 Relocatable Expression The square brackets are used to enclose a relocatable expression The value con tained in the square brackets is an offset from the base of the current section Usually this grouping operator is placed around the value of an assembler local label underscore la bel since these symbols do not migrate to the link file D 5 2 3 Memory Space Operator The at sign is a binary operator that checks the memory space compatibility of the left operand based on the value of the right operand The right operand can have the follow ing values 0 None X space Y space L space P space E space OO P Go A II The compatibility check is made based on the matrix outlined in section 3 3 Expression Memory Space Attribute D 5 2 4 Bit Size Operator The pound sign is a binary operator used to verify the size in bits of the left operand given the value of the right operand The following bit sizes and operand type
224. onal label in the label field and white space separates all distinct fields in the statement Any structured control statement may be followed by a comment on the same logical line 7 5 1 Expression Formatting Given an expression of the form lt op1 gt lt LT gt lt op2 gt OR lt op3 gt lt GE gt lt op4 gt 176 DSP Assembler Reference Manual Freescale Chapter 7 Structured Control Statements Effects on the Programmer s Environment there must be white space blank tab between all operands and their associated opera tors including boolean operators in compound expressions Moreover there must be white space between the structured control directive and the expression and between the expression and any optional directive modifier THEN DO An assembler expression Chapter 3 used as an operand in a structured control statement expression must not have white space in it since it is parsed by the standard assembler evaluation routines IF CVI SQT 4 0 lt GT gt 2 no white space in first operand 7 5 2 FOR LOOP Formatting The FOR and LOOP directives represent special cases The FOR structured control statement consists of several fields FOR lt op1 gt lt op2 gt TO lt op3 gt BY lt op4 gt DO There must be white space between all operands and other syntactic entities such as TO BY and DO As with expression formatting an assembler expression used as an operand must not have white space in it FO
225. onstruct found CONTINUE ignored A BREAK or CONTINUE structure control statement was encountered outside of any active looping construct FOR LOOP REPEAT WHILE Number of macro expansion arguments is greater than definition Number of macro expansion arguments is less than definition A discrepancy exists between the number of arguments specified in a macro defi nition and the number of arguments provided in the macro call Options for both debug and strip specified strip ignored Both the G and Z options were given on the command line The G option takes precedence P space not accessed using MOVE encoding A MOVEP type instruction was given but a P memory reference was not used as an operand The assembler substitutes a valid encoding for the operands in ques tion Page directive with no arguments ignored with page length of zero A PAGE directive with no arguments which ordinarily produces a form feed in the listing output is ignored because a previous PAGE directive specified a page length of zero 192 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Warnings PC relative address involves incompatible memory spaces The memory space attribute is regarded by the assembler as a type in the same sense that high level languages use type for variables Symbols may have memory space attributes of X Y L P rogram or N one only N is fully compatible with all other attributes In t
226. option selection logic OPT directive was not valid This is a serious internal error that should be reported to Freescale 228 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Fatal Errors Out of memory assembly aborted There is not enough internal memory to perform dynamic storage allocation Since the assembler keeps all working information in memory including the symbol table and macro definitions there is the possibility that memory will be exhausted if many symbols or macros are defined in a single assembly run PC relative mode select failure The mode indicator passed to the PC relative addressing mode selection logic was not valid This is a serious internal error that should be reported to Freescale Register selection failure The register number passed to the multiply mask selection logic was not valid This is a serious internal error that should be reported to Freescale Section counter sequence failure The ordering of location counter structures has been corrupted This is an internal error that should be reported to Freescale Section stack mode error The assembler expected to restore a nested section but found the section list emp ty This is an internal error that should be reported to Freescale Too many lines in source file An individual source file contained more than 2 31 lines of code Too many sections in module There is a limit of 255 discrete sections in a given sourc
227. or equality involving floating point val ues should be used with caution since rounding error could cause unexpected results Relational operators are primarily intended for use with the conditional assembly IF direc tive but can be used in any expression 3 6 5 Bitwise operators AND amp Integer only OR I Integer only exclusive OR Integer only The bitwise AND operator yields the bitwise AND function of its operands The bitwise OR operator yields the bitwise OR function of its operands The bitwise exclusive OR operator yields the bitwise exclusive OR function of its oper ands Bitwise operators cannot be applied to floating point operands 3 6 6 Logical operators Logical AND amp amp Logical OR Il The logical AND operator returns an integer 1 if both of its operands are nonzero other wise it returns an integer 0 22 DSP Assembler Reference Manual Freescale Chapter 3 Expressions Operator Precedence The logical OR operator returns an integer 1 if either of its operands is nonzero otherwise it returns an integer 0 The types of the operands may be either integer or floating point the memory space at tribute of the result is None Logical operators are primarily intended for use with the con ditional assembly IF directive but can be used in any expression 3 7 Operator Precedence Expressions are evaluated with the following operator precedence parenthetical expression innermost
228. ords 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 lt lt IOPORT IOPORT EQU Y FFF3 Freescale DSP Assembler Reference Manual 85 Chapter 6 Assembler Significant Characters and Directives Assembler Directives lt Short Addressing Mode Force Operator Many DSP instructions allow a short form of addressing If the value of an absolute ad dress is known to the assembler on pass one or the FORCE SHORT 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 ad dressing can be forced by preceding the absolute address by the short addressing mode force operator lt See also FORCE EXAMPLE Since the symbol DATAST is a forward reference in the following sequence of source lines the assembler would pick the long absolute form of addressing by default MOVE DO L Y DATAST DATAST EQU Y 23 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
229. ore labels are not allowed with this directive LOCAL without preceding SECTION directive A LOCAL directive was encountered outside any previously defined section Long absolute address cannot be used An operand was forced long where only a short or I O short address was valid Long absolute cannot be used force short or I O short A forward reference was forced long where only a short or I O short address was valid Macro cannot be redefined A macro name cannot be used as the label for a second macro definition in the same source file unless the macro is defined and used within a declared section see the SECTION directive Chapter 6 210 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Macro not defined The macro name was not found in the macro lookup table Macro value substitution failed The evaluation of a macro argument expression failed Memory bounds greater than maximum address The bounds argument in a LOMEM or HIMEM directive is invalid Memory counter designator value too large The integer counter designator in an ORG directive is greater than 65535 Memory space must be P or NONE An END directive was encountered while the runtime memory space was X Y or L Missing for function All assembler built in functions require at least one argument which must be en closed in parentheses Missing in expression Parentheses are not balanced in an expression Missing argument T
230. ory mapping field are shown in order in Figure E 29 258 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Differences in DSP Object For Mnemonic Mnemonic memory_map_p memory_map_xa memory_map_x memory_map_xb memory_Map_y memory_Map_xe memory_map_ memory_map_xi memory_map_none memory_Map_xr memory_map_laa memory_map_ya memory_map_lab memory_map_yb memory_map_lba memory_map_ye memory_map_lbb memory_map_yi 2 3 4 5 6 7 8 9 memory_map_le memory_map_yr O memory_map_li memory_map_pt memory_map_pa memory_map_pf memory_map_pb memory_map_emi memory_map_pe memory_map_e0 63 29 92 memory_map_pi memory_map_error 666666 memory_map_pr Figure E 29 Memory Mapping Enumerations D 4 2 Object File Transportability There are many different structure definitions in the COFF specification These definitions consist of fields comprised of varying C data types These data types are recognized by any reasonable C compiler but their characteristics and sizes may change from machine to machine This is acceptable if the COFF files are to be used only on a particular ma chine architecture But if COFF files are produced on one machine to be used on another several problems may arise One is that since the data fields can vary in size there could be alignment problems when accessing structures or individual field
231. ould Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application Buyer shall indemnify and hold Freescale Semiconductor and its officers employees subsidiaries affiliates and distributors harmless against all claims costs damages and expenses and reasonable attorney fees arising out of directly or indirectly any claim of personal injury or death associated with such unintended or unauthorized use even if such claim alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part Freescale and the Freescale logo are trademarks of Freescale Semiconductor Inc All other product or service names are the property of their respective owners Freescale Semiconductor Inc 2008 All rights reserved MS DOS and Windows are trademarks of Microsoft Corporation Preface This manual documents the assembler as of version 6 3 28 of the software Notation The notational conventions used in this manual are DIRECTIVE All assembler mnemonics and directives are shown in bold upper case to highlight them However the assembler will recognize both upper and lower case for mne monics and directives Contains a list of elements or directives one of which must be selected Each choice will be separated by a vertical bar For example R L indicates that either R or L must be selected Contains one or more optional elements If more than one optio
232. ove destination operand in an LMS move must use post incre ment by offset addressing Only post increment or post increment by offset addressing allowed Moves to P memory allow only post increment or post increment by offset address ing Only register direct addressing allowed The instruction allows only register direct addressing Only register direct and indirect addressing allowed The instruction allows only register direct and indirect addressing Only register indirect addressing allowed The instruction allows only register indirect addressing Operation not allowed with address term Only addition and subtraction are allowed in expressions involving addresses or relative terms Page length too small for specified top and bottom margins The sum of the top and bottom margins specified in the PAGE directive is greater than the page length 10 Page length too small to allow default bottom margin The bottom margin exceeds the page length specified in the PAGE directive PC relative address too large to use short The PC relative offset being forced short is too large to fit into the instruction word Freescale DSP Assembler Reference Manual 215 Appendix C Assembler Messages Errors PC relative addressing mode not allowed The PC relative addressing mode is not allowed for this instruction The restriction applies for example to bit manipulation instructions and some jump type instruc tions Phasing error The
233. own to the assembler on pass one not a forward or external reference then the as sembler will always pick the shortest form of immediate addressing consistent with the in struction unless the FORCE LONG directive is active If this is not desired then the long form of addressing can be forced using the immediate long addressing mode force oper ator gt See also 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 DO L If this is not desirable then the long immediate form of addressing can be forced as shown below CNST EQU 5 MOVE gt CNST DO L 90 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives BADDR Set Buffer Address BADDR lt M R gt lt expression gt The BADDR directive sets the runtime location counter to the address of a buffer of the given type the length of which in words is equal to the value of lt expression gt The buffer type may be either Modulo or Reverse carry If the runtime location counter is not zero this directive first advances the runtime location counter to a base address that is a mul tiple of 2K where 2k gt lt expression gt An error will be issued if there is insufficient memory remaining to establish a valid base addr
234. p type instructions and parallel XY data memory moves Register displacement valid only with address register R2 Only address register R2 is valid as a displacement register Relative equate must be in same section An EQU directive with a relative expression operand must be defined in the same section as the section associated with the operand expression Relative expression must be integer A relative expression must evaluate to an integer value Relative expression not allowed Relative expressions are not allowed as arguments to the assembler built in func tions Relative SET must be in same section A SET directive with a relative expression operand must be defined in the same section as the section associated with the operand expression Freescale DSP Assembler Reference Manual 217 Appendix C Assembler Messages Errors Relative terms from different sections not allowed Relative terms defined in different sections are not allowed in expressions This is because the relationship between the terms is based on where the enclosing sec tions are located in memory Reserved name used for symbol name One of the DSP register names has been used as a label operand or directive ar gument These register names in either upper or lower case are reserved by the assembler See Appendix E for a list of DSP register names Runtime space must be P An instruction was encountered and the runtime memory space was not set to P P
235. pcode it will not automatically replace that directive or opcode as previously described In this case the RDIRECT directive must be used to force the replacement See the description of the MACLIB directive below The macro call causes source statements to be generated The generated statements may contain substitutable arguments The statements produced by a macro call are rel atively unrestricted as to type They can be any processor instruction almost any assem bler directive or any previously defined macro Source statements resulting from a macro call are subject to the same conditions and restrictions that are applied to statements writ ten by the programmer To invoke a macro the macro name must appear in the operation code field of a source statement Any arguments are placed in the operand field By suitably selecting the ar guments in relation to their use as indicated by the macro definition the programmer causes the assembler to produce in line coding variations of the macro definition Freescale DSP Assembler Reference Manual 57 Chapter 5 Macro Operations and Conditional Assembly Macro Libraries The effect of a macro call is to produce in line code to perform a predefined function The code is inserted in the normal flow of the program so that the generated instructions are executed with the rest of the program each time the macro is called An important feature in defining a macro is the use of macro calls within the
236. pe The type information is encoded as sets of bits in the field Bits O through 3 hold one of the fundamental type values given in Figure E 13 244 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Components Mnemonic Type T_NULL Type not assigned T_VOID Void T CHAR Character T_SHORT Short integer T_INT Integer T_LONG Long integer T_FLOAT Floating point T_DOUBLE Double word floating point T STRUCT Structure T_UNION Union T_ENUM Enumeration T MOE Member of enumeration T_UCHAR Unsigned character T_USHORT Unsigned short T_UINT Unsigned integer T_ULONG Unsigned long Figure E 13 Fundamental Types Bits 4 through 15 are arranged as six 2 bit subfields These subfields represent levels of the derived types given in Figure E 14 Freescale DSP Assembler Reference Manual 245 Appendix D Freescale DSP Object File Format COFF Object File Components Mnemonic Type DT_NON No derived type DT_PTR Pointer DT_FCN Function DT_ARY Array Figure E 14 Derived Types As an example of encoding fundamental and derived types consider a function returning a pointer to a character The fundamental type is character giving bits 0 3 of the symbol type field the value 2 Bits 4 5 would hold a 2 for the derived type of function and bits 6 7 would contain a 1 for the pointer derived t
237. pendix D Freescale DSP Object File Format COFF Object File Components Declaration Name Description char n_name Symbol name null padded long int n_zeroes Zero in this field indicates name is in string table long int n_offset Offset of name in string table CORE_ADDR n_address Symbol address value unsigned long n_val 2 Symbol value long int n_scnum Symbol section number unsigned long n_type Symbol basic and derived type long int n_sclass Symbol storage class long int n_numaux Number of auxiliary entries Figure E 12 Symbol Table Entry Format D 3 4 1 Symbol Name The first eight bytes in the symbol table entry are a union of a character array and two longs If the symbol name is seven characters or less the null padded symbol name is stored there If the symbol name is longer than seven characters then the entire symbol name is stored in the string table In this case the eight bytes contain two long integers the first is zero and the second is the offset relative to the beginning of the string table of the name in the string table Since there can be no symbols with a null name the ze roes on the first four bytes serve to distinguish a symbol table entry with an offset from one with a name in the first eight bytes D 3 4 2 Symbol Value The symbol value is a union of aCORE_ADDR typedef and an array of two longs If the symbol value is an address the contents will be store
238. pendix D Freescale DSP Object File Format COFF Object File Data Expression For and parentheses Expressions may contain user defined labels integers floating point numbers or literal strings An object file data expression generally follows the guidelines of assembler expressions except that functions are not supported e g they must be evaluated at assembly time and operators are provided for linker specific operations Al so floating point terms found in these expressions are converted to binary values D 5 1 Data Expression Generation Link file data expressions are generated when external or relocatable operands are en countered during assembly or incremental link processing In most cases the operand ex pression is copied verbatim from the source and embellished with link evaluation control constructs For example consider the source line below MOVE FOO RO The DSP96000 assembler produces the following encoding for this line in the object file 3A8D2000 FOO 0 0 Since the symbol FOO is not known to the assembler it generates a two word instruction and places a relocation reference to the expression in the position of the second instruc tion word The braces indicate that this is a user expression that should adhere to certain integrity constraints such as those governing absolute and relative terms Other wise the braces are treated much like parentheses The at sign is a binary operator indicating the me
239. perator and the rest of the characters To position an argument between two alphanumeric characters place a backslash both be fore and after the argument name For example consider the following macro definition SWAP_REG MACRO REG1 REG2 sswap REG1 REG2 using X0 as temp MOVE R REG1 X0 MOVE R REG2 R REG1 MOVE X0 R REG2 ENDM If this macro were called with the following statement SWAP_REG 0 1 then for the macro expansion the macro processor would substitute the character O 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 charac ters for the dummy arguments are to be concatenated in both cases with the character R The resulting expansion of this macro call would be MOVE RO X0 MOVE Ri1 RO MOVE X0O R1 Freescale DSP Assembler Reference Manual 61 Chapter 5 Macro Operations and Conditional Assembly Dummy Argument Operators 5 5 2 Return Value Operator Another macro definition operator is the question mark that returns the value of a sym bol When the macro processor encounters this operator the lt symbol gt sequence is converted to a character string representing the decimal value of the lt symbol gt For ex ample consider the following modification of the SWAP_REG macro described above SWAP_SYM MACRO REG1 REG2 swap REG1 REG2 using X0 as temp MOVE R REG1 X0 MOVE R REG2 R REG1 MOVE X0
240. ple MIN DC MIN 1 0 5 5 3 25 MIN 3 25 MSP lt expression gt Returns the memory space attribute of lt expression gt as an integer value None 0 X space 1 Y space 2 L space 3 P space 4 The lt expression gt may be relative or absolute Example MEM SET MSP ORIGIN save memory space MXP Returns an integer 1 memory space attribute N if the assembler is expanding a macro 0 otherwise Example IF MXP macro expansion active POS lt str1 gt lt str2 gt lt start gt Returns the position of string lt str2 gt in lt str1 gt as an integer starting at position lt start gt If lt start gt is not given the search begins at the beginning of lt str1 gt If the lt start gt argument is specified it must be a positive integer and cannot exceed the length of the source string The memory space attribute of the result will be None Example ID EQU POS DSP56300 56 ID 3 Freescale DSP Assembler Reference Manual 33 Chapter 3 Expressions Functions POW lt expr1 gt lt expr2 gt Returns lt expr1 gt raised to the power lt expr2 gt as a floating point value lt expr1 gt and lt expr2 gt must be separated by a comma The memory space attribute of the result will be None Example BUF EQU CVI POW 2 0 3 0 BUF 8 REL Returns an integer 1 memory space attribute N if the assembler is operating in relative mode 0 otherwise Example IF REL in rela
241. point value lt expres sion gt must be greater than zero The memory space attribute of the result will be None Example LOG EQU LOG 100 0 LOG 4 605170 LST Returns the value of the LIST directive flag as an integer with a memory space at tribute of None Whenever a LIST directive is encountered in the assembler source the flag is incremented when a NOLIST directive is encountered the flag is decremented Example DUP CVI ABS LST list unconditionally LUN lt expression gt Converts the double word lt expression gt to a floating point value For fractional DSPs DSP56300 lt expression gt should represent a binary fraction The memory space attribute of the result will be None Example DBLFRC EQU LUN 3FE0000000000000 DBLFRC 0 5 MAC lt symbol gt Returns an integer 1 memory space attribute N if lt symbol gt has been defined as a macro name 0 otherwise Example IF MAC DOMUL expand macro MAX lt expr1 gt lt exprN gt Returns the greatest of lt expr1 gt lt exprN gt as a floating point value The memory space attribute of the result will be None Example MAX DC MAX 1 0 5 5 3 25 MAN 5 5 32 DSP Assembler Reference Manual Freescale Chapter 3 Expressions Functions MIN lt expr1 gt lt exprN gt Returns the least of lt expr1 gt lt exprN gt as a floating point value The memory space attribute of the result will be None Exam
242. processing See also DUP DUPC DUPF ENDM MACRO EXAMPLE If the input source file contained the following statements DUPA VALUE 12 32 34 DC VALUE ENDM then the assembled source listing would show DUPA VALUE 12 32 34 DC 12 DC 32 DC 34 ENDM 106 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives Note that the lines DUPA VALUE 12 32 34 ENDM will only be shown on the source listing if the MD option is enabled The lines DC 12 DC 32 DC 34 will only be shown on the source listing if the MEX option is enabled See the OPT directive in this chapter for more information on the MD and MEX options Freescale DSP Assembler Reference Manual 107 Chapter 6 Assembler Significant Characters and Directives Assembler Directives DUPC Duplicate Sequence With Characters lt label gt DUPC lt dummy gt lt string gt ENDM The block of source statements defined by the DUPC and ENDM directives will be repeat ed for each character of lt string gt For each repetition every occurrence of the dummy parameter within the block is replaced with each succeeding character in the string If the string is null then the block is skipped lt label gt if present will be assigned the value of the runtime location counter at the start of the DUPC directive processing See also DUP DUPA DUPF ENDM MACRO EXAMPLE If input source file contained
243. pt through another SET directive Symbol cannot be set to new value The label has been defined previously other than with the SET directive Only sym bols defined using the SET directive may be redefined 220 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Symbol defined in current section before GLOBAL directive Symbol defined in current section before XDEF directive The GLOBAL or XDEF directive must appear within a section prior to the definition of any symbols in its argument list Any symbols within a section which must be accessible outside the section should be declared in a GLOBAL or XDEF directive immediately following the SECTION directive Symbol name too long Symbols are limited to 512 characters The first character must be alphabetic or the underscore character A Z a z _ The remaining characters must be alphanu meric including the underscore character A Z a z 0 9 _ Symbol not previously defined The symbol specified in an UNDEF directive was not previously defined in a DE FINE directive Symbol redefined The symbol has already been used as a label in a previous context Symbol tag mismatch A matching tag reference could not be found for a tagged symbol table entry Symbol undefined on pass 2 The symbol used as an operand or directive argument was never defined in the source program Symbols must start with alphabetic character Symbol names must begin with an
244. r is similar to the standard COFF a out header but there are differences The magic number in this header is not the same as the magic number in the file header this magic number is used indicate the file type to a host operating system The magic number and version stamp fields currently are not used by the Freescale DSP tools and are set to zero The text size field gives the size of all text type data executable code in the object file The data size field holds a count of all initialized data apart from code in the file The uninitialized data size field is not used and is set to zero Freescale DSP Assembler Reference Manual 235 Appendix D Freescale DSP Object File Format COFF Object File Components The program entry field represents the address given in the assembler END directive The text start and data start values contain the low addresses for text and data segments respectively The text and data end values contain the high addresses for text and data segments respectively Note that addresses are expressed in terms of the C language typedef CORE_ADDR A CORE_ADDR is a structure containing a long 4 byte address and an enumeration type which classifies the address according to memory space X Y L P and memory mapping internal external etc See section D 4 1 for more informa tion on the CORE_ADDR structure Declaration Description long int Magic number long int vstamp Version stamp long int tsize Size
245. rective was encountered without a preceding IF conditional assembly directive ELSE without associated IF directive An ELSE directive was encountered before a matching IF conditional structured control statement Empty bit mask field The first operand of a BFxxx type instruction was zero End of structure or union without matching definition A source level debug end of structure symbol declaration was recognized without a preceding structure or union definition ENDBUF without associated BUFFER directive An ENDBUF directive was encountered without a preceding BUFFER directive ENDEF without associated DEF directive A source level debug ENDEF directive was encountered without a preceding DEE directive ENDF without associated FOR directive ENDI without associated IF directive An end of conditional or end of loop directive was encountered before a matching conditional or loop structured control statement Freescale DSP Assembler Reference Manual 199 Appendix C Assembler Messages Errors ENDIF without associated IF directive An ENDIF directive was encountered without a preceding IF conditional assembly directive ENDL without associated LOOP directive An end of loop directive was encountered before a matching loop structured con trol statement ENDM without associated MACRO directive An ENDM directive was encountered without a preceding MACRO directive ENDSEC without associated SECTION directive An
246. rectives see Chapter 6 The assembler operates in either absolute or relative mode depending on the presence of the command line A option In relative mode the assembler creates relocatable object files These files can be combined and relocated using the Freescale DSP linker In ab solute mode the assembler generates absolute object files Absolute files cannot be re located but can be loaded directly for execution By default the assembler runs in relative mode 1 7 Assembler Support for Digital Signal Processing As mentioned previously the assembler offers facilities commonly found in other macro assemblers such as nested macro capabilities include files and conditional assembly The assembler must also provide extensions in support of the unconventional architecture of the Freescale digital signal processors as well as aids for programming DSP specific applications Some of these features are discussed briefly below see the appropriate chapters later in this manual for more information The assembler supports the use of arbitrary algebraic expressions as arguments to vari ous directives and as immediate operands in certain instructions Terms of these expres sions may consist of the assembler s own built in functions which perform data conversion comparison and computational operations In the digital signal processing domain transcendental functions for computing sine cosine and natural logarithm are useful for initializing
247. red I O short however the destination operand does not qualify so the source operand is assumed to be the I O short operand Storage block size not a power of 2 The expression in a DSR directive did not evaluate to a power of 2 Since the DSR directive is generally used to allocate FFT buffers for reverse carry operations the size of the buffer may be in error String truncated in expression evaluation Only the first four characters of a string constant are used during expression eval uation except for arguments to the DC directive see Chapter 6 Strip not valid in relocatable mode ignored The Z option is valid only when the A option is also given 194 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Warnings Unresolved external reference Ordinarily the assembler does not flag unresolved references in relative mode as suming they will be resolved at link time If the UR option is specified the assem bler will generate this warning if any symbols are undefined during the second pass Freescale DSP Assembler Reference Manual 195 Appendix C Assembler Messages Errors CA Errors Absolute address contains forward reference force short or I O short address The assembler attempted a default to short addressing which failed Either the ab solute address is too large or it needs to be forced I O short Absolute address must be either short or I O short The absolute address is too
248. reescale DSP Object File Format COFF Object File Components D 3 4 6 8 Beginning of Blocks and Functions The format for C language symbol entries for the beginning of blocks and functions is de scribed in Figure E 26 The source file line number is retained The x_endndx provides a link to the next beginning of block or function symbol in the symbol table Declaration Description Unused zero filled unsigned long Source file line number long int X_endndx Unused zero filled Index of next beginning of block or function unsigned long x_type Function prologue epilogue index Unused zero filled Figure E 26 Beginning of Block or Function Auxiliary Entry D 3 4 6 9 Structure Union and Enumeration Names The format for auxiliary entries related to structure union and enumeration names is giv en in Figure E 27 The tag index is used to access the tag symbol record that describes this structure Note that in Freescale DSP COFF the size of the associated structure or union is in words as opposed to bytes as in standard COFF 256 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Differences in DSP Object For Declaration Name Description long int x_tagndx Tag index Unused zero filled unsigned long Size of structure union or enumeration in words Unused zero filled Figure E 27 Structure
249. register number in an operand using post increment post dec rement or indexed by offset addressing mode Nn is different from the number specified for the address register Rn The offset register number may be omitted from these types of indirect addressing modes the assembler defaults to the ad dress register number Offset value greater than string size The offset parameter in a substring construct is larger than the composite length of the input string argument Only absolute addressing allowed The instruction allows only absolute addressing Only absolute and register direct addressing allowed The instruction allows only absolute and register direct addressing Only immediate addressing allowed The instruction allows an immediate source operand only Only immediate and register direct addressing allowed The instruction allows only immediate and register direct addressing modes 214 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Only immediate and register direct and indirect addressing allowed The instruction allows only immediate register direct and register indirect ad dressing modes Only PC relative addressing allowed The instruction allows only PC relative addressing Only PC relative and register direct addressing allowed The instruction allows only PC relative and register direct addressing Only post increment by offset addressing allowed with LMS move The initial data m
250. rguments are stored as is but must be byte values e g within the range 0 255 floating point numbers are not allowed Single and multiple character strings are handled in the following manner 1 Single character strings are stored in a word whose lower seven bits repre sent the ASCII value of the character EXAMPLE R 000052 2 Multiple character strings represent words whose bytes are composed of concatenated sequences of the ASCII representation of the characters in the string unless the NOPS option is specified see the OPT directive If the number of characters is not an even multiple of the number of bytes per DSP word then the last word will have the remaining characters left aligned and the rest of the word will be zero filled If the NOPS option is given each character in the string is stored in a word whose lower seven bits represent the ASCII value of the character EXAMPLE AB CD 414200 434400 See also BSC DC EXAMPLE TABLE DCB two 0 strings O CHARS DCB A B C D Freescale DSP Assembler Reference Manual 99 Chapter 6 Assembler Significant Characters and Directives Assembler Directives DEFINE Define Substitution String DEFINE lt symbol gt lt string gt The DEFINE directive is used to define substitution strings that will be used on all follow ing source lines All succeeding lines will be searched for an occurrence of lt symbol gt which will be replaced by lt string gt Thi
251. rlay The assembler is invoked in absolute mode A option and generates an executable and listing file All files on the command line are processed as a single assembly run and all are used to produce the output BOOTPROUJ ASM is read first and sets up the appropriate absolute addresses for later sections Since no explicit base address was given in the sec tion files both load and runtime addresses will continue from one section to the other e g they will be contiguous For example if only two words of instruction were between each of the START and END labels the runtime value for END1 and START2 would be hex 102 However the load address of the code associated with these labels assuming a 16 bit target word size would be C004 hexadecimal Similarly the runtime value for END2 would be 104 hex and the corresponding load address would be C008 hexadecimal 4 8 2 Relative Mode Implementation In relative mode each of the source files is assembled separately to create individual ob ject files The object files are combined to build a single executable file A preamble file is not necessary to handle bootstrap files in relative mode because the addresses are es tablished at link time In order to generate bytewide load addresses the LB option can be specified on the assembler command line using the O command line option ASM56300 B L OLB SECT1 This command assembles the file SECT1 ASM and creates a relocatable object file called SEC
252. rogram SCO option must be used before any label The SCO option sends structured control statements to the object file and thus must be specified before any symbols are defined in the source file Second data move destination accumulator same as operand destination accumulator The destination accumulator in a double memory read instruction is the same as the DALU accumulator specification Secondary opcode not allowed The secondary opcode field is allowed only with the FMPY instruction Section not encountered on pass 1 The section declared in a SECTION directive was not encountered during the first pass of the assembler This situation indicates an internal assembler error and should be reported to Freescale SET requires label The SET directive must have a label in order to associate the directive argument with a symbol name SET symbol names cannot be used with GLOBAL SET symbol names cannot be used with LOCAL SET symbol names cannot be used with XDEF A symbol defined using the SET directive cannot be exported from a section using GLOBAL LOCAL or XDEF 218 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Short absolute address too large The flagged operand value is greater than the maximum short address of the target DSP Short I O absolute address too large Short I O absolute address too small The flagged operand value is outside the I O address range of the target DSP Shor
253. rror The FAIL directive is normally used in conjunction with conditional assembly directives for exceptional condition check ing The assembly proceeds normally after the error has been printed An arbitrary num ber of strings and expressions in any order but separated by commas with no intervening white space can be specified optionally to describe the nature of the generated error A label is not allowed with this directive See also MSG WARN EXAMPLE FAIL Parameter out of range 118 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives FORCE Set Operand Forcing Mode FORCE SHORT LONG NONE The FORCE directive causes the assembler to force all immediate memory and address operands to the specified mode as if an explicit forcing operator were used Note that if a relocatable operand value forced short is determined to be too large for the instruction word an error will occur at link time not during assembly Explicit forcing operators over ride the effect of this directive A label is not allowed with this directive See also lt gt lt gt EXAMPLE FORCE SHORT force operands short Freescale DSP Assembler Reference Manual 119 Chapter 6 Assembler Significant Characters and Directives Assembler Directives GLOBAL Global Section Symbol Declaration GLOBAL lt symbol gt lt symbol gt lt symbol gt The GLOBAL d
254. rs on particular directives in loops default reset Expand DEFINE directive strings in listing Fold trailing comments Any trailing comments that are included in a source line will be folded underneath the source line and aligned with the opcode field Lines that start with the comment character will be aligned with the label field in the source listing The FC option is useful for displaying the source listing on 80 column devices Use form feeds for page ejects in the listing file Format assembler messages so that the message text is aligned and broken at word boundaries Make all section symbols global This has the same effect as declaring every section explicitly GLOBAL This option must be given before any sections are defined explicitly in the source file default reset in absolute mode Make all sections global static All section counters and attributes will be associated with the GLOBAL section This op tion must be given before any sections are defined explicitly in the source file default reset Generate listing header along with titles and subtitles Ignore case in symbol section and macro names This directive must be is sued before any symbols sections or macros are defined DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives INTR LB LDB LOC MC MD MEX MI MSW MU NL NOAE NOCC NOCEX NOCK NOCL Freescale
255. rve as operands in structured control state ment expressions The structured control statement expressions described below are evaluated at run time and will be referred to in the following discussion simply as expres sions A structured control statement expression may be simple or compound A compound ex pression consists of two or more simple expressions joined by either AND or OR but not both in a single compound expression 7 4 1 Simple Expressions Simple expressions are concerned with the bits of the Condition Code Register CCR These expressions are of two types The first type merely tests conditions currently spec ified by the contents of the CCR section 7 4 1 1 The second type sets up a comparison of two operands to set the condition codes and afterwards tests the codes section 7 4 1 2 7 4 1 1 Condition Code Expressions A variety of tests identical to those in the Jcc instruction may be performed based on the CCR condition codes The condition codes in this case are preset by either a user generated instruction or a structured operand comparison expression section 7 4 1 2 Each test is expressed in the structured control statement by a mnemonic enclosed in an gle brackets the mnemonics are described in Appendix E Condition Code Mnemonics 174 DSP Assembler Reference Manual Freescale Chapter 7 Structured Control Statements Simple and Compound Expressions When processed by the assembler the expression
256. ry Instruction allows parallel data move 268 DSP Assembler Reference Manual Freescale Appendix E Instruction Set Information DSP56300 Information E 1 1 4 Loop Instructions The DSP56300 instructions used for loop operations are DO Start hardware loop ENDDO Exit from hardware loop E 1 1 5 Move Instructions The DSP56300 instructions used for move operations are LUA Load updated address MOVE Move data MOVEC Move control register MOVEM Move program memory MOVEP Move peripheral data E 1 1 6 Program Control Instructions The DSP56300 instructions used for program control are DEBUG Enter debug mode DEBUGcc Enter debug mode conditionally ILLEGAL Illegal instruction interrupt Jcc Jump conditionally JCLR Jump if bit clear JMP Jump JScc Jump to subroutine conditionally JSCLR Jump to subroutine if bit clear JSET Jump if bit set JSSET Jump to subroutine if bit set JSR Jump to subroutine NOP No operation REP Repeat next instruction RESET Reset on chip peripheral devices RTI Return from interrupt RTS Return from subroutine STOP Stop processing low power standby SWI Software interrupt WAIT Wait for interrupt low power standby Instruction allows parallel data move Freescale DSP Assembler Reference Manual 269 Appendix E Instruction Set Information DSP56300 Information E 1 2 Register Names and Usage The following DSP56300 regist
257. s Another issue is byte ordering between machines Given an arbitrary byte stream some machines store the bytes in a word starting at the least significant bit LSB end of the word while others store bytes starting at the most significant bit MSB end of the word Freescale DSP Assembler Reference Manual 259 Appendix D Freescale DSP Object File Format COFF Differences in DSP Object For The Freescale DSP version of COFF addresses these potential problems by normalizing the object file Normalization occurs in a number of ways All structure and union ele ments are converted to long values and raw data is stored in 4 byte quantities indepen dent of the word size of the target processor In some cases this wastes space in the object file and in memory but it was considered worth the price for transportability among supported hosts Also it is not a completely portable solution by any means e g for ma chines with larger than 4 byte word sizes The byte ordering issue was dealt with by establishing a baseline ordering providing com pliance for foreign hosts with conversion code This introduces overhead logic on ma chines that do not support the baseline word order but again it was seen as a reasonable trade off to insure transportability of object files among development environments Note that byte swapping logic only comes into play for fields that are not byte atomic such as integer fields Character arrays in structures for e
258. s P and the counter used as the runtime location counter is counter 5 It will not be initialized and the last previous value of counter 5 will be used The load memory space is Y Since neither H L nor any counter expression was specified as the load counter the default load counter counter 0 will be used as the load location counter The default load counter will be initialized to 8000 146 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives PAGE Top of Page Size Page PAGE lt exp1 gt lt exp2 gt lt exp5 gt The PAGE directive has two forms 1 If no arguments are supplied then the assembler will advance the listing to the top of the next page In this case the PAGE directive will not be output 2 The PAGE directive with arguments can be used to specify the printed format of the output listing Arguments may be any positive absolute integer expression The arguments in the operand field as explained below are separated by com mas Any argument can be left as the default or last set value by omitting the ar gument and using two adjacent commas The PAGE directive with arguments will not cause a page eject and will be printed in the source listing A label is not allowed with this directive The arguments in order are PAGE_WIDTH lt exp1 gt Page width in terms of number of output columns per line default 80 min 1 max 255 PAGE_LENG
259. s a LONG STRING MSG This is a short sentence 80 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives Function Delimiter All assembler built in functions start with the symbol See Section 3 8 for a full discus sion of these functions EXAMPLE SVAL EQU SQT FVAL OBTAIN SQUARE ROOT Freescale DSP Assembler Reference Manual 81 Chapter 6 Assembler Significant Characters and Directives Assembler Directives 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 82 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives 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 interven ing blanks between the string concatenation operator and the two strings EXAMPLE ABC DEF ABCDEF Freescale DSP Assembler Reference Manual 83 Chapter 6 Assembler Significant Characters and Directives Assembler Directives Substring Delimiter lt string gt lt offset gt lt length gt Square brackets delimit a substring operation The lt string gt argum
260. s directive is useful for providing better documen tation in the source program lt symbol gt must adhere to the restrictions for non local la bels That is it cannot exceed 512 characters the first of which must be alphabetic and the remainder of which must be either alphanumeric or the underscore _ A warning will result if a new definition of a previously defined symbol is attempted The assembler out put listing will show lines after the DEFINE directive has been applied and therefore rede fined symbols will be replaced by their substitution strings unless the NODXL option in effect see the OPT directive Macros represent a special case DEFINE directive translations will be applied to the macro definition as it is encountered When the macro is expanded any active DEFINE directive translations will again be applied DEFINE directive symbols that are defined within a section will only apply to that section See the SECTION directive A label is not allowed with this directive See also UNDEF EXAMPLE If the following DEFINE directive occurred in the first part of the source program DEFINE ARRAYSIZ 10 SAMPLSIZ then the source line below DS ARRAYSIZ would be transformed by the assembler to the following DS 10 SAMPLSIZ 100 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives DS Define Storage lt label gt DS lt expression gt Th
261. s expecting the start of a quoted string Syntax error extra characters Extra characters were found after an instruction or directive operand Syntax error invalid assignment operator The loop assignment operator in a FOR structured control statement is not an equals sign Syntax error invalid compound operator Structured control statement compound operators are either AND or OR Syntax error invalid conditional operator The conditional operator in a structure control statement expression is not valid Syntax error invalid statement terminator There were extra or invalid characters found at the end of a structured control statement Syntax error missing address mode specifier An instruction operand was not specified 222 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Syntax error missing operand An operand in a structured control statement expression was missing Syntax error in directive name list A character other than a comma was found separating the arguments in an RDI RECT or SYMOBy directive name list Syntax error in dummy argument list A character other than a comma was found separating the dummy arguments in a macro definition MACRO directive or a dummy argument began with the under score character _ Syntax error in macro argument list A character other than a comma was found separating the arguments in a macro Call Syntax error in macro name li
262. s the assembler to report assembly progress beginning of passes opening and closing of input files to the standard error output stream This is useful to insure that assembly is proceeding normally Example ASM56300 V myprog asm Assemble the file MYPROG ASM and send progress lines to the standard error output This option causes the assembler to strip symbol information from the ab solute load file Normally symbol information is retained in the object file for symbolic reference purposes Note that this option is valid only when the assembler is in absolute mode via the A command line option and when an object file is created B option Example ASM56300 A B Z myprog asm Assemble the file MYPROG ASM in absolute mode and strip symbol information from the load file created as output A list of operating system compatible filenames including optional path names If no extension is supplied for a given file the assembler first will attempt to open the file using the filename as supplied If that is not success ful the assembler appends ASM to the filename and attempts to open the file again If no pathname is specified for a given file the assembler will look for that file in the current directory The list of files will be processed sequen tially in the order given and all files will be used to generate the object file and listing The assembler will redirect the output listing to the standard output if the output listing
263. sing processor type There was no argument provided for the P command line option Missing quote Missing quote in string A single or double quote character was expected by the string parsing routines Missing revision There was no argument provided for the R command line option Missing section name No section name was given as an argument to the SECTION directive 212 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Missing size argument No size value was given as an argument to the SIZE directive Missing string after concatenation operator The string concatenation operator must be followed by another quoted string Missing symbol name The SYMOB4J XDEF and XREF directives require at least one symbol name as an argument Missing symbol value No symbol value was given as an argument to the VAL directive Missing tag for end of structure or union A source level debug structure or union declaration was found without a corre sponding tag definition Missing tag name No tag name was given as an argument to the TAG directive Mnemonic must indicate precision using S or X suffix Floating point instructions generally must indicate the precision of their operation by appending either S for single precision or X for single extended precision Mode not specified The MODE directive was not followed by either RELATIVE or ABSOLUTE Move from SSH or SSL cannot follow move to SP Mo
264. ssist in the de velopment of large software projects Complex software projects often are divided into smaller program units These subprograms may be written by a team of programmers in parallel or they may be programs written for a previous development effort that are going to be reused The assembler provides directives to encapsulate program units and permit the free use of symbol names within subprograms without regard to symbol names used in other programs These encapsulated program units are called sections Sections are also the basis for relocating blocks of code and data so that concerns about memory placement are postponed until after the assembly process 4 2 Sections A section is bounded by a SECTION directive and an ENDSEC directive For example SECTION lt section name gt GLOBAL STATIC LOCAL Section source statements ENDSEC All symbols that are defined within a section have the lt section name gt associated with them This serves to protect them from like named symbols elsewhere in the program By default a symbol defined inside any given section is private to that section unless the GLOBAL or LOCAL qualifiers accompany the SECTION directive More information on the GLOBAL and LOCAL qualifiers can be found in Sections and Data Hiding below Any code or data inside a section is considered an indivisible block with respect to relo cation Code or data associated with a section is independently relocatable within th
265. st A character other than a comma was found separating the arguments in a PMAC RO directive name list Syntax error in symbol name list A character other than a comma was found separating the arguments in an XDEF or XREF directive name list Tag name not found A matching tag name could not be found for the current source level debug struc ture or union declaration Too many fields specified for instruction An instruction field that was expected to be empty contained data other than a com ment This can happen when an instruction using only the X data transfer field en counters data other than a comment in the Y data transfer field Two dummy arguments are the same Two dummy arguments in a macro definition MACRO directive have the same name UNDEF symbol must be a global symbol name The argument to an UNDEF directive cannot be a local label e g a name starting with the underscore character _ Freescale DSP Assembler Reference Manual 223 Appendix C Assembler Messages Errors Unexpected end of file missing ENDF Unexpected end of file missing ENDI Unexpected end of file missing ENDL Unexpected end of file missing ENDW Unexpected end of file missing UNTIL The matching end of conditional or end of loop directive for a conditional or loop ing structured control statement was never found Unexpected end of file missing COMMENT delimiter The second occurrence of the delimiter character in a
266. standard output Freescale DSP Assembler Reference Manual 185 Appendix C Assembler Messages Command Line Errors C 2 Command Line Errors Cannot open command file Cannot open listing file Cannot open object file The file associated with a F L or B command line option was not found Cannot open source file The assembly source input file was not found Duplicate listing file specified ignored Duplicate object file specified ignored The L and B command line options were encountered more than once on the command line Only the first occurrence of each option is used The assembler continues processing Illegal command line D option argument The symbol name given in a D command line option is invalid possibly too long or does not begin with an alphabetic character or the substitution string is not en closed in single quotes Illegal command line I option argument A problem occurred when attempting to save the include file path string Illegal command line M option argument A problem occurred when attempting to save the MACLIB file path string Illegal command line P option argument The string provided as the processor type is not valid illegal command line R option argument The string provided as the revision level is not valid Illegal command line option The option specified on the command line was not recognized by the assembler Interrupted The assembler was interrupted by a keyboard break Contr
267. t pathname This option specifies that a listing file is to be created for assembler output lt Istfil gt can be any legal operating system filename including an optional pathname A hyphen also may be used as an argument to indicate that the listing file should be sent to the standard output although the listing file is routed to standard output by default If a pathname is not specified the file will be created in the current directory If no filename is specified the assembler will use the basename filename without extension of the first filename encountered in the source input file list and append LST to the basename If the L option is not specified then the assembler will route listing output to the standard output usually the console or terminal screen by default The L option should be specified only once If the file named in the L option already exists it will be overwritten Example ASM56300 L filter asm gauss asm In this example the files FILTER ASM and GAUSS ASM are assem bled together to produce a listing file Because no filename was giv en with the L option the output file will be named using the DSP Assembler Reference Manual 5 Chapter 1 Freescale DSP Assembler Running the Assembler basename of the first source file in this case FILTER The listing file will be called FILTER LST M lt pathname gt This is equivalent to a source statement of the form MACLIB lt pathname gt The pathname
268. t addressing Long absolute addressing is not valid for this operation The assembler substitutes I O short addressing Long absolute address cannot be forced substituting short addressing Long absolute addressing is not valid for this operation The assembler substitutes short absolute addressing Long immediate cannot be forced Long immediate data is not valid for this operation An appropriate size for the tar get DSP is substituted Freescale DSP Assembler Reference Manual 191 Appendix C Assembler Messages Warnings Long PC relative address cannot be forced Long PC relative addressing is not valid for this operation An appropriate ad dressing mode short PC relative is substituted Macro expansion not active A macro must have been called prior to using the ARG or CNT functions see Chapter 3 Macro name is the same as existing assembler directive Macro name is the same as existing assembler mnemonic The name of the macro being defined conflicts with the name of an assembler di rective or mnemonic Either use a different macro name or use the RDIRECT di rective to remove the directive or mnemonic name from the assembler lookup tables No control registers accessed using MOVE encoding A MOVEC type instruction was given but no control registers were used as oper ands The assembler substitutes a valid encoding for the operands in question No looping construct found _BREAK ignored No looping c
269. t as an integer Useful in conjunction with the CC NOCC and CONTCC assembler options see the OPT directive The mem ory space attribute of the result will be None Example IF CCC gt 200 cycle count gt 200 CEL lt expression gt Returns a floating point value which represents the smallest integer greater than or equal to lt expression gt The memory space attribute of the result will be None Example CEIL SET CEL 1 05 CEIL 1 0 Freescale DSP Assembler Reference Manual 27 Chapter 3 Expressions Functions CHK Returns the current instruction data checksum value as an integer Useful in con junction with the CK NOCK and CONTCK assembler options see the OPT direc tive Note that assignment of the checksum value with directives other than SET could cause phasing errors due to different generated instruction values between passes The memory space attribute of the result will be None Example CHKSUM SET CHK reserve checksum value CNT Returns the count of the current macro expansion arguments as an integer A warning will be issued if this function is used when no macro expansion is active The memory space attribute of the result will be None Example ARGCNT SET CNT squirrel away arg count COH lt expression gt Returns the hyperbolic cosine of lt expression gt as a floating point value The mem ory space attribute of the result will be None Example HYCOS EQ
270. t be disabled until another NOLIST directive was issued A label is not allowed with this directive See also LIST OPT EXAMPLE IF LISTOFF NOLIST Turn the listing off ENDIF 134 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives OPT Assembler Options OPT lt option gt lt option gt lt option gt lt comment gt The OPT directive is used to designate the assembler options Assembler options are giv en in the operand field of the source input file and are separated by commas Options also may be specified using the command line O option see Chapter 1 All options have a default condition Some options are reset to their default condition at the end of pass one Some are allowed to have the prefix NO attached to them which then reverses their meaning Options can be grouped by function into five different types Listing format control Reporting options Message control Symbol options Assembler operation OD AON Listing Format Control These options control the format of the listing file FC Fold trailing comments FF Form feeds for page ejects FM Format messages PP Pretty print listing RC Relative comment spacing Freescale DSP Assembler Reference Manual 135 Chapter 6 Assembler Significant Characters and Directives Assembler Directives Reporting Options These options control what is reported in
271. t or I O short address expected A short or I O short address was expected as the second operand of a JCLR JSET JSCLR or JSSET instruction Short PC relative address too large The flagged operand value is greater than the maximum PC relative address of the target DSP SSH cannot be both source and destination register In a MOVE instruction the SSH register cannot be both the source and destination operand Start argument greater than machine word size The start parameter of a FLD function has a value larger than can fit in the tar get machine word Start position greater than source string size The start parameter in a POS function is larger than the total length of the source string argument Storage block size must be greater than zero The size of a buffer allocated with the DSM DSR BSM BSB and other buffer di rectives was too small Storage block size out of range The size of the buffer in a DSM DSR BSM BSB or other buffer directive is too large to be allocated Storage block too large The runtime location counter overflowed while the assembler was attempting to al locate storage through a DSM or DSR directive The assembler automatically ad vances the program counter to the next valid base address given the size of the modulo or reverse carry buffer This error occurs when the sum of the expression Freescale DSP Assembler Reference Manual 219 Appendix C Assembler Messages Errors in t
272. ters are used to set up the required counters and comparands In some cases these registers are effectively reserved the FOR loop uses two data registers to hold the step and target values respectively and performs no save restore operations on these registers The assembler in fact does no save restore processing in any structured control operation it simply moves the operands into appropriate registers to execute the compare See Appendix E for a list of registers used by the assembler in support of struc tured control statements on a particular processor The SCSREG directive Chapter 6 may be used to reassign structured control statement registers The MEX assembler op tion see the OPT directive Chapter 6 may be used to send the assembler generated code to the listing file for examination of possible register use conflicts 178 DSP Assembler Reference Manual Freescale Freescale Decimal Hex 0 00 1 01 2 02 3 03 4 04 5 05 6 06 7 07 8 08 9 09 10 OA 11 OB 12 OC 13 OD 14 OE 15 OF 16 10 17 11 18 12 19 13 20 14 21 15 22 16 23 17 24 18 25 19 26 1A 27 1B 28 1C 29 1D 30 1E 31 1F 32 20 33 21 34 22 35 23 DSP Assembler Reference Manual ASCII NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR So S1 DLW DC1 DC2 DC3 DC4 NAK SYN ETB CAN Appendix A ASCII Character Codes Decimal Hex 64 40 65 41 66 42 67 43 68 44 69 45 70 46 71 47 72 48 73 49 74 4A 75 4B 76 4C 77 4D 7
273. the appropriate file type CLN or CLD to the basename If the B option is not specified then the assembler will not generate an object file The B option should be specified only once If the file named in the B option already exists it will be overwritten Example ASM56300 Bfilter main asm fft asm fio asm In this example the files MAIN ASM FFT ASM and FIO ASM are assembled together to produce the relocatable object file FILTER CLN D lt symbol gt lt string gt Freescale This is equivalent to a source statement of the form DEFINE lt symbol gt lt string gt lt string gt must be preceded by a blank and should be enclosed in single quotes if it contains any embedded blanks Note that if single quotes are used they must be passed to the assembler intact e g some host command interpreters will strip single quotes from around arguments The D lt sym bol gt lt string gt sequence can be repeated as often as desired See the DE FINE directive Chapter 6 for more information Example ASM56300 D POINTS 16 prog asm All occurrences of the symbol POINTS in the program PROG ASM will be replaced by the string 16 DSP Assembler Reference Manual 3 Chapter 1 Freescale DSP Assembler Running the Assembler EA lt errfil gt EW lt errfil gt F lt argfil gt These options allow the standard error output file to be reassigned on hosts that do not support error output redirection from the command line
274. the file The information in the section header is described in Figure E 6 Declaration Name Description char s_name Section name null padded CORE_ADDR s_paddr Physical address CORE_ADDR s_vaddr Virtual address long int S Size Section size in words long int s_scnptr File pointer to raw data long int s_relptr File pointer to relocation entries long int s_Innoptr File pointer to line number entries unsigned long s_nreloc Number of relocation entries unsigned long s_ninno Number of line number entries long int s_flags Section flags See Figure E 7 Figure E 6 Section Header Format The section name is an 8 byte character array padded with null zero bytes if required In Freescale relocatable object files section names may be longer than eight characters In this case the convention used for long symbol names is followed where if the least sig nificant four bytes of the section name field contain zeroes the name is in the symbol table at the offset given by the most significant four bytes of the name field See section D 3 4 1 for more information on the handling of long symbol names The physical address is the address where the section text or data will reside in memory The address value depends upon whether the section is absolute or relocatable If the section is absolute then the physical address is the actual address where the section will be loaded into memory If the section is re
275. the runtime location counter is counter 5 It will not be initialized and the last previous value of counter 5 will be used The load memory space is Y Since neither H L nor any counter expression was specified as the load counter the default load counter counter 0 will be used as the load location counter The default load counter will be initialized to 8000 If the last example shown was used in the following code sequence assume the runtime counter associated with P space had a previous value of 0010 ORG P 5 Y 8000 RLMUL MOVE X R0 D4 S Y R4 D7 S FMPY S D4 D7 D0 MOVE DO S X R1 then the label RLMUL would have a value of 0010 and a memory space attribute of P space the code generated would load into Y memory starting at 8000 and the runtime address associated with the code would start at 0010 4 5 4 Circular Buffers To take advantage of the special DSP addressing capabilities a circular buffer must be aligned on an appropriate address boundary with respect to its size For a buffer to be located properly in memory the lower bits of the starting address which encompass one less than the buffer size must be zero For example the lowest address greater than zero at which a buffer of size 32 may be located is 32 20 hexadecimal More generally the buffer base address must be modulo the buffer size or a multiple of 2 where 2 is greater than or equal to the size of the buffer Buffers may be allocated manuall
276. tion character was not recognized Invalid label field width specified The argument given to the LSTCOL directive does not allow enough room on the listing line for the remaining fields to be output Invalid macro name Macro names cannot be local symbols e g they cannot begin with the underscore _ character Invalid memory space attribute The memory space attribute given is not one of the letters X Y L or P Invalid mode The mode specified in a MODE directive was not either RELATIVE or ABSOLUTE Invalid opcode field width specified Invalid opcode 2 field width specified Invalid operand field width specified Invalid operand 2 field width specified The argument given to the LSTCOL directive does not allow enough room on the listing line for the remaining fields to be output Invalid page length specified The minimum page length allowed by the PAGE directive is 10 lines per page The maximum is 255 Invalid page width specified The minimum page width allowed by the PAGE directive is 1 column per line The maximum is 255 Invalid radix expression The expression in the RADIX directive does not evaluate to one of the supported constant bases 2 8 10 or 16 Invalid register combination The source operand registers in a FMPY instruction cannot be used together Freescale DSP Assembler Reference Manual 207 Appendix C Assembler Messages Errors Invalid register specified The direct register operand is i
277. tional Assembly Dummy Argument Operators argument can be declared null when calling a macro However it must be declared ex plicitly null Null arguments can be specified in four ways by writing the delimiting com mas in succession with no intervening spaces by terminating the argument list with a comma and omitting the rest of the argument list by declaring the argument as a null string or by simply omitting some or all of the arguments A null argument will cause no character to be substituted in the generated statements that reference the argument If more arguments are supplied in the macro call than appear in the macro definition a warning will be output by the assembler 5 5 Dummy Argument Operators The assembler macro processor provides for text substitution of arguments during macro expansion In order to make the argument substitution facility more flexible the assem bler also recognizes certain text operators within macro definitions which allow for trans formations of the argument text These operators can be used for text concatenation numeric conversion and string handling 5 5 1 Dummy Argument Concatenation Operator Dummy arguments that are intended to be concatenated with other characters must be preceded by the concatenation operator N to separate them from the rest of the charac ters The argument may precede or follow the adjoining text but there must be no inter vening blanks between the concatenation o
278. tions that change program flow Instructions that cannot be repeated include DO Jcc JCLR JMP JSET JScc JSCLR JSR JSSET REP RTI RTS and SWI CONST option must be used before any label This option which prevents EQU symbols from being exported to the object file must be given before any label is encountered in the source file Freescale DSP Assembler Reference Manual 197 Appendix C Assembler Messages Errors Contents of assigned register in previous instruction not available Due to pipelining if an address register Rn or Nn is changed in the previous in struction the new contents are not available for use as a pointer until the next in struction Count must be an integer value The argument to a DUP directive did not evaluate as an integer expression CRE option must be used before any label The CRE option must be activated before any labels are encountered so that the assembler can append cross reference data to all applicable symbol table entries Data allocation exceeds buffer size Data allocated between a BUFFER ENDBUF sequence exceeded the size speci fied in the BUFFER directive Decimal constant expected A character other than ASCII 0 through 9 either followed the decimal constant de limiter or appeared in an expression where a decimal value was expected by de fault DEFINE symbol must be a global symbol name A local label a symbol beginning with the underscore character may not be
279. tive mode RND Returns a random value in the range 0 0 to 1 0 The memory space attribute of the result will be None Example SEED DC RND save initial seed value RVB lt expr1 gt lt expr2 gt Reverse the bits in lt expr1 gt delimited by the number of bits in lt expr2 gt If lt expr2 gt is omitted the field is bounded by the target word size Both expressions must be single word integer values Example REV EQU RVB VAL reverse all bits in value SCP lt str1 gt lt str2 gt Returns an integer 1 memory space attribute N if the two strings compare 0 oth erwise The two strings must be separated by a comma Example IF SCP STR MAIN does STR equal MAIN 34 DSP Assembler Reference Manual Freescale Chapter 3 Expressions Functions SGN lt expression gt Returns the sign of lt expression gt as an integer 1 if the argument is negative 0 if zero 1 if positive The memory space attribute of the result will be None The lt ex pression gt may be relative or absolute Example IF SGN INPUT is sign positive SIN lt expression gt Returns the sine of lt expression gt as a floating point value The memory space at tribute of the result will be None Example DC SIN CVF COUNT FREQ compute sine value SNH lt expression gt Returns the hyperbolic sine of lt expression gt as a floating point value The memory space attribute of the result will be None Example
280. uation is probably not valid 196 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Assembler directive or mnemonic not found An argument to the RDIRECT directive was not a recognized assembler directive or mnemonic Base argument larger than machine word size The base parameter of a FLD function has a value larger than can fit in the tar get machine word Binary constant expected A character other than ASCII 0 or 1 either followed the binary constant delimiter or appeared in an expression where a binary value was expected by default Bit mask cannot span more than eight bits If the first operand of a BFxxx type instruction was shifted one bit to the right until the low order bit was a 1 the resulting value must not exceed FF hexadecimal Cannot conditionally repeat write to memory A move to memory cannot be preceded by a REPcc type instruction Cannot nest section inside itself A section of a given name may not have another SECTION directive with the same name declared inside it Cannot nest symbol definitions A source level debug DEF directive was encountered inside another DEF EN DEF pair Cannot open include file The specified INCLUDE file cannot be found or the operating system limit on open files has been exceeded Cannot repeat this instruction Cannot repeat two word instruction The REP instruction cannot be used to repeat two word instructions or instruc
281. ulation of overlays and the intermixing of label definition and code generation in multiple memory spaces without having to reinitialize a location counter every time the load memory space is changed 4 5 2 Overlays If the last half of the operand field in an ORG directive dealing with the load memory space and counter is not specified then the assembler will assume that the load memory space and load location counter are the same as the runtime memory space and runtime loca tion counter In this case object code is being assembled to be loaded into the address and memory space where it will be when the program is run and is not an overlay If the load memory space and counter are given in the operand field then the assembler always generates code for an overlay Whether the overlay is absolute or relocatable de pends upon the current operating mode of the assembler and whether the load counter value is an absolute or relative expression If the assembler is running in absolute mode or if the load counter expression is absolute then the overlay is absolute If the assembler is in relative mode and the load counter expression is relative the overlay is relocatable Runtime relocatable overlay code is addressed relative to the location given in the runtime location counter expression This expression if relative may not refer to another overlay block See section 1 6 for more information on location counters and overlays Freescale DSP Assem
282. ult reset Do not flag unresolved external references Do not print warning messages default reset Allow scoping of symbols within nested sections default reset Pretty print listing file The assembler attempts to align fields at a consistent column position without regard to source file formatting default reset Pack strings in DC directive Individual bytes in strings will be packed into consecutive target words for the length of the string Space comments relatively in listing fields By default the assembler always places comments at a consistent column position in the listing file This option allows the comment field to float on a line containing only a label and opcode the comment would begin in the operand field Generate NOP instructions to accommodate pipeline delay If an address register is loaded in one instruction then the contents of the register is not available for use as a pointer until after the next instruction Ordinarily when the assembler detects this condition it issues an error message The RP op tion will cause the assembler to output a NOP instruction into the output stream instead of issuing an error Print symbol table at the end of the source listing This option has no effect if the CRE option is used default reset Structured control statements generate non local labels that ordinarily are not visible to the programmer This can create problems when local labels are interspersed among structur
283. ument by a comma If no second argument is present the default counter counter 0 is assumed The LCV function will not work correctly if used to specify the runtime counter value of a relocatable overlay This is because the resulting value is an overlay expression and overlay expressions may not be used to set the runtime counter for a subsequent overlay See the ORG directive Chapter 6 for more information Example ADDR LCV R save runtime address LEN lt string gt Returns the length of lt string gt as an integer The memory space attribute of the result will be None Example SLEN SET LEN string SLEN 6 LFR lt expression gt For binary fractional DSPs DSP56300 this functions performs scaling and con vergent rounding to obtain the fractional representation of the floating point lt ex pression gt as a long integer The memory space attribute of the result will be None Example LFRAC EQU LFR LFLT Store binary form LNG lt expr1 gt lt expr2 gt Concatenates the single word lt expr1 gt and lt expr2 gt into a double word value such that lt expr1 gt is the high word and lt expr2 gt is the low word The memory space attribute of the result will be None Example LWORD DC LNG HI LO build long word Freescale DSP Assembler Reference Manual 31 Chapter 3 Expressions Functions LOG lt expression gt Returns the natural logarithm of lt expression gt as a floating
284. used as a DEFINE directive symbol Displacement address mode not allowed Long displacement addressing is not allowed with some instructions in particular parallel XY data memory moves Divide by zero The expression evaluator detected a divide by zero DO loop address must be in current section The loop address of a DO loop cannot fall outside the bounds of its enclosing sec tion This is particularly important in relative mode as the loop address is calculat ed based on the starting address of the section Dummy argument not found The dummy argument name given as an argument to the ARG function was not found in the macro dummy argument list 198 DSP Assembler Reference Manual Freescale Appendix C Assembler Messages Errors Duplicate destination register not allowed If the opcode operand portion of an instruction specifies a destination register the same register or portion of that register may not be specified as a destination in the parallel data bus move operation Duplicate source and destination register not allowed If the opcode operand portion of an instruction specifies a source register the same register or portion of that register may not be specified as a destination in the parallel data bus move operation Either source or destination memory space must be X or Y One of the operands in a MOVEP instruction must reference a location in X or Y memory ELSE without associated IF directive An ELSE di
285. used as the runtime location counter It will be reset to the value of OVL1 If the assembler is in absolute mode via the A command line option then OVL1 must be an absolute expression If OVL1 is an absolute expres sion the assembler uses the absolute runtime location counter If OVL1 is a relo catable value the assembler uses the relative runtime location counter In this case OVL1 must not itself be an overlay symbol e g defined within an overlay block The load memory space is Y Since neither H L nor any counter expression was specified as the load counter the default load counter counter 0 will be used as the load location counter The counter value and mode will be whatever it was the last time it was referenced ORG XL E8 Sets the runtime memory space to X Selects the L counter counter 1 associated with X space to use as the runtime location counter The L counter will not be ini tialized and its last value will be used The load memory space is set to E and the qualifier 8 indicates a bytewise RAM configuration Instructions and data will be generated eight bits per output word with byte oriented load addresses The de fault load counter will be used and there is no explicit load origin Freescale DSP Assembler Reference Manual 145 Chapter 6 Assembler Significant Characters and Directives Assembler Directives ORG P 5 Y 8000 Indicates code will be generated for an absolute overlay The runtime memory space i
286. value associated with a symbol has changed between pass 1 of the assembly and pass 2 This error can occur spontaneously in conjunction with other errors The assembler is designed to avoid phasing errors in general If a phasing error occurs without any other errors this may represent an internal error which should be reported to Freescale One exception is the use of the checksumming function CHK with the EQU di rective Instruction encoding may be incomplete after the first pass due to forward referencing causing the checksum value to change between passes Because of this the SET directive must be used to assign the checksum value to a symbol Possible invalid white space between operands or arguments The assembler verifies that fields which should not contain operands or values are empty If these fields are not empty the assembler produces this error Post decrement addressing mode not allowed The post decrement addressing mode is not allowed for this instruction The re striction applies for example to bit manipulation instructions and some jump type instructions Post decrement by offset addressing mode not allowed The post decrement by offset addressing mode is not allowed for this instruction The restriction applies for example to bit manipulation instructions and some jump type instructions Post increment addressing mode not allowed The post increment addressing mode is not allowed for this instruction The restric
287. ve then all sym bols defined in the section until the next ENDSEC directive are visible to the immediately enclosing section The effect is as if every symbol in the section were defined within the parent section This is useful when a section needs to be independently relocatable but data hiding within an enclosing section is not required Freescale DSP Assembler Reference Manual 155 Chapter 6 Assembler Significant Characters and Directives Assembler Directives The division of a program into sections controls not only labels and symbols but also mac ros and DEFINE directive symbols Macros defined within a section are private to that section and are distinct from macros defined in other sections even if they have the same macro name Macros defined outside of sections are considered global and may be used within any section Similarly DEFINE directive symbols defined within a section are pri vate to that section and DEFINE directive symbols defined outside of any section are glo bally applied There are no directives that correspond to XDEF for macros or DEFINE symbols and therefore macros and DEFINE symbols defined in a section can never be accessed globally If global accessibility is desired the macros and DEFINE symbols should be defined outside of any section Sections can be nested to any level When the assembler encounters a nested section the current section is stacked and the new section is used When the ENDSEC directive
288. ve from SSH or SSL cannot follow update to SP A MOVE instruction using the system stack SSH or SSL as a source operand cannot immediately follow a MOVE which uses the stack pointer SP as a desti nation operand MU option must be used before any code or data generation The MU option must be given before any data allocation directive BSC DC DS DSM DSR or any instruction appears in the source file Negative immediate value not allowed The immediate count value for a DO or REP instruction cannot be less than zero Freescale DSP Assembler Reference Manual 213 Appendix C Assembler Messages Errors Negative or empty DO loop not allowed The loop address given in a DO instruction must specify an address at least one greater than the current program counter value NOGS option must be used before any section The NOGS option must be activated before any explicit sections are encountered so that the assembler can use the appropriate counters for section relocation No previous function declaration A EF debugging directive was encountered without a corresponding BF directive Not enough fields specified for instruction There were no operands specified fora MOVE MOVEC MOVEM or MOVEP in struction No update mode not allowed The no update register addressing mode is not allowed for this instruction e g the LEA instruction Offset register number must be the same as address register number The explicit offset
289. ve inside DEF ENDEF declaration illegal directive outside DEF ENDEF declaration Some source level debug directives such as FILE make no sense and are not allowed inside DEF ENDEF declarations Conversely other directives such as VAL are not allowed outside of a DEF ENDEF declaration Illegal directive inside DO loop A directive was encountered inside a DO loop that is not allowed in that context Some invalid directives include any buffer type directive DSM DSR etc section directives or any directive which alters the current location counter designation MODE ORG Illegal function argument An invalid argument was passed to one of the assembler built in functions in par ticular the LCV function Illegal instruction in single instruction DO loop A conditional break instruction BRKcc cannot be used as the only instruction in a DO loop Freescale DSP Assembler Reference Manual 203 Appendix C Assembler Messages Errors Illegal memory counter specified The memory counter designation supplied in the ORG directive was not one of H high L low or a positive integer expression in parentheses illegal memory map character The memory map character supplied in the ORG directive was not one of I inter nal E external R ROM A port A or B port B Illegal memory space specified Illegal memory space specified L Illegal memory space specified P Illegal memory space specified X I
290. ve mode Do not perform interrupt location checks Do not print macro calls Do not print macro definitions default reset Do not print macro expansions default reset Do not scan MACLIB directory paths for include files Do not issue warning on memory space incompatibilities default reset Do not display nesting levels on listing Do not allow scoping of symbols within nested sections Do not pretty print listing file Source lines are sent to the listing file as they are encountered in the source with the exception that tabs are expanded to spaces and continuation lines are concatenated into a single physical line for printing Do not pack strings in DC directive Individual bytes in strings will be stored one byte per word default reset Do not space comments relatively default reset Do not generate instructions to accommodate pipeline delay Do not maintain the current local label scope when a structured control state ment label is encountered DSP56300 only default reset Interpret an eight bit short immediate value moved to a fractional register as a short unless forced long DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives NOU NOUR NOW NS PP PS RC RP SCL SCO SI SO SVO Freescale default reset Do not print the lines excluded from the assembly due to a con ditional assembly directive defa
291. w memory bounds MODE Change relocation mode MSG Programmer generated message ORG Initialize memory space and location counters RADIX Change input radix for constants RDIRECT Remove directive or mnemonic from table SCSJMP Set structured control branching mode SCSREG Reassign structured control statement registers UNDEF Undefine DEFINE symbol WARN Programmer generated warning 68 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives 6 3 2 Symbol Definition The directives used to control symbol definition are ENDSEC End section EQU Equate symbol to a value GLOBAL Global section symbol declaration GSET Set global symbol to a value LOCAL Local section symbol declaration SECTION Start section SET Set symbol to a value XDEF External section symbol definition XREF External section symbol reference 6 3 3 Data Definition Storage Allocation The directives used to control constant data definition and storage allocation are BADDR Set buffer address BSB Block storage bit reverse BSC Block storage of constant BSM Block storage modulo BUFFER Start buffer DC Define constant DCB Define constant byte DS Define storage DSM Define modulo storage DSR Define reverse carry storage ENDBUF End buffer 6 3 4 Listing Control and Options The directives used to control the output listing are LIST List th
292. while FOR DOWNTO allows counting downward The programmer may specify an increment decrement step size in lt op4 gt or elect the default step size of 1 by omitting the BY clause A FOR TO loop is not executed if lt op2 gt is greater than lt op3 gt upon entry to the loop Similarly a FOR DOWNTO loop is not executed if lt op2 gt is less than lt op3 gt NOTES lt op1 gt must be a writable register or memory location It is initialized at the beginning of the loop and updated at each pass through the loop Any im mediate operands must be preceded by a pound sign Memory refer 170 DSP Assembler Reference Manual Freescale Chapter 7 Structured Control Statements Syntax ences must be preceded by a memory space qualifier X Y or P L memory references are not allowed Operands must be or refer to single word values The logic generated by the FOR directive makes use of several DSP data registers see Appendix E In fact two data registers are used to hold the step and target values respectively throughout the loop they are never re loaded by the generated code It is recommended that these registers not be used within the body of the loop or that they be saved and restored prior to loop evaluation The DO keyword is optional EXAMPLE FOR X CNT 0 TO Y targ 2 114 loop on X CNT ENDF IF Statement SYNTAX JE lt expression gt THEN lt stmtlist gt ELSE lt stmtlist gt END
293. xample should not have their bytes ex changed The byte ordering for Freescale DSP COFF is shown in Figure E 30 It adheres to what sometimes is called the big endian approach to byte and word ordering Addr n 1 Addr n 2 Addr n 3 MSB 1 LSB 1 LSB Figure E 30 Freescale DSP COFF Byte Ordering D 4 3 Structure Size Fields In some of the COFF data structures there is a size field which gives the size of a block in the target processor environment For example there are several symbol table auxil iary entries that specify the size of a structure or union for debug purposes In standard COFF these sizes ordinarily are in bytes but in Freescale DSP COFF they are given in words unless otherwise indicated The use of word sizes for debug entities should be dis tinguished from file pointer offset values in the object file File pointers are indeed byte offsets within the object file that are used by utilities to process information in the object file itself D 4 4 Relocation Information In standard COFF the r_symnax field of any given relocation record points to an entry in the symbol table corresponding to a symbol reference requiring modification When the standard COFF linker performs symbol resolution pairing symbol definitions with match ing references it updates the relocation entry to point to the symbol definition and dis 260 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF O
294. xpansion would be MOVE RO D4 L MOVE Ri1 RO MOVE D4 L R1 Freescale DSP Assembler Reference Manual 75 Chapter 6 Assembler Significant Characters and Directives Assembler Directives Return Value of Symbol Character The lt symbol gt sequence when used in macro definitions will be replaced by an ASCII string representing the value of lt symbol gt This operator may be used in association with the backslash operator The value of lt symbol gt must be an integer not floating point EXAMPLE Consider the following macro definition SWAP_SYM MACRO REG1 REG2_ swap REG1 REG2 using D4 L as temp MOVE R REG1 D4 L MOVE R REG2 R REG1 MOVE D4 L 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 RO D4 L MOVE Ri1 RO MOVE D4 L R1 76 DSP Assembler Reference Manual Freescale Chapter 6 Assembler Significant Characters and Directives Assembler Directives Return Hex Value of Symbol Character The lt symbol gt sequence when used in macro definitions will be replaced by an ASCII string representing the hexadecimal value of lt symbol gt This operator may be used in as sociation with the backslash operator The value of lt symbol gt must be an integer not floating point EXAMPLE Consider the following macro definition
295. xtra fields ignored There were extra fields specified in an assembler directive Freescale DSP Assembler Reference Manual 201 Appendix C Assembler Messages Errors First data move destination accumulator same as operand destination accumulator The destination of the data move field is the same as the Data ALU destination First data move field required with this instruction A TFR3 instruction requires a register and a data move operand field First data move source accumulator same as operand destination accumulator The source of the data move field is the same as the Data ALU destination Floating point constant expected A character other than ASCII 0 through 9 e or E or appeared in an expres sion where a floating point value was expected by default Floating point not allowed in relative expression Relative expressions are generally used for address computation therefore a float ing point value would not be appropriate Floating point value not allowed An immediate value expressed in floating point notation is only valid in a MOVE type instruction Forcing not specified The type of forcing operand was not given in a FORCE directive Function result out of range The result computed by a transcendental function was too large to be represented on the host machine GL option must be used before any section The GL option must be activated before any explicit sections are encountered so that the assembler c
296. y or by using one of the assembler s special buffer di rectives ORG X 100 BUF1 DS 24 BUF2 DSM 32 The ORG statement sets the origin to hexadecimal 100 in X memory The first buffer BUF1 is manually allocated with a size of 24 Since the starting address is hex 100 the buffer is already suitably aligned The label BUF1 is assigned the runtime counter value at the beginning of the buffer The second buffer is allocated using the DSM directive which automatically sets the buffer starting address before reserving space In this case the first buffer ended at location 117 hexadecimal so the assembler advances the pro gram counter to location 120 hex before assigning a value to the buffer label BUF2 Freescale DSP Assembler Reference Manual 47 Chapter 4 Software Project Management Example 1 Multi Programmer Environment Buffers are special purpose data structures but they are named and accessed with labels like any other data block They therefore adhere to the same rules governing data hiding in sections that any other segment of code or data would follow A buffer allocated when the assembler is in absolute mode either via A or an absolute ORG or MODE directive is placed in memory according to the absolute value of the runtime location counter at as sembly time A buffer allocated in relative mode a relocatable buffer is suitably aligned within its relocation section at assembly time During the link phase a section enclosing any
297. ype The value in the symbol entry type field would result in 01100010 binary or 62 hexadecimal D 3 4 5 Symbol Storage Class The symbol storage class indicates how a symbol will be used during execution or debug ging Some storage classes actually reflect how a symbol will be stored e g as a register parameter Other storage classes provide information for special symbols used in debug ging such as the beginning of blocks or the end of functions Storage classes are outlined in Figure E 15 246 DSP Assembler Reference Manual Freescale Appendix D Freescale DSP Object File Format COFF Object File Components Mnemonic Type C_EFCN C_NULL Physical end of function No storage class C_AUTO Automatic variable C_EXT External symbol C_STAT Static symbol C_REG Register variable C_EXTDEF External definition C_LABEL C_ULABEL Label Undefined label C_MOS Member of structure C_ARG C_STRTAG Function argument Structure tag C_MOU Member of union C_UNTAG Union tag C_TPDEF Type definition C_USTATIC Uninitialized static C_ENTAG Enumeration tag C_MOE C_REGPARAM Member of enumeration Register parameter C_FIELD Freescale Bit field Figure E 15 Storage Classes DSP Assembler Reference Manual 247 Appendix D Freescale DSP Object File Format COFF Object File Components Mnemonic Typ
Download Pdf Manuals
Related Search
Related Contents
First Alert 6 Channel Dvr With 2 User's Manual 2014 Sistema de infoentretenimiento Cadillac CUE TT320X Mode d`emploi Radio Shack PRO LX7 User's Manual Cellular Line SOSSOLARCMULTI6 mobile device charger Instrucciones de usuario Netgear WNDAP360 User's Manual Copyright © All rights reserved.
Failed to retrieve file