Home

VisualDSP++® 5.0 Assembler and Preprocessor

image

Contents

1. LE LEFTO LEFTZ LENGTH LINE LN LOAD LOG2 LOGB LOOP LR LSHIFT LT 0 1 2 3 4 5 6 7 8 9 10 ll 12 13 14 15 ANT AX BM I OD ODE1 ODE2 ODIFY ROB ROF R1B R1F R2B R2F RB RF S V ROB ROF E OFO OFZ OP OPSPECIAL OF U OFFSETOF OR P20 P32 P40 PACK PAGE PC PCSTK PCSTKP PM PMADR PMBANK1 PMDAE PMDAS POP POVLO POVLI PSALE PSAIS PSA2E PSA3E PSA3S PSA4E PSA4S PUSH PX PX1 PX2 RETAIN_NAME RO R1 R2 R3 R4 RF5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 READ RECIPS RFRAME RND ROT RS RSQRTS RTI RTS SCALB SCL SE SET SF SIN SIZE SIZEOF SQR SR VisualDSP 5 0 Assembler and Preprocessor Manual 1 43 Assembler Syntax Reference Table 1 10 SHARC Processor Assembler Keywords Cont d SSF SSFR SSI SSIR ST STEP STKY STRUCT STS SUF SUFR SV SW SZ TAG TCOUNT TE TGL TPERIOD TRUE TRUNC TST TYPE TRAP UF UI UNPACK UNTIL UR USF USFR US USIR USTAT1 USTAT2 UUF UUFR UUIR UUIR VAL WITH XOR Table 1 11 TigerSsHARC Processor Assembler Keywords ADI __DATE__ FILE __LastSuffix__ __LINE__ TIME LALIGN ALIGN_CODE ELIF ELSE ENDIF EXTERN FILE FILE_ATTR GLOBAL LIF IMPORT LEFTMARGI LIST LIST_DATA LIST_DATFILE LIST_DEFTAB LIST_LOCTAB LIST_WRAPDATA MESSAGE OLIST_DATA
2. MR3 0 MR3 2 MR1 0 MRO MR1 MR2 MR3 MR4 PRO PRI PR1 0 RO through R31 XSTAT YSTAT XYSTAT XRO through XR31 YRO through YR31 Accelerator Register Group TRO through TR31 THRO THR1 THR2 THR3 EP Register Group BMAX BMAXC BUSLK FLGPIN FLGPINCL FLGPINST SDRCON SYSCON SYSCONCL SYSCONST SYSCTL SYSTAT SYSTATCL Misc Register Group AUTODMAO AUTODMA1 BTBCMD BTBDATA BTBOTGO through TBOTG3 BTB1TGO through TB1TG3 BTB2TGO through TB2TG3 BTB3TGO through TB3TG3 BTBOTRO through TBOTR3 BTB1TRO through TB1TR3 BTB2TRO through TB2TR3 BTB3TRO through TB3TR3 BTBLRUO through TBLRU3 CACMDO CACMD2 CACMD4 CACMD8 CACMD10 1 46 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 11 TigerSHARC Processor Assembler Keywords Cont d CACMDALL CADATAO CADATA2 CADATA4 CADATA8 CADATALO CADATAALL CASTATO CASTAT2 CASTAT4 CASTAT8 CASTAT10 CASTATALL CCATRO CCAIR2 CCAIR4 CCAIR8 CCAIRIO CCATRALL CCNTO CCNT1 CUMP CMCTL DBGE DC4 through DC13 DCDO DCD1 DCD2 DCD3 DCNT DCNTCL DCNTST Dcso DCS1 DCS2 DCS3 DSTAT DSTATC EMUCTL EMUDAT EMUIR EMUSTAT DCODE LATCLH LATCLL LATH LATL LATSTH LATSTL MASKH MASKL NSTAT NTEN NTCTL VBUSLK VDBG VHW VDMAO through IVDMA13 VIRQO VIRQI VIRQ2 VIRO3 VLINKO VLINK1 VLINK2 VLINK3 vs VTIMEROH
3. WISUAUDSP 5 0 Assembler and Preprocessor Manual Revision 3 2 March 2009 Part Number 82 000420 04 Analog Devices Inc One Technology Way ANALOG Norwood Mass 02062 9106 DEVICES Copynght Information 2009 Analog Devices Inc ALL RIGHTS RESERVED This docu ment may not be reproduced in any form without prior express written consent from Analog Devices Inc Printed in the USA Disclaimer Analog Devices Inc reserves the right to change this product without prior notice Information furnished by Analog Devices is believed to be accurate and reliable However no responsibility is assumed by Analog Devices for its use nor for any infringement of patents or other rights of third parties which may result from its use No license is granted by impli cation or otherwise under the patent rights of Analog Devices Inc Trademark and Service Mark Notice The Analog Devices logo VisualDSP Blackfin SHARC and Tiger SHARC are registered trademarks of Analog Devices Inc All other brand and product names are trademarks or service marks of their respective owners CONTENTS PREFACE Puipa Cesonia xiii orndat Tu ONE ro E xiii Manual EO sersa xiv Whats Now inthe Mantal acorn xiv Technical or Customer SUpport saesineriuissnni Xv Supported ProCEssOTS og aidnnjaisiule ania RE iea xvi Produet Tntormatiai srsgriiiki tanede niniaren xvi Anales Devices Web SIE ccrirnrereraonareaie en xvi VisualDSP Onli
4. Macro Definition __ADSP2116x__ Present when running easm2 proc ADSP 2116x with the ADSP 2116x processor __ADSP21261__ Present when running easm2 proc ADSP 21261 with the ADSP 21261 processor __ADSP21262__ Present when running easm2 proc ADSP 21262 with the ADSP 21262 processor __ADSP21266__ Present when running easm2 proc ADSP 21266 with the ADSP 21266 processor __ADSP21267__ Present when running easm2 proc ADSP 21267 with the ADSP 21267 processor 2136x Present when useed with the ADSP 2136x processors __ADSP21362__ Present when running easm21K proc ADSP 21362 with the ADSP 21362 processors __ADSP21363__ Present when running easm2 proc ADSP 21363 with the ADSP 21363 processor __ADSP21364__ Present when running easm2 proc ADSP 21364 with the ADSP 21364 processor __ADSP21365__ Present when running easm2 proc ADSP 21365 with the ADSP 21365 processor __ADSP21366__ Present when running easm2 proc ADSP 21366 with the ADSP 21366 processor __ADSP21367__ Present when running easm2 proc ADSP 21367 with the ADSP 21367 processor __ADSP21368__ Present when running easm2 proc ADSP 21368 with the ADSP 21368 processor __ADSP21369__ Present when running easm2 proc ADSP 21369 with the ADSP 21369 processor __ADSP2137x__ Present when running easm21K proc ADSP 2137x with the ADSP 2137x processor VisualDSP 5 0 Assem
5. PAGEWIDTH on page 1 109 Defines the length of a listing page Defines the width of a listing page PORT on page 1 111 Legacy directive Declares a memory mapped I O port NOTE SHARC processors only PRECISION on page 1 112 Defines the number of significant bits in a floating point value NOTE SHARC processors only PREVIOUS on page 1 114 Reverts to a previously described SECTION PRIORITY on page 1 115 Allows prioritized symbol mapping in the linker REFERENCE on page 1 118 Provides better information in an X REF file Refer to REFERENCE Provide Better Info in an X REF File on page 1 118 for more information NOTE Blackfin processors only RETAIN_NAME on page 1 118 Stops the linker from eliminating a symbol ROUND_NEAREST on page 1 119 Specifies the Round to Nearest mode NOTE SHARC processors only ROUND_MINUS on page 1 119 Specifies the Round to Negative Infinity mode NOTE SHARC processors only 1 70 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 17 Assembler Directive Summary Cont d Directive Description ROUND_PLUS Specifies the Round to Positive Infinity mode on page 1 119 NOTE SHARC processors only ROUND_ZERO Specifies the Round to Zero mode on page 1 119 NOTE SHARC processors only SECTION Marks the beginning of a section on
6. JELS Conditional assembly directive on page 1 60 ENDIF Conditional assembly directive on page 1 60 ENDSEG Legacy directive Marks the end of a section on page 1 128 Used with legacy directive SEGMENT that begins a section NOTE SHARC processors only EXTERN Allows reference to a global symbol on page 1 81 EXTERN STRUCT Allows reference to a global symbol struct that was defined on page 1 83 in another file FILE Overrides filename given on the command line used by C on page 1 85 compiler FILE_ATTR Creates a attribute in the generated object file on page 1 86 FORCECOMPRESS Compresses the next instruction on page 1 87 NOTE ADSP 2146x SHARC processors only GLOBAL Changes a symbol s scope from local to global on page 1 88 GLOBL Equivalent to GLOBAL Refer to GLOBAL Make a Symbol Available Globally on page 1 88 NOTE Blackfin processors only IF Conditional assembly directive on page 1 60 1 68 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 17 Assembler Directive Summary Cont d Directive Description IMPORT on page 1 90 Provides the assembler with the structure layout C struct information INC BINARY on page 1 92 Includes the content of file at the current location INCBIN LEFTMARGIN on page 1 93 Equivalent to INC BINARY Refer to INC BI
7. The assembly source file may contain preprocessor commands such as tinclude that cause the preprocessor to include header files h into the source program The preprocessor s only output an intermediate source file is is the assembler s primary input In normal operation the preprocessor output is a temporary file that is deleted during the assembly process VisualDSP 5 0 Assembler and Preprocessor Manual 1 5 Assembler Guide Program Content Assembly source file statements include assembly instructions assembler directives and preprocessor commands Assembly Instructions Instructions adhere to the processor s instruction set syntax which is documented in the processor s Programming Reference Each instruction line must be terminated by a semicolon On TigerSHARC processors each instruction line which can contain up to 4 instructions is termi nated by an additional semicolon Figure 1 2 on page 1 8 shows an example assembly source file To mark the location of an instruction place an address label at the begin ning of an instruction line or on the preceding line End the label with a colon before beginning the instruction Your program can then refer to this memory location using the label instead of an address The assembler places no restriction on the number of characters in a label Labels are case sensitive The assembler treats outer and Outer as unique labels For exam
8. 1 76 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler BYTE Declare a Byte Data Variable or Buffer Used with Blackfin processors only The BYTE BYTE2 and BYTE4 directives declare and optionally initialize one two and four byte data objects respectively Note that the BYTE4 directive performs the same function as the VAR directive Syntax When declaring and or initializing memory variables or buffer elements use one of these forms BYTE varNameil varName2 BYTE initExpressionl initExpression BYTE varNamel initExpression varName2 initExpression2 BYTE bufferNamel initExpressionl initExpression BYTE bufferNamel fileName BYTE bufferName length fileName BYTE bufferName length initExpressionl initExpression2 where varName user defined symbols that name variables bufferName user defined symbols that name buffers fileName indicates that the elements of a buffer get their initial values from the fileName data file The lt fileName gt parameter can consist of the actual name and path specification for the data file If the initialization file is in current directory of your operating system only the fileName need be given inside double quote characters Note that when reading in a data file the assembler reads in whitespace separated lists of decimal digits or hex strings VisualDSP 5 0 Assembler and Prepro
9. DATA64 64 bit word section qualifier 1 125 DATA assembler directive 1 68 __ DATE __ macro 2 16 dat files 1 3 1 143 D define macro assembler switch 1 152 1 155 preprocessor switch 2 50 debugging generate information 1 156 macros 2 14 debugging macros 2 13 default branch np assembler switch 1 151 default branch p assembler switch 1 152 define macro preprocessor command 2 9 2 24 dependencies from buffer initialization 1 33 directives list assembler 1 67 D_LANGUAGE_C macro 1 31 dlb files 1 4 DMAONLY section qualifier 1 125 DM data 40 bit word section qualifier 1 125 doj files 1 3 DOUBLE32 64 ANY section qualifiers 1 123 double size 32 assembler switch 1 152 double size 64 assembler switch 1 153 double size any assembler switch 1 153 DWARE2 function information 1 156 E easm21k assembler driver 1 2 easmblkfn assembler driver 1 2 easmts assembler driver 1 2 ELF h header file 1 123 ELF section types 1 123 ELIF conditional assembly directive 1 60 VisualDSP 5 0 Assembler and Preprocessor Manual 1 5 INDEX elif else if preprocessor command 2 27 else alternate instruction preprocessor command 2 28 ELSE conditional assembly directive 1 60 ENDIF conditional assembly directive 1 60 endif termination preprocessor command 2 29 end labels marking ending function boundaries 1 35 missing 1 157 end of a function 1 157 ENDSEG assembler
10. D__ADSPBF536__ Present when running easm fn proc ADSP BF536 with the ADSP BF536 processor D__ADSPBF537__ Present when running easmblkfn proc ADSP BF537 with the ADSP BF537 processor D__ADSPBF538__ Present when running easmblkfn proc ADSP BF538 with the ADSP BF538 processor D__ADSPBF539__ Present when running easmblkfn proc ADSP BF539 with the ADSP BF539 processor D__ADSPBF542__ Present when running easm fn proc ADSP BF542 with the ADSP BF542 processor D__ADSPBF544__ Present when running easmblkfn proc ADSP BF544 with the ADSP BF544 processor D__ADSPBF547__ Present when running easmblkfn proc ADSP BF547 with the ADSP BF547processor D__ADSPBF548__ Present when running easmblkfn proc ADSP BF548 with the ADSP BF548 processor VisualDSP 5 0 Assembler and Preprocessor Manual 1 27 Assembler Guide Table 1 5 Feature Macros for Blackfin Processors Cont d D__ADSPBF549__ 1 Present when running easmblkfn proc ADSP BF549 with the ADSP BF549 processor D__ADSPBF561__ 1 Present when running easmblkfn proc ADSP BF561 with the ADSP BF561 processor Table 1 6 Feature Macros for SHARC Processors D_LANGUAGE_ASM Always present D__ADSP21000__ Always present D__ADSP21020_ Present when running easm2 proc ADSP 21020 D__2102x__ with the ADSP 21020 processors D__ADSP21060__ Present when ru
11. FILE_ATTR at101 a123 at102 at103 999 1 86 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler FORCECOMPRESS Compress the Next Instruction NOTE Used with the ADSP 2146x SHARC processors only The FORCECOMPRESS directive causes the next instruction to be com pressed if possible The directive has effect on sections that are assembled as short word The directive overrides the effect of a previous NOCOMPRESS directive on page 1 107 for one instruction Only the immediately fol lowing assembly instruction is affected by FORCECOMPRESS while COMPRESS on page 1 81 starts a sequence of COMPRESS instructions and NOCOMPRESS FORCECOMPRESS can override certain conservative assumptions normally made by the assembler such as when an immediate value is an expression containing a symbol In this case the assembler normally does not gener ate a compressed instruction because the ultimate value of the symbolic expression may not fit in the immediate field of the compressed instruction FORCECOMPRESS is advisory only e There is no guarantee that a particular instruction will be compressed e An instruction can be uncompressed if it is near the end of a DO loop e Whether a particular instruction is compressed can change due to assembler enhancements or bug fixes e There are no warnings if an instruction cannot be compressed Therefore it is not recommended to create code layouts
12. No space is allowed between i and the path name These files are e Header files h included with the include preprocessor command e Data initialization files dat specified with the VAR assembly directive 1 158 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler The assembler passes this information to the preprocessor the preprocessor searches for included files in the following order 1 Directory for assembly program 2 include subdirectory of the VisualDSP installation directory 3 Specified directory or list of directories The order of the list defines the order of multiple searches The current directory is the directory where the assembly service is not the directory of the project Usage of full path names for the 1 switch on the command line is recommended For example easm21K proc ADSP 21161 I bin include file asm I filename The 1 filename listing switch directs the assembler to generate the named listing file Each listing file 1st shows the relationship between your source code and instruction opcodes that the assembler produces For example easmblkfn proc ADSP BF533 I path I 1 file lst file asm The file name is a required argument to the 1 switch For more information see Reading a Listing File on page 1 34 li filename The 1i listing switch directs the assembler to generate the named listing file with include files The file name is a requ
13. OBJECTS COMMAND _LINE_OBJECTS Internal memory blocks are 0x10000 64k MEMORY VisualDSP 5 0 Assembler and Preprocessor Manual 1 13 Assembler Guide Data Section eB SECTION data1 Assembler Directive VAR buffert 0x100 buffer dat Data Section gt SECTION data2 VAR buffer2 Code Section _ SECTION program Assembler Label start Preprocessor Commands __ ifdef XRO_SET_TO 2 for Conditional Assembly xRO 0x2 else xRO 0x1 endif Assembly Instructions i buffer1 JL1 0 i LCO 0x100 this loop J J2 XRO IF NLCOE JUMP this_loop Figure 1 3 Assembly Code File Structure for Tigers HARC Processors OCode TYPECRAM START Ox00000000 END OXOOOOFFFF WIDTH 32 1Data TYPECRAM START 0x00080000 END OxOO08BFFF WIDTH 32 1Heap TYPECRAM START Ox0008C000 END Ox0008C7FF WIDTH 32 1Stack TYPECRAM START 0x0008C800 END OXOOO8FFFF WIDTH 32 2Data TYPECRAM START 0x00100000 END OXxOO1OBFFF WIDTH 32 2Stack TYPECRAM START Ox0010C000 END OXOO1OFFFF WIDTH 32 SDRAM TYPECRAM START 0x04000000 END OxXO7FFFFFF WIDTH 32 1 14 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler MSO TYPECRAM START 0x08000000 END OXOBFFFFFF WIDTH 32 MS1 TYPECRAM START Ox0C00000
14. Outputs the named listing file with include files expanded Generates make dependencies for include and data files only does not assemble For example M suppresses the creation of an object file MM on page 1 160 Generates make dependencies for include and data files Use MM for make dependencies with assembly Mo filename on page 1 161 Mt filename on page 1 161 Writes make dependencies to the fi 1ename specified The Mo option is for use with either the M or MM option If Mo is not present the default is lt stdout gt dis play Specifies the make dependencies target name The Mt option is for use with either the M or MM option If Mt is not present the default is base name plus DOJ micaswarn on page 1 161 Treats multi issue conflicts as warnings NOTE Blackfin processors only no anomaly detect id1l id2 Sel on page 1 162 Does not issue a warning or an error for an anomaly id no anomal y workaround idlL id2 se on page 1 162 Does not implement a workaround for an anomaly id no expand symbolic links on page 1 162 Disables support for Cygwin style paths 1 146 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 25 Assembler Command Line Switch Summary Contd Switch Name Purpose no expand windows shortcuts Disables support for Windows shortcuts on page 1 163 no t
15. U stackseg ldf_stack_space ldf_stack_length 0x2000 gt seg_stak section placement for default heap heap ldf_heap_space ldf_heap_end ldf_heap_space 0x2000 ldf_heap_length ldf_heap_end ldf_heap_space gt seg_heap section placement for additional custom heap 1 12 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler heaq ldf_heaq_space ldf_heag_end ldf_heagq_space 0x2000 ldf_heag_length ldf_heag_end ldf_heaq_space gt seg_heaq End SECTIONS End PO Code File Structure for TigerSHARC Processors Figure 1 3 describes assembly code file structure for TigerSsHARC processors Looking at Figure 1 3 notice that an assembly source may contain preprocessor commands such as Finclude to include other files in source code ifdef for conditional assembly or define to define macros Assembler directives such as VAR appear within sections to declare and initialize variables LDF for TigerSHARC Processors Listing 1 2 shows a sample user defined 1df file for TigerSHARC processors Looking at the file s SECTIONS command notice that the INPUT_SECTION commands map to the names of memory sections such as program datal data2 ctor heaptab and so on used in the example assembly sample program Listing 1 2 Example Linker Description File for Tigers HARC Processors ARCHITECTURE ADSP TS101 SEARCH_DIR ADI_DSP TS 1lib
16. Writing Assembly Programs on page 1 4 e Using Assembler Support for C Structs on page 1 21 e Preprocessing a Program on page 1 24 e Using Assembler Feature Macros on page 1 25 e Generating Make Dependencies on page 1 33 e Reading a Listing File on page 1 34 1 2 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler e Enabling Statistical Profiling for Assembly Functions on page 1 35 e Specifying Assembler Options in VisualDSP on page 1 170 For information about a processor s architecture including the instruction set used when writing assembly programs refer to the Hardware Reference and the Programming Reference for the appropriate processor Assembler Overview The assembler processes data from assembly source asm data dat and header h files to generate object files in executable and linkable format ELF an industry standard format for binary object files The object file has a doj extension In addition to the object file the assembler can produce a listing file 1st that shows the correspondence between the binary code and the source Assembler switches are specified from the VisualDSP IDDE or from the command line used to invoke the assembler These switches allow you to control the assembly process of source data and header files Use these switches to enable and configure assembly features such as search paths output file names and macro
17. 4 1 used the SEGMENT and ENDSEG directives to define the beginning and end of a section of contiguous memory addresses Although these directives have been replaced with the SECTION directive source code written with SEGMENT ENDSEG legacy directives is accepted by the ADSP 21xxx assembler SEPARATE_MEM_SEGMENTS Used with TigerSHARC processors only The SEPARATE_MEM_SEGMENTS directive allows you to specify two buffers the linker should try to place into different memory segments Syntax SECTION datal VAR bufl VAR buf2 EXTERN buf3 SEPARATE_MEM_SEGMENTS bufl buf2 SEPARATE_MEM_SEGMENTS bufl buf3 You can also use the compiler s separate_mem_segments pragma to perform the same function For more information refer to your processor s VisualDSP 5 0 C C Compiler and Library Manual 1 128 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler SET Seta Symbolic Alias The SET directive is used to alias one symbol for another Syntax SET symboll symbol2 where symbol1 becomes an alias to symbol2 Example SET symboll symboll SHORT Defines and initializes 2 byte data objects Used with Blackfin processors only The SHORT directive declares and optionally initializes two byte data objects It is effectively equivalent to BYTE2 initExpressionl initExpression2 For more information see BYTE Declare a Byte Data Variable or Buffer on page 1 77 Syntax When
18. 5 0 Assembler and Preprocessor Manual 1 131 Assembler Syntax Reference If data member names are present the assembler validates that the assembler and compiler are in agreement about these names The initial ization of data struct members declared via the assembly STRUCT directive is processor specific Example 1 Long Form STRUCT Directive define NTSC 1 contains layouts for playback and capture_hdr IMPORT comdat h STRUCT capture_hdr myLastCapture captureInt 0 captureString InitialState bs STRUCT myPlayback playback theSize 0 ready 1 stat_debug 0 last_capture myLastCapture watchdog 0 vidtype NTSC bs Example 2 Short Form STRUCT Directive define NTSC 1 contains layouts for playback and capture_hdr IMPORT comdat h STRUCT capture_hdr myLastCapture 0 InitialState STRUCT playback myPlayback 0 1 0 myLastCapture 0 NTSC Example 3 Long Form STRUCT Directive to Initialize an Array STRUCT structWithArrays XXX scalar 5 arrayl 1 2 3 4 5 array2 filel dat 1 132 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler array3 WithBraces dat must have within dat bs In the short form nested braces can be used to perform partial initializa tions as in C In Example 4 below if the second member of the struct is an array with more than four elements the remaining elements is init
19. Command Operator Description define on page 2 24 Defines a macro elif on page 2 27 Subdivides an if endif pair else on page 2 28 Identifies alternative instructions within an if endif pair endif on page 2 29 Ends an if endif pair error on page 2 30 Reports an error message if on page 2 31 Begins an if endif pair re Fi fdef on page 2 32 Begins an ifdef endif pair and tests if macro is defined ifndef on page 2 33 Begins an ifndef Fendif pair and tests if macro is not defined include on page 2 34 Includes contents of a file re Fl ine on page 2 36 Sets a line number during preprocessing fpragma on page 2 37 Takes any sequence of tokens Fundef on page 2 38 Removes macro definition Fwarning on page 2 39 Reports a warning message Table 2 6 Preprocessor Operator Summary Command Operator Description dF on page 2 40 Converts a macro argument into a string constant By default this operator is OFF Use the command line switch stringize to enable it JHF on page 2 42 Concatenates two tokens on page 2 43 Generates unique labels for repeated macro expansions on page 2 25 Specifies a variable length argument list VisualDSP 5 0 Assembler and Preprocessor Manual 2 23 Preprocessor Command
20. RO DM I0 MO R1 PM I8 M8 R2 FIX F1 BY RO this_loop C R3 R3 R2 DM rad R3 Preprocessor Commands gt ifdef duplicate_write for Conditional Assembly DM rad R3 endif function1 end Assembler Label Figure 1 2 Assembly Code File Structure for SHARC Processors seg_pmda TYPE DM RA START Ox28000 END 0x28fff WIDTH 32 seg_dmda TYPE DM RA START 0x29000 END 0x29fff WIDTH 32 seg_stak TYPE DM RA START Ox2e000 END Ox2f fff WIDTH 32 memory declarations for default heap seg_heap TYPE DM RA START Ox2a000 END Ox2bfff WIDTH 32 memory declarations for custom heap seg_heaqtTYPE DM RA START Ox2c000 END Ox2dfff WIDTH 32 End MEMORY VisualDSP 5 0 Assembler and Preprocessor Manual 1 11 Assembler Guide PROCESSOR pO LINK_AGAINST COMMAND_LINE_LINK_AGAINST OUTPUT COMMAND_LINE_OUTPUT_FILE SECTIONS seg_rth INPUT_SECTIONS 0BJECTS seg_rth LIBRARIES seg_rth gt seg_rth seg_init INPUT_SECTIONS 0BJECTS seg_init LIBRARIES seg_init gt seg_init seg_pmco INPUT_SECTIONS OBJECTS seg_pmco LIBRARIES seg_pmco gt seg_pmco U seg_pmda INPUT_SECTIONS OBJECTS seg_pmda LIBRARIES seg_pmda gt seg_pmda seg_dmda INPUT_SECTIONS 0BJECTS seg_dmda LIBRARIES seg_dmda gt seg_dmda
21. Returns 4 VisualDSP 5 0 Assembler and Preprocessor Manual 1 135 Assembler Syntax Reference Syntax The VAR directive takes one of the following forms VAR varNamel varName2 VAR 7nitExpressionl initExpression2 VAR bufferNameL initExpressionl initExpression VAR bufferNamelL fileName VAR bufferName length fileName VAR bufferNamel length initExpressionl initExpression m where varName user defined symbols that identify variables buf ferName user defined symbols that identify buffers fileName parameter indicates that the elements of a buffer get their initial values from the fileName data file The fileName can consist of the actual name and path specification for the data file If the initialization file is in the current directory of your operating system only the fileName need be given quotes Note that when reading in a data file the assembler reads in whitespace separated lists of decimal digits or hex strings Initialization from files is useful for loading buffers with data such as filter coefficients or FFT phase rotation factors that are generated by other programs The assembler determines how the values are stored in memory when it reads the data files Ellipsis a comma delimited list of parameters Jength optional parameter that defines the length in words of the associated buffer When length is not provided the buffer s
22. units are in bytes SIZEOF Built In Function The SIZEOF built in function returns the amount of storage associated with an imported C struct or data member It provides functionality similar to its C counterpart SIZEOF struct typedef C_base_type where The SIZEOF function takes a symbolic reference as its single argument A symbolic reference is a name followed by none or several qualifiers to members VisualDSP 5 0 Assembler and Preprocessor Manual 1 63 Assembler Syntax Reference The SIZEOF function gives the amount of storage associated with e An aggregate type structure e AC base type int char and so on e A member of a structure any type For example Blackfin processor code IMPORT Celebrity h EXTERN STRUCT Celebrity StNick L3 SIZEOF Celebrity typedef L3 SIZEOF StNick struct var of typedef Celebrity L3 SIZEOF char C built in type L3 SIZEOF StNick gt Town member of a struct var L3 SIZEOF Celebrity gt Town member of a struct typedef The SIZEOF built in function returns the size in the units appro priate for its processor For SHARC and TigerSHARC processors units are in words For Blackfin processors units are in bytes When applied to a structure type or variable SIZEOF returns the actual size which may include padding bytes inserted for alignment When applied to a statically dimensioned array SIZEOF returns the size
23. LIST_LOCTAB directives The default tab width is inherited by nested source files but the local tab width only affects the current source file Syntax LIST_LOCTAB expression where expression evaluates to an integer greater than or equal to 0 A value of 0 sets the local tab width to the current setting of the default tab width In the absence of a LIST_LOCTAB directive the local tab width defaults to the current setting for the default tab width Example See the LIST_DEFTAB example on page 1 97 VisualDSP 5 0 Assembler and Preprocessor Manual 1 99 Assembler Syntax Reference LIST WRAPDATA NOLIST WRAPDATA The LIST_WRAPDATA NOLIST_WRAPDATA directives control the listing of opcodes that are too big to fit in the opcode column By default the NOLIST_WRAPDATA directive is in effect This directive pair applies to any opcode that does not fit but in practice such a value almost always is the data alignment directives can also result in large opcodes e If LIST_WRAPDATA is in effect the opcode value is wrapped so that it fits in the opcode column resulting in multiple listing lines e If NOLIST_WRAPDATA is in effect the printout is what fits in the opcode column Nested source files inherit the current setting of this directive pair but a change to the setting made in a nested source file does not affect the parent source file The LIST_WRAPDATA NOLIST_WRAPDATA directives do not take any
24. NOLIST_DATFILE NOLIST WRAPDATA NEWPAGE PAGELENGTH PAGEWIDTH PREVIOUS SECTION _SEPARATE_MEM_SEGMENTS Sei SECTION VAR EA ABS ACS ADDRESS AND ASHIFT BCLR BFOINC BFOTMP BITEST BITFIFO BKFPT BR BSET BTBDIS BTBELOCK BTBEN BTBLOCK BTBINV BTGL BY c CALL cB COMP CJMP_CALL CI CLIP COMP COMPACT COPYSIGN 1 44 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 11 TigerSHARC Processor Assembler Keywords Cont d DAB DEC DESPREAD DO ELSE EMUT RAP EXP EXPAND EXTD FCOMP FDEP FEXT FIX FLOAT FTESTO FTEST1 FOR GETBITS DLE INC JC JUMP KC LDO LD1 LENGTH LINES LOGB LP LSHIFT LSHIFTR LIBSIM_CALL ANT ASK AX ERGE IN EWPAGE OT OP P OFFSETOF ONES OR PASS PERMUTE PRECISION PUTBITS RDS RECIPS RESET RETI ROT ROTL ROTR ROUND RSQRTS RTI SCALB SDAB SE SECTION SFO SF SNGL SIZE SIZEOF STRUCT SUM TMAX TRAP TYPEVAR UNTIL VMIN VMAX XCORRS XOR XSDAB YDAB YSDAB JK Register Group JO through J31 0 through K31 JBO JB1 JB2 JB3 BO KB1 KB2 KB3 JLO JL1 JL2 JL3 LO KLI KL2 KL3 RF Register Group FRO through FR31 VisualDSP 5 0 Assembler and Preprocessor Manual 1 45 Assembler Syntax Reference Table 1 11 TigerSsHARC Processor Assembler Keywords Cont d
25. The closer to zero value is taken The number is truncated after the third decimal digit LSB 1 2581 rounds to 1 258 8 5996 rounds to 8 599 5 3298 rounds to 5 329 6 4974 rounds to 6 497 ROUND_PLUS Selects Round to Positive Infinity The number rounds to the next larger For positive numbers a 1 is added to the third decimal digit the least significant bit Then the result is truncated after the LSB For negative numbers the mantissa is truncated after the third decimal digit LSB 1 2581 rounds to 1 259 8 5996 rounds to 8 600 5 3298 rounds to 5 329 1 120 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler 6 4974 rounds to 6 497 xj ROUND_MINUS Selects Round to Negative Infinity The value rounds to the next smaller For negative numbers a 1 is subtracted from the third decimal digit the least significant bit Then the result is truncated after the LSB For positive numbers the mantissa is truncated after the t 1 2581 round 8 5996 round 5 3298 rou 6 4974 rou ird decimal digit LSB s to 1 258 s to 8 599 ds to 5 330 ds to 6 498 VisualDSP 5 0 Assembler and Preprocessor Manual 1 121 Assembler Syntax Reference SECTION Declare a Memory Section The SECTION directive marks the beginning of a logical section mirroring an array of contiguous locations in your processor memory Statements between one SECTION directive and the followin
26. and data It also organizes the instructions and data to allow the use of the linker descrip tion file 1df to describe how code and data are mapped into the memory on your target processor The way you structure your code and data into memory should follow the memory architecture of the target processor VisualDSP 5 0 Assembler and Preprocessor Manual 1 7 Assembler Guide Use the SECTION directive to organize the code and data in assembly source files The SECTION directive defines a grouping of instructions and data that occupies contiguous memory addresses in the processor The name given in a SECTION directive corresponds to an input section name in the linker description file Table 1 1 Table 1 2 and Table 1 3 show suggested input section names for data and code that can be used in your assembly source for various processors Using these predefined names in your sources makes it easier to take advantage of the default 1df file included in your DSP system However you may also define your own sections For information on 1df files refer to the VisualDSP 5 0 Linker and Utilities Manual Table 1 1 Suggested Input Section Names for a SHARC ldf File SECTION Name Description seg_pmco A section in program memory that holds code seg_dmda A section in data memory that holds data seg_pmda A section in program memory that holds data seg_rth A section in program memory that holds system initialization co
27. assembly files 2 22 command syntax 1 7 2 3 2 22 2 45 cpredef C style switch 2 48 csall all comment styles switch 2 50 cs comment style switch 2 49 cs comment style switch 2 50 cs comment style switch 2 50 cs switch 2 49 D define macro switch 2 50 feature macros 2 15 h help switch 2 50 i include directory switch 2 51 i less includes switch 2 51 I search system include files switch 2 52 M make rule only switch 2 53 MM make rule and assemble switch 2 53 Mo output make rule switch 2 53 Mt output make rule for named file switch 2 54 notokenize dot switch 2 54 nowarn switch 2 56 o output switch 2 54 output file is extension 1 5 running from command line 2 45 setting options 2 21 source files 2 22 stringize switch 2 54 system header files 2 34 tokenize dot switch 2 54 Uname switch 2 55 user header files 2 34 version display version switch 2 55 v verbose switch 2 55 warn print warnings switch 2 56 Wnumber warning suppression switch 2 56 w skip warning messages switch 2 55 INDEX preprocessor commands define 2 24 elif 2 27 else 2 28 endif 2 29 error 2 30 if 2 31 ifdef 2 32 ifndef 2 33 include 2 34 line counter 2 36 pragma 2 37 undef 2 38 warning 2 39 preprocessor macros common macros 2 16 for Blackfin processors 2 16 for
28. for naming symbols See Assembler Keywords and Symbols on page 1 38 for more information on naming conventions flags compiler The flags compiler optl opt2 switch passes each comma separated option to the C compiler The switch takes a list of one or more comma separated compiler options that are passed on the com piler command line for compiling IMPORT headers The assembler calls the compiler to process each header file in an IMPORT directive It calls the compiler with the debug types option along with any flags compiler switches given on the assembler command line For example file asm has IMPORT myHeader h easmbkIn proc ADSP BF535 flags compiler I Path I file asm The rest of the assembly program including its include files are processed by the assembler preprocessor The flags compiler switch processes a list of one or more valid C compiler options including the D and I options 1 154 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler User Specified Defines Options D defines options in an assembler command line are passed to the assembler preprocessor but they are not passed to the compiler for IMPORT header processing If defines are used for IMPORT header compilation they must be explicitly specified with the flags compiler switch For example file asm has IMPORT myHeader h easmblkfn proc ADSP BF535 DaDef flags compiler DbDef DbDefTwo 2 f
29. laclade Fath PEE sicietcotenatancireeaeenemmnndadn 2 7 WHINE MACIOS iciiaiininin inne nneiniess 2 7 Macro Definition and Usage Guidelines iiccscunnscrdegcessnseasosns 2 9 Examples of Multi Line Code Macros with Arguments 2 12 Debugeing Macros daw ia cacisnstaieiidiaiedeaeaamubeiinliaiteniaaadedeiass 2 13 Using Predefined Preprocessor Macros ssincccctssreenceteereteisiciers 2 15 D__VISUALDSPVERSION_____ Predefined Macro Preprocessor 2 21 Specifying Preprocessor OptdNS scviiensisvisclieensivieiapiatanevn iis 2 21 Preprocessor Command Rerterence iaanccisanccstenticatucieisaaesstacaniasniaden 2 22 Preprocessor Commands and Operators cisccciscociwiensererrercenites 2 22 a TN E E nis 2 24 Vatiable Length Argument Definitions sis cancciicscsvcascensssces 2 25 L gape te nnn ene RCE nie ite er U RENE Mere een De Tce nme Se ADR eT ewe 2 27 a E E AT A A T 2 28 x VisualDSP 5 0 Assembler and Preprocessor Manual CONTENTS TONG nanena 2 29 PERRO E E E 2 30 2 E E A A A 2 31 E r r r Geen ener 2 32 Filadelf onisteorieinbuiiani n ai eiaa 2 33 E E E AE E E 2 34 E E E S 2 36 FIA E E E 2 37 CN sisi teen Ge E a E T 2 38 a E A E T EE 2 39 E A E E E E T meee 2 40 Ta Concaenate oer N 2 47 7 Generire a umigue Kbel ccncsncnisamieninancnens 2 43 Preprocessor Command Line Reference ccicarccusenurcnuneniancs 2 45 Rumning the Preprocessor ssinorerrriisieia etiain 2 45 Preprocessor Command Line Switches sccsesseacesccessenessnrseeyancacs 2 46 pp
30. macro formal parameter to convert into a literal string The operator must precede a macro parameter The preprocessor includes a converted string within double quotation marks This feature is off by default Use the stringize command line switch to enable it C Code Example define WARN_IF EXP fprintf stderr Warning EXP n Defines a macro that takes an argument and converts the argument to a string WARN_IF current lt minimum Invokes the macro passing the condition fprintf stderr Warning current lt minimum n 2 40 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor Note that the EXP has been changed to current lt minimum and is enclosed in VisualDSP 5 0 Assembler and Preprocessor Manual 2 41 Preprocessor Command Reference H Concatenate The concatenate operator directs the preprocessor to concatenate two tokens When you define a macro you request concatenation with HF in the macro body The preprocessor concatenates the syntactic tokens on either side of the concatenation operator Syntax tokenlitftoken2 Example define varstring name VAR var_d nameL name varstring error varstring warning The above code results in VAR var_error error 0 VAR var_warningL warning 0 2 42 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor Generate a uniq
31. qualifier immediately follows the directive and is separated by a slash arguments follow qualifiers Assembler directives can be uppercase or lowercase uppercase distinguishes directives from other symbols in your source code Table 1 17 lists all currently supported assembler directives A description of each directive appears in the following sections These directives were added for GNU compatibility Table 1 17 Assembler Directive Summary Directive Description ALIGN Specifies an alignment requirement for data or code on page 1 72 ALIGN_CODE Specifies an alignment requirement for code on page 1 74 NOTE TigerSHARC processors only ASCII Initializes ASCII strings on page 1 76 NOTE Blackfin processors only BSS Equivalent to SECTION zero_init bsz Refer to SECTION Declare a Memory Section on page 1 122 NOTE Blackfin processors only BYTE Defines and initializes one two and four byte data objects BYTE2 respectively BYTE4 NOTE Blackfin processors only on page 1 77 VisualDSP 5 0 Assembler and Preprocessor Manual 1 67 Assembler Syntax Reference Table 1 17 Assembler Directive Summary Cont d Directive Description COMPRESS Starts compression on page 1 81 NOTE ADSP 2146x SHARC processors only DATA Equivalent to SECTION datal Refer to SECTION Declare a Memory Section on page 1 122 NOTE Blackfin processors only
32. tables with fixed size entries that depend on particular instructions being compressed Syntax FORCECOMPRESS VisualDSP 5 0 Assembler and Preprocessor Manual 1 87 Assembler Syntax Reference GLOBAL Make a Symbol Available Globally The GLOBAL directive changes the scope of a symbol from local to global making the symbol available for reference in object files that are linked to the current one By default a symbol has local binding meaning the linker can resolve references to it only from the local file that is the same file in which it is defined It is visible only in the file in which it is declared Local symbols in different files can have the same name and the linker considers them to be independent entities Global symbols are visible from other files all references from other files to an external symbol by the same name will resolve to the same address and value corresponding to the single global definition of the symbol You change the default scope with the GLOBAL directive Once the symbol is declared global other files may refer to it with EXTERN For more infor mation refer to the EXTERN directive on page 1 81 Note that GLOBAL or WEAK scope is required for symbols that appear in RESOLVE commands in the 1df file Syntax GLOBAL symbo NameiL symbol Name2 where symbo1Name the name of a global symbol A single GLOBAL directive may define the global scope of any number of
33. 03r declare and initialize an implicit length buffer 1 78 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler and initialize it with three 4 byte fract constants BYTE2 Ins Outs Remains declare three 2 byte variables zero initialized by default BYTE4 demo_codes 100 inits dat declare a 100 location buffer and initialize it with the contents of the inits dat file BYTE2 taps 100 declare a 2 byte variable and initialize it to 100 BYTE twiddles 10 phase dat declare a 10 location buffer and load the buffer with contents of the phase dat file BYTE4 R32 Fract_Byte4_R32 fr32FormatFract dat When declaring or initializing variables with 8YTE consider constraints applied to the VAR directive The VAR directive allocates and optionally initializes 32 bit data objects For information about the VAR directive refer to information on page 1 135 ASCII Sting Initialization Support The assembler supports ASCII string initialization This allows the full use of the ASCII character set including digits and special characters In Blackfin processors ASCII initialization can be provided with BYTE BYTE2 or VAR directives The most likely use is the 8YTE directive where each char is represented by one byte versus a VAR directive in which each char needs four bytes The characters are stored in the upper byte of 32 bit words The LSBs are cleared String initializa
34. 1 60 DATA 1 68 EXTERN 1 82 EXTERN STRUCT 1 83 FILE_ATTR 1 86 FILE override filename 1 85 FORCECOMPRESS 1 87 GLOBAL 1 88 GLOBL 1 68 IMPORT 1 90 INCBIN 1 69 INC BINARY 1 92 LEFTMARGIN 1 93 LIST 1 94 LIST_DATA 1 95 LIST_DATFILE 1 96 LIST_DEFTAB 1 97 LIST_LOCTAB 1 99 LIST_WRAPDATA 1 100 LONG 1 101 MESSAGE 1 102 NEWPAGE 1 106 1 118 NOCOMPRESS 1 107 NOLIST 1 94 NOLIST_DATA 1 95 NOLIST_DATFILE 1 96 NOLIST_WRAPDATA 1 100 PAGELENGTH 1 108 PAGEWIDTH 1 109 PORT 1 111 1 118 PRECISION 1 112 1 114 PREVIOUS 1 114 PRIORITY 1 115 INDEX ROUND_MINUS 1 119 ROUND_NEAREST 1 119 ROUND_PLUS 1 119 ROUND_ZERO 1 119 SECTION 1 122 SEGMENT ENDSEG 1 128 SEPARATE_MEM_SEGMENTS 1 128 1 129 SET 1 71 SHORT 1 129 SHORT EXPRESSION LIST 1 71 STRUCT 1 130 TEXT 1 71 TYPE 1 134 VAR 1 135 WEAK 1 140 VisualDSP 5 0 Assembler and Preprocessor Manual I 3 INDEX assembler switches align branch lines 1 149 anomaly detect 1 149 1 162 anomaly warn 1 149 anomaly workaround 1 150 char size 32 1 151 char size 8 1 151 char size any 1 151 D define macro 1 152 1 155 default branch np 1 151 default branch p 1 152 double size 32 1 152 double size 64 1 153 double size any 1 153 expand symbolic links 1 153 expand windows shortcuts 1 154 flags compiler 1 154 flags pp 1 156 g genera
35. L LO _StNick gt isSeniorCitizen P3 H HI _StNick gt isSeniorCitizen 1 84 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler FILE Ovenide the Name ofa Source File The FILE directive overrides the name of the source file This directive may appear in the C C compiler generated assembly source file s The FILE directive is used to ensure that the debugger has the correct file name for the source file that had generated the object file Syntax FILE filename ext where filename the name of the source file to associate with the object file The argument is enclosed in double quotes VisualDSP 5 0 Assembler and Preprocessor Manual 1 85 Assembler Syntax Reference FILE_ATIR Create an Attribute in the Object File The FILE_ATTR directive instructs the assembler to place an attribute in the object file which can be referenced in the 1df file when linking See the VisualDSP 5 0 Linker and Utilities Manual for more information Syntax FILE_ATTR attrNamel attrVall attrName2 attrVal2 where attrName the name of the attribute Attribute names must follow the same rules for naming symbols attrVal sets the attribute to this value If omitted 1 is used The value must be double quoted unless it follows the rules for naming symbols as described in Assembler Keywords and Symbols on page 1 38 Examples FILE_ATTR atl FILE_ATTR at10 a123
36. Load the base address of the circular buffer JB3 real_data Load the index J3 real_data Load the circular buffer length JL3 LENGTH real_data Set loop counter 0 with buffer length LCOS JESS start XRO CB J3 1 Read data from the circular buffer if NLCOE jump start 1 54 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler The code fragment above initializes JB3 and JL3 to the base address and length respectively of the real_data circular buffer The buffer length value contained in JL3 determines when addressing wraps around the top of the buffer For further information on circular buffers refer to the Hardware Reference of the target processor SHARC Processor Example The following code example determines the base address and length of the real_data circular buffer The buffer s length value contained in L5 determines when addressing wraps around to the top of the buffer when setting up circular buffers in SHARC processors For further information on circular buffers refer to the Hardware Reference of the target processor SECTION DM seg_dmda data segment VAR real_datatn n number of input samples SECTION PM seg_pmco code segment B5 real_data buffer base address 15 loads automatically L5 length real_data buffer s length M6 1 post modify I5 by 1 LCNTR length real_data DO loopend UNT
37. Reference define The define command defines macros When defining macros in your source code the preprocessor substitutes each occurrence of the macro with the defined text Defining this type of macro has the same effect as using the Find Replace feature of a text editor although it does not replace literals in double quotation marks and does not replace a match within a larger token For macro definitions longer than one line place a backslash character at the end of each line except the last line for readability refer to the macro definition rules in Writing Macros on page 2 7 You can add arguments to the macro definition The arguments are sym bols separated by commas that appear within parentheses Syntax itdefine macroSymbol replacementText i tdefine macroSymboll argl arg2 replacementText where macroSymbol macro identifying symbol replacement Text text to substitute each occurrence of macroSymbol in your source code 2 24 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor Examples i define BUFFER_SIZE 1020 Defines a macro named BUFFER_SIZE and sets its value to 1020 define copy src dest xr0 J3l sre J31 dest xr0 Define a macro named copy with two arguments The definition includes two instructions that copy a word from memory to memory For example copy 0x3F 0xC0 calls the macro passing parameters to it The preprocessor rep
38. SECTION program SHT_DEBUGINFO Supported ELF section types are SHT_PROGBITS SHT_DEBUGINFO and SHT_NULL These sectionTypes are described in the ELF h header file which is available from third party software develop ment kits For more information on the ELF file format see the VisualDSP 5 0 Linker and Utilities Manual If you select an invalid common qualifier or specify no common qualifier the assembler exits with an error message Blackfin Example Declared below memory sections correspond to the default LDF s input sections SECTION DOUBLE32 datal SECTION DOUBLE32 program DOUBLE Qualifiers memory section to store data memory section to store code The DOUBLE qualifier can be one of the following listed in Table 1 18 Table 1 18 DOUBLE Qualifiers Qualifier Description DOUBLE32 DOUBLEs are represented as 32 bit types DOUBLE64 DOUBLEs are represented as 64 bit types DOUBLEANY Section does not include code that depends on the size of DOUBLE VisualDSP 5 0 Assembler and Preprocessor Manual 1 123 Assembler Syntax Reference The DOUBLE size qualifiers are used to ensure that object files are consistent when linked together and with run time libraries A memory section may have one DOUBLE size qualifier it cannot have two DOUBLE size qualifiers Sections in the same file do not have to have the same type size qualifiers Use of DOUBLEANY in a secti
39. a struct name struct member initializers per struct member initializers 1 130 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler The curly braces are used for consistency with the C initializer syntax Initialization can be in long form or short form where data member names are not included The short form corresponds to the syntax in C compiler struct initialization with these changes e C compiler keyword struct is changed to struct by adding the period e C compiler constant string syntax MyString is changed to MyString by changing the double quotes into single quotes The long form is assembler specific and provides the following benefits e Provides better error checking e Supports self documenting code e Protects from possible future changes to the layout of the struct If an additional member is added before the member is initialized the assembler will continue to offset to the correct location for the specified initialization and zero initialize the new member Any members that are not present in a long form initialization are initialized to zero For example if struct StructThree has three members member1 member2 and member3 and STRUCT StructThree myThree member1 Oxaa member3 Oxff j member2 will be initialized to 0 because no initializer was present for it If no initializers are present the entire struct is zero initialized VisualDSP
40. an N byte value into the processor ensure that this value is aligned in memory by N boundary otherwise a hardware exception is generated VisualDSP 5 0 Assembler and Preprocessor Manual 1 137 Assembler Syntax Reference Blackfin Code Example In the following example the 4 byte variables y0 y1 and y2 would be misaligned unless the ALIGN 4 directive is placed before the VAR y0 and VAR y2 statements SECTION datal ALIGN 4 VAR XO VAR X1 BYTE BO ALIGN 4 aligns the following data item YO on a word boundary advances other data items consequently VAR YO VAR Y1 BYTE Bl ALIGN 4 aligns the following data item Y2 on a word boundary VAR Y2 VAR and ASCII String Initialization Support The assemblers support ASCII string initialization This allows the full use of the ASCII character set including digits and special characters On SHARC and TigerSHARC processors the characters are stored in the upper byte of 32 bit words The least significant bits LSBs are cleared When using 16 bit Blackfin processors refer to the BYTE directive description on page 1 77 for more information String initialization takes one of the following forms VAR symbolStringllength initString 0 VAR symbolString initString 0 Note that the number of initialization characters defines length of a string 1 138 VisualDSP 5 0 Assembler and Preprocessor Manual Assem
41. applies to all floating point expressions in the file that follow it up to the next PRECISION directive Example PRECISTON 32 Selects standard IEEE 32 bit single precision format 1 112 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler PRECISION 40 Selects standard IEEE 40 bit format with extended mantissa This is the default setting The ROUND_ directives on page 1 119 specify how the assembler converts a value of many significant bits to fit into the selected precision VisualDSP 5 0 Assembler and Preprocessor Manual 1 113 Assembler Syntax Reference PREVIO US Revert to the Previously Defined Section The PREVIOUS directive instructs the assembler to set the current section in memory to the section described immediately before the current one The PREVIOUS directive operates on a stack Syntax PREVIOUS The following examples provide valid and invalid cases of the use of the consecutive PREVIOUS directives Example of Invalid Directive Use SECTION datal data SECTION code instructions PREVIOUS previous section ends back to datal PREVIOUS no previous section to set to Example of Valid Directive Use define MACRO1 SECTION data2 VAR vd 4 PREVIOUS SECTION datal data VAR va 1 SECTION program instructions VAR vb 2 MACRO1 invoke macro PREVIOUS VAR vc 3 1 114 VisualDSP 5
42. assembler to store floating point data with 40 bit precision and to round a floating point value to a closer to zero value if it does not fit in the 40 bit format LDF for SHARC Processors Listing 1 1 shows a sample user defined 1df file for SHARC processors Looking at the file s SECTIONS command notice that the INPUT_SECTION commands map to the names of memory sections such as program data1 data2 ctor heaptab and so on used in the example assembly sample program Listing 1 1 LDF Example for SHARC Processors ARCHITECTURE ADSP 21062 SEARCH_DIR ADI_DSP 21k lib LIBRARIES 11b060 d1b libc dlb OBJECTS COMMAND_LINE_OBJECTS 060_hdr doj MEMORY seg_rth TYPE PM RAM START 0x20000 END Ox20fff WIDTH 48 seg_init TYPE PM RAM START 0x21000 END Ox2100f WIDTH 48 seg_pmco TYPE PM RAM START Ox21010 END Ox24fff WIDTH 48 1 10 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Preprocessor Commands _____ include const h define PI 3 14159 Assembler Directives gt _ PRECISION 40 ROUND_ZERO SECTION DM seg_dmda VAR fxd 10 1 2 3 4 5 6 7 8 9 0xA Data Section VAR rad SECTION PM seg_pmda VAR flt 5 PI PI 2 1 0 2 0 2 0 3 0 C SECTION PM seg_pmco instructions function1 10 fxd MO 1 18 fit Code Section lt M8 1 Assembler Label RO LENGTH fit LCNTR RO DO this_loop UNTIL LCE
43. canceled by a COMPRESS directive on page 1 81 later in the source file The directive s effect also is cancelled by a FORCE COMPRESS directive on page 1 87 for one instruction only VisualDSP 5 0 Assembler and Preprocessor Manual 1 107 Assembler Syntax Reference PAGELENGTH Set the Page Length of a Listing File The PAGELENGTH directive controls the page length of the listing file produced by the assembler when you use the 1 switch on page 1 159 Syntax PAGELENGTH expression where expression evaluates to an integer 0 or greater It specifies the number of text lines per printed page The default page length is 0 which means the listing has no page breaks To format the entire listing place the PAGELENGTH directive at the beginning of your assembly source file If a page length value greater than 0 is too small to allow a properly formatted listing page the assembler issues a warning and uses its internal minimum page length approxi mately 10 lines Example PAGELENGTH 50 starts a new page after printing 50 lines You can set the page length only once per source file If the assembler encounters multiple occurrences of the directive it ignores all except the last directive 1 108 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler PAG EWIDTH Set the Page Width of a Listing File The PAGEWIDTH directive sets the page width of the listing file produced by the assembler wh
44. declaring and or initializing memory variables or buffer elements use this format Note that the terminating semicolon is optional SHORT initExpressionl initExpression2 3 SHORT constExpressionl constExpression2 where initExpressions parameters contain one or more comma separated symbol value expressions VisualDSP 5 0 Assembler and Preprocessor Manual 1 129 Assembler Syntax Reference constExpressions parameters contain a comma separated list of constant values The following lines of code demonstrate SHORT directives Declare three 2 byte variables zero initialized SHORT Ins Outs Remains Declare a 2 byte variable and initialize it to 100 SHORT taps 100 Declare three 2 byte areas of memory initialized to 3 4 and 5 respectively SHORT 0x3 0x4 0x5 STRUCT Create a Struct Variable The STRUCT directive allows you to define and initialize high level data objects within the assembly code The STRUCT directive creates a struct variable using a C style typedef as its guide from IMPORT C header files Syntax Nn RUCT typedef structName RUCT typedef structName RUCT typedef structName struct member initializers struct member initializers STRUCT typedef ArrayOfStructs struct member initializers Nn N struct member initializers where typedef the type definition for a struct VARstructName
45. description file 1df Looking at the file s SECTIONS command notice that the INPUT_SECTION commands map to sections program datal and constdata Listing 1 3 Example Linker Description File for Blackfin Processors ARCHITECTURE ADSP BF535 SEARCH_DIR ADI_DSP Blackfin lib tdefine LIBS libc dlb libdsp dlb LIBRARIES LIBS librt535 d1b OBJECTS COMMAND_LINE_OBJECTS EMORY Define label system memory List of global Memory Segments EM_PROGRAM TYPECRA START OxFOO00000 END OXxFOO2FFFF WIDTH 8 EM_HEAP TYPECRA START OxFO030000 END OxFOO37FFF WIDTH 8 EM_STACK TYPECRA START OxF0038000 END OxFOO3DFFF WIDTH 8 EM_SYSSTACK TYPECRA START OXFOO3E000 END OxFOO3FDFF WIDTH 8 EM_ARGV TYPECRA START OXFOO3FE00 END COXFOO3FFFF WIDTH 8 PROCESSOR pO The processor in the system VisualDSP 5 0 Assembler and Preprocessor Manual Assembler OUTPUT COMMAND_LINE_OUTPUT_FILE SECTIONS List of sections for processor PO progra Align all code sections on 2 byte boundary NPUT_SECTION_ALIGN 2 PUT_SECTIONS OBJECTS program LIBRARIES program NPUT_SECTION_ALIGN PUT_SECTIONS OBJECTS datal LIBRARIES datal NPUT_SECTION_ALIGN PUT_SECTIONS OBJECTS cons
46. file 1st is an optional output text file that lists the results of the assembly process Listing files provide the following information Address The first column contains the offset from the SECTION s base address Opcode The second column contains the hexadecimal opcode that the assembler generates for the line of assembly source Line The third column contains the line number in the assembly source file Assembly Source The fourth column contains the assembly source line from the file The assembler listing file provides information about the imported C data structures It tells which imports were used within the program followed by a more detailed section It shows the name total size and layout with offset for the members The information appears at the end of the listing You must specify the 1 filename option as described on page 1 159 to produce a listing file 1 34 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Enabling Statistical Profiling for Assembly Functions Use the following steps to enable statistical profiling in assembler sources 1 When using the VisualDSP IDDE use the Assemble page of the Project Options dialog box Figure 1 6 on page 1 171 to select and or set assembler functional options 2 Select the Generate debug information option 3 Mark ending function boundaries with end labels in the assembler source For example SECTION program GLO
47. for code generation from the file lt processor gt ini The assembler searches for the ini file in the VisualDSP System folder For custom processors the assembler searches the section proc in the lt processor gt ini file for key architecture The custom processor must be based on an architecture key that is one of the known processors For example proc Custom xxx searches the Custom xxx ini file See also the si revision version switch description for more infor mation on silicon revision of the specified processor save temps The save temps save intermediate files switch directs the assembler to retain intermediate files generated and normally removed as part of the assembly process Short word code or swc The short word code or swc switch directs the assembler to encode input sections bearing the PM qualifier see Table 1 20 for execution from short word memory The switch is used with the ADSP 2146x SHARC processors only si revision version The si revision version silicon revision switch directs the assembler to build for a specific hardware revision Any errata workarounds available for the targeted silicon revision will be enabled The version parameter represents a silicon revision for the processor specified by the proc proces sor switch VisualDSP 5 0 Assembler and Preprocessor Manual 1 165 Assembler Command Line Reference For example easmblkfn proc ADSP BF533 si r
48. for dot_product_asm Eh General F Project Assemble Eh Language Settings z Eh MISRA C Options Eh Preprocessor I Generate verbose output F Save temporary files Th Processor 1 IV Generate debug information Skip preprocessing Eh Processor 2 I Output listing file Eh Profile guided Optimization fay Warning E Assemble n fl Link Preprocessor definitions E General fs LDF Preprocessing Eh Elimination Additional include directories ea Processor A El Load l jes Options jes Compression Th Kernel Eh Splitter 7 Additional options Th Pre build Eh Post build 2 Add Startup Code LDF a Figure 1 6 Example Project Options Dialog Box Assemble Page Most dialog box options have corresponding assembler command line switches described in Assembler Command Line Switch Descriptions on page 1 144 For more information use the VisualDSP context sensitive Help view select information on assembler options you can specify in VisualDSP To do that click on the toolbar s button and then click on the dialog box field or box for which you require information Use the Additional options field to enter appropriate command line switches file names and options that do not have corresponding controls on the Assemble page but are available via command line invocation VisualDSP 5 0 Assembler and Preprocessor Manual 1 171 Assembler Command Line Reference Assembler options apply to direc
49. from the Analog Devices Web site change rapidly and therefore are not included on the technical library CD Technical manuals change periodically Check the Web site for the latest manual revisions and associated documentation errata Notation Conventions Text conventions used in this manual are identified and described as follows Additional conventions which apply only to specific chapters may appear throughout this document Example Description Close command Titles in in bold style reference sections indicate the location of an item File menu within the VisualDSP environment s menu system for example the Close command appears on the File menu this that Alternative required items in syntax descriptions appear within curly brackets and separated by vertical bars read the example as this or that One or the other is required this that Optional items in syntax descriptions appear within brackets and sepa rated by vertical bars read the example as an optional this or that xviii VisualDSP 5 0 Assembler and Preprocessor Manual Preface Example Description this Optional item lists in syntax descriptions appear within brackets delimited by commas and terminated with an ellipse read the example as an optional comma separated list of this SECTION Commands directives keywords and feature names are in text with letter gothic font filename Non keyword
50. have the same affect as the DEFAULT form of MESSAGE Many error messages cannot be altered in severity as the assembler behavior is unknown Include files inherit any severity changes from the files which include them MESSAGE directives in include files do not control the severity of messages generated after returning to the source file which included them A MESSAGE DEFAULT directive in an include file controls the severity of messages generated after returning to the source file which included them VisualDSP 5 0 Assembler and Preprocessor Manual 1 105 Assembler Syntax Reference NEWPAGE Insert a Page Break in a Listing File The NEWPAGE directive inserts a page break in the printed listing file 1st which the assembler produces when you use the 1 switch on page 1 159 The assembler inserts a page break at the location of the NEWPAGE directive The NEWPAGE directive does not take any qualifiers or arguments Syntax NEWPAGE This directive may appear anywhere in your source file In the absence of the NEWPAGE directive the assembler generates no page breaks in the file 1 106 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler NOCOMPRESS Terminate Compression NOTE Used with the ADSP 2146x SHARC processors only The NOCOMPRESS directive indicates that all of the following instructions in the source file should not be compressed Syntax NOCOMPRESS The directive s effect is
51. honors the alignment specified by the assembler when placing the section in memory thus guaranteeing the integrity of the alignment of each element aligned with a ALIGN directive You also can use the INPUT_SECTION_ALIGN number LDF command in the 1df file to force all the following input sections to the specified alignment Refer to the VisualDSP 5 0 Linker and Utilities Manual for more information on section alignment Syntax ALIGN expression where expression evaluates to an integer It specifies an alignment require ment its value must be a power of 2 When aligning a data item or instruction the assembler adjusts the address of the current location counter to the next address that can be divided by the value of expression with no remainder The expression set to 0 or 1 signifies no address alignment requirement The linker stops allocating padding for symbols aligned by 16 or more In the absence of the ALIGN directive the default address alignment is 1 1 72 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Example In the following example the assembler sets the alignment of the section to 4 to match the value specified in the second alignment directive This satisfies the first alignment directive as well since any item alignment on an address multiple of 4 is also aligned on a multiple of 2 If the target is a byte addressed processor such as Blackfin there is no padding inserted bet
52. in the 1df file 1 140 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Assembler Command Line Reference This section describes the assembler command line interface and switch set It describes the assembler s switches which are accessible from the operating system s command line or from the VisualDSP environment This section contains e Running the Assembler on page 1 142 e Assembler Command Line Switch Descriptions on page 1 144 Command line switches control certain aspects of the assembly process including debugging information listing and preprocessing Because the assembler automatically runs the preprocessor as your program assembles unless you use the sp switch the assembler s command line can receive input for the preprocessor program and direct its operation For more information on the preprocessor see Chapter 2 Preprocessor When developing a DSP project you may find it useful to modify the assembler s default options settings The way you set assembler options depends on the environment used to run the DSP develop ment software See Specifying Assembler Options in VisualDSP on page 1 170 for more information VisualDSP 5 0 Assembler and Preprocessor Manual 1 141 Assembler Command Line Reference Running the Assembler To run the assembler from the command line type the name of the appropriate assembler program followed by arguments in any or
53. include filename used with user header files e iinclude text used with a sequence of tokens The sequence of tokens is subject to macro expansion by the pre processor After macro expansion the text must match one of the header file forms The only difference to the preprocessor between the two types of header files is the way the preprocessor searches for them e System Header File lt fi7eName gt The preprocessor searches for a system header file in this order 1 the directories you specify and 2 the standard list of system directories e User Header File fi7eName The preprocessor searches for a user header file in this order 1 Current directory the directory where the source file that has the include command s lives 2 Directories you specify 3 Standard list of system directories Refer to Header Files and include Command on page 2 4 for more information 2 34 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor Syntax d Finclude lt fileName gt include a system header file include fileName include a user header file include macroFileNameExpansion Include a file named through macro expansion This command directs the preprocessor to expand the macro The preprocessor processes the expanded text which must match either lt fileName gt or fileName Example ifdef ADSPBF535__ Tests that __ADSPBF535__ has been defined include lt
54. information about related development software It also provides information on new and legacy syntax for assembler and preprocessor directives and comments as well as command line switches Intended Audience The primary audience for this manual is a programmer who is familiar with Analog Devices processors This manual assumes that the audience has a working knowledge of the appropriate processor architecture and instruction set Programmers who are unfamiliar with Analog Devices processors can use this manual but should supplement it with other texts such as the appropriate hardware reference and programming reference manuals that describe your target architecture VisualDSP 5 0 Assembler and Preprocessor Manual xiii Manual Contents Manual Contents The manual consists of e Chapter 1 Assembler Provides an overview of the process of writing and building assembly programs It also provides information about assembler switches expressions keywords and directives e Chapter 2 Preprocessor Provides procedures for using preprocessor commands within assembly source files as well as the preprocessor s command line interface options and command sets Whats New in this Manual This revision of the VisualDSP 5 0 Assembler and Preprocessor Manual documents assembler and preprocessor functionality that is new to Visu alDSP 5 0 and updates up to update 6 including support for new ADSP 2146x SHARC proce
55. of the entire array Struct References A reference to a struct VAR provides an absolute address For a fully qualified reference to a member the address is offset to the correct loca tion within the struct The assembler syntax for struct references is gt The following example references the address of Member5 located within myStruct 1 64 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler myStruct gt Member5 If the struct layout changes there is no need to change the reference The assembler recalculates the offset when the source is reassembled with the updated header Nested struct references are supported For example myStruct gt nestedRef gt AnotherMember Unlike struct members in C struct members in the assembler are always referenced with gt not because is a legal character in identifiers in assembly and is not available as a struct reference References within nested structures are permitted A nested struct definition can be provided in a single reference in assembly code and a nested struct via a pointer type requires more than one instruction Use the OF FSETOF built in function to avoid hard coded offsets that may become invalid if the struct layout changes in the future Following are two nested struct examples for IMPORT CHeaderFile h Example 1 Nested Reference Within the Struct Definition with Appropriate C Declarations C Code struc
56. page 1 122 SEGMENT Legacy directive Replaced with the SECTION directive on page 1 128 NOTE SHARC processors only SEPARATE_MEM_SEGMENTS Specifies that two buffers should be placed into different on page 1 128 memory segments by the linker NOTE TigerSHARC processors only SET Sets symbolic aliases on page 1 129 SHORT Supports two byte data initializer lists for GNU compatibility on page 1 129 NOTE Blackfin processors only STRUCT Defines and initializes data objects based on C typedefs from on page 1 130 IMPORT C header files TEXT Equivalent to SECTION program Refer to SECTION Declare a Memory Section on page 1 122 NOTE Blackfin processors only TYPE Changes the default data type of a symbol used by C compiler on page 1 134 VAR Defines and initializes 32 bit data objects on page 1 135 WEAK Creates a weak definition or reference on page 1 140 VisualDSP 5 0 Assembler and Preprocessor Manual 1 71 Assembler Syntax Reference ALIGN Specify an Address Alignment The ALIGN directive forces the address alignment of an instruction or data item The assembler sets the alignment of the section to match the largest alignment requirement specified in the section and inserts padding at each alignment location to ensure that the following item has the proper offset from the start of the section to maintain the requested alignment The linker
57. placeholders appear in text with italic style format Note For correct operation A Note provides supplementary information on a related topic In the online version of this book the word Note appears instead of this symbol Caution Incorrect device operation may result if Caution Device damage may result if A Caution identifies conditions or inappropriate usage of the product that could lead to undesirable results or product damage In the online version of this book the word Caution appears instead of this symbol Warning Injury to device users may result if A Warning identifies conditions or inappropriate usage of the product that could lead to conditions that are potentially hazardous for devices users In the online version of this book the word Warning appears instead of this symbol VisualDSP 5 0 Assembler and Preprocessor Manual xix Notation Conventions xx VisualDSP 5 0 Assembler and Preprocessor Manual 1 ASSEMBLER This chapter provides information on how to use the assembler to develop and assemble programs for SHARC ADSP 21xxx TigerSsHARC ADSP TSxxx and Blackfin ADSP BFxxx processors The chapter contains the following sections e Assembler Guide on page 1 2 Describes how to develop new programs using the processor s assembly language e Assembler Syntax Reference on page 1 37 Provides the assembler rules and conventions of syntax used to de
58. preprocessing For more information see Assembler Command Line Reference on page 1 141 You can also set assembler options via the Assemble page of the Project Options dialog box in VisualDSP For more information see Specify ing Assembler Options in VisualDSP on page 1 170 VisualDSP 5 0 Assembler and Preprocessor Manual 1 3 Assembler Guide Writing Assembly Programs Assembler directives are coded in assembly source files The directives allow you to define variables set up hardware features and identify pro gram sections for placement within processor memory The assembler uses directives for guidance as it translates a source program into object code Write assembly language programs using the VisualDSP editor or any editor that produces text files Do not use a word processor that embeds special control codes in the text Use an asm extension to source file names to identify them as assembly source files Figure 1 1 shows a graphical overview of the assembly process The figure shows the preprocessor processing the assembly source asm and header h files Assemble your source files from the VisualDSP environment or using any mechanism such as a batch file or makefile that supports invoking an appropriate assembler driver with a specified command line command By default the assembler processes an intermediate file to produce a binary object file doj and an optional listing file 1st
59. stdlib h gt ffendif VisualDSP 5 0 Assembler and Preprocessor Manual 2 35 Preprocessor Command Reference Hine The 1 ine command directs the preprocessor to set the internal line counter to the specified value Use this command for error tracking purposes Syntax line TineNumber sourceFile where 1ineNumber line number of the source line sourceFile name of the source file included in double quotation marks The sourceFile entry can include the drive directory and file extension as part of the file name Example line 7 myFile c All assembly programs have 1 ine directives after preprocessing They always have a first line with line 1 filename asm and they will also have 1 ine directives to establish correct line num bers for text that came from include files as a result of the processed Hinclude directives 2 36 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor pragma The pragma command is the implementation specific command that modifies the preprocessor behavior The pragma command can take any sequence of tokens This command is accepted for compatibility with other VisualDSP software tools The pp preprocessor currently does not support any pragmas therefore it ignores any information in the pragma command Syntax fpragma any_sequence_of_tokens Example fpragma disable_warning 1024 VisualDSP 5 0 Assembler and Preprocessor Manual 2 37 Prep
60. style comments comment as well as C style comments comment The C style comment has a delimiter at the start and end of the comment the C style comment begins at the and terminates at the end of the line The terminates at the end of the line aspect of C style com ments renders comments unsuitable within multi line macro definitions The line continuation character causes the next line to be concatenated to the comment thus becoming part of the com ment The following code fragment demonstrates the problem define macro first line second line when expanded by writing macro in your asm file this code becomes first line second line If you use C style comments you can write define macro this macro has two lines first line VisualDSP 5 0 Assembler and Preprocessor Manual 2 11 Preprocessor Guide and two comments X second line which will expand to first line second line However if you use C style comments as shown below tdefine macro this comment will devour the rest of the macro first line second line the macro expands into an empty macro In the code above the first line of the macro definition starts a comment Since there are line continuation characters the logical end of line for that comment is the end of the macro Thus the code yields an empty macro e Macro nesting macros called within anothe
61. to it with a leading _ e Ifa struct was declared in an asm file use the name as is no leading underscore _ is necessary The EXTERN STRUCT directive optionally accepts a list such as EXTERN STRUCT typedef structvarName STRUCT typedef structvar Name The key to the assembler knowing the layout is the IMPORT directive and the EXTERN STRUCT directive associating the typedef with the struct VAR To reference a data structure declared in another file use the IMPORT directive with the EXTERN directive This mechanism can be used for structures defined in assembly source files as well as in C files VisualDSP 5 0 Assembler and Preprocessor Manual 1 83 Assembler Syntax Reference The EXTERN directive supports variables in the assembler If the program references struct members EXTERN STRUCT must be used because the assembler must consult the struct layout to calculate the offset of the struct members If the program does not reference struct members you can use EXTERN for struct VARs Example SHARC code IMPORT MyCelebrities h Celebrity is the typedef for struct var StNick EXTERN means that _StNick is referenced within this file but not locally defined This example assumes StNick was declared in a C file and it must be referenced with a leading underscore EXTERN STRUCT Celebrity _StNick isSeniorCitizen is one of the members of the Celebrity type P3
62. 0 END COXOFFFFFFF WIDTH 32 PROCESSOR pO The processor in the system OUTPUT COMMAND_LINE_OUTPUT_FILE SECTIONS List of sections for processor PO code FILL Oxb3c00000 INPUT_SECTION_ALIGN 4 INPUT_SECTIONS OBJECTS program gt MOCode datal INPUT_SECTIONS OBJECTS datal gt M1Data data2 INPUT_SECTIONS 0BJECTS data2 gt M2Data Provide support for initialization including C static initialization This section builds a table of initialization function pointers ctor VisualDSP 5 0 Assembler and Preprocessor Manual 1 15 Assembler Guide INPUT_SECTIONS 0BJECTS ctord INPUT_SECTIONS 0BJECTS ctor1 INPUT_SECTIONS 0BJECTS ctor2 INPUT_SECTIONS 0BJECTS ctor3 Ye Ye wy wH INPUT_SECTIONS OBJECTS ctor gt M1Data Table containing heap segment descriptors heaptab INPUT_SECTIONS OBJECTS heaptab gt M1Data Allocate stacks for the application jstackseg ldf_jstack_limit ldf_jstack_base MEMORY_SIZEOF M1Stack gt M1Stack kstackseg ldf_kstack_limit ldf_kstack_base MEMORY_SIZEOF M2Stack gt M2Stack The default heap occupies its own memory block defheapseg ldf_defheap_base ldf_defheap_size MEMORY_SIZEOF M1Heap gt M1lHeap VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Cod
63. 0 Assembler and Preprocessor Manual Assembler evaluates as SECTION datal data VAR va 1 SECTION program instructions VAR vb 2 Start MACRO1 SECTION data2 VAR vd 4 PREVIOUS end data2 section program End MACRO1 PREVIOUS end program start datal VAR vc 3 PRIORITY Allow Prionitized Symbol Mapping in Linker The PRIORITY directive allows prioritized symbol mapping in the linker The directive can be specified in three ways e Fora symbol defined in the same file as the directive e Fora globally defined symbol e Fora local symbol in a different source file Syntax PRIORITY symbo Name priority PRIORITY symbo Name sourcefile priority where In the first case symbo Name is a global symbol or locally defined symbol In the second case symbolName is a symbol defined in sourcefile VisualDSP 5 0 Assembler and Preprocessor Manual 1 115 Assembler Syntax Reference Example PRIORITY _foo 35 Symbol with highest priority PRIORITY _main 15 Symbol with medium priority PRIORITY bar barFile asm 10 Symbol with lowest priority Linker Operation After the absolute placement of symbols specified in the 1df file s RESOLVE command but before mapping commands are processed the linker tries to map all symbols appearing in priority directives in decreasing order of their priorities The prioritized symbol is placed into memory th
64. 1 149 anomal ydetect Lic cesrennnsanssreisornonen 1 149 anomaly warn id1 id2 all mone oo ee eeeeeeeeeeeeeeeeeees 1 149 anomaly workaround lid excdnaicarsasacecncadancemessscnesesnadnancers 1 150 E a a E E T A E E A A 1 151 seharga I oira TA 1 151 SNR SIA ig cect E AET 1 151 7ST AWE AUC E R 1 151 VisualDSP 5 0 Assembler and Preprocessor Manual vii CONTENTS MGIC RIANA 620s E A T E 1 152 A RCT ETI sensira 1 152 ALE DIE L iina EREA 1 152 IA OI se 1 153 HORACIO BY norieta ri 1 153 eee Oy mball INKE ror aed 1 153 lt x pand windows SNOrteuts sinensis 1 154 rete Atte HPAL sarcinam 1 154 ES a A 1 154 User Specitied Defines Options ccc cecciscaserctccdscotzacnanades 1 155 Tnclvde Options sriaiusenssri aes 1 155 Flagepp ope ropa ere 1 156 E E E E ER aR 1 156 WARNING al 121 Missing End Labels iiascisicscvcives 1 157 STN r AR AEA 1 158 E E E AAE A E EE EE 1 158 A PCH AI enano aa aii 1 159 E ANE i E EE E E E EE EE T 1 159 ANI cai Siete aa laa Wa eeera pede rena 1 160 ha D EE A E EE E EE E A 1 160 RI acs ose shack E A E E E E 1 161 Sig 2 1 1a aR 1 161 AWA obeak a an aaa 1 161 osouredependeney srsriscernnseonn enh 1 161 viii VisualDSP 5 0 Assembler and Preprocessor Manual CONTENTS an anomaly detecr i002 oo ccsreincirercaneeerniends 1 162 no anomaly workaround id1 id2 eeeeeeceeeeeseeeeeeeeee 1 162 no expand symbolic links cigs cic cccdss asic ensdiietwnnsdeamaoneeoceeds 1 162 no expan
65. 1 5r 0 5e 4r 0 25e 3r fracts 0 875r 2 1 5r is out of range VisualDSP 5 0 Assembler and Preprocessor Manual 1 57 Assembler Syntax Reference Fract constants must be greater than or equal to 1 and less than 1 In Blackfin processors fract 1 15 is a default Use a R32 qualifier in BYTE4 R32 or VAR R32 to support 32 bit initialization for use with 1 31 fracts 1 31 Fracts Fracts supported by Analog Devices processors use 1 31 format which means a sign bit and 31 bits of fraction This is 1 to 1 2 31 For example 1 31 maps the constant 0 5r to 2 31 The conversion formula used by processors to convert from floating point format to fixed point format uses a scale factor of 31 For example VAR R32 myFract 0 5r Fract output for 0 5r is 0x4000 0000 sign bit 31 bits 0100 0000 0000 0000 0000 0000 0000 0000 4 0 0 0 0 0 0 0 0x4000 0000 or VAR R32 myFract 1 0r Fract output for 1 0r is 0x8000 0000 sign bit 31 bits 1000 0000 0000 0000 0000 0000 0000 0000 8 0 0 0 0 0 0 0 0x8000 0000 1 0r VAR R32 myFract 1 72471041E 03r Fract output for 1 72471041E 03 is OxFFC77C15 sign bit 31 bits 1111 1111 1100 0111 0111 1100 0001 0101 F F C 7 7 C 1 5 1 58 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler 1 0r Special Case 1 0r is out of the range fract Specify 0x7FFF FFFF for the closest approximat
66. 126 branch instructions 1 149 1 151 1 152 lines default to NP 1 151 target buffer 1 151 1 152 BSS assembler directive 1 67 built in functions OFFSETOF 1 61 1 63 SIZEOF 1 61 1 63 BYTE4 R32 assembler directive 1 78 1 4 VisualDSP 5 0 Assembler and Preprocessor Manual BYTE BYTE2 BYTE4 assembler directives 1 77 C C C run time library initializing 1 126 CHAR32 section qualifier 1 124 CHARS section qualifier 1 124 CHARANY section qualifier 1 124 char size 32 assembler switch 1 151 char size 8 assembler switch 1 151 char size any assembler switch 1 151 circular buffers setting 1 54 1 55 comma separated options 1 156 COMPRESS assembler directive 1 81 concatenate preprocessor operator 2 42 conditional assembly directives ELIF 1 60 ELSE 1 60 ENDIF 1 60 IF 1 60 constant expressions 1 51 conventions comment strings 1 60 file extensions 1 143 file names 1 143 numeric formats 1 56 user defined symbols 1 49 cpredef C style definitions preprocessor switch 2 48 2 49 C programs interfacing assembly 1 20 C programs interfacing assembly 1 20 csall all comment styles preprocessor switch 2 50 cs comment style preprocessor switch 2 49 cs comment style preprocessor switch 2 49 cs comment style preprocessor switch 2 50 cs comment style preprocessor switch 2 50 INDEX C structs in assembly source 1 21 customer support xv D
67. 170 Use preprocessor commands to modify assembly code For example you can use the include command to fill memory load configuration registers or set up processor parameters You can use the def ine com mand to define constants and aliases for frequently used instruction sequences The preprocessor replaces each occurrence of the macro reference with the corresponding value or series of instructions For example the MAXIMUM macro from define MAXIMUM 100 is replaced with the number 100 during preprocessing 1 24 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler For more information on the preprocessor command set see Preproces sor Command Reference on page 2 22 For more information on the preprocessor usage see flags pp opt1 opt2 on page 1 156 There is one important difference between the assembler prepro cessor and compiler preprocessor The assembler preprocessor treats the character as part of an identifier Thus EXTERN is a single identifier and will not match a preprocessor macro EXTERN This behavior can affect how macro expansion is done for some instructions For example define EXTERN 0x123 EXTERN Coordinate EXTERN not affected by macro d fdefine MY_REG PO MY_REG 1 14 MY_REG 1 is not expanded is part of token Using Assembler Feature Mac ros The assembler includes the command to invoke preprocessor macros to define the context such
68. 2 BYTE4 DATA IF ELSE ENDIF ELSE ENDIF XTERN FILE FILE_ATTR GLOBAL GLOBL F INC BINARY INCBIN IMPORT LEFTMARGIN LIST LIST_DATA LIST_DATFILE LIST_DEFTAB LIST_LOCTAB LIST_WRAPDATA LONG EWPAGE NOLIST NOLIST_DATA NOLIST_DATFILE NOLIST_WRAPDATA PAGELENGTH PAGEWIDTH PREVIOUS SECTION SET SYMBOL SYMBOL SHORT STRUCT TEX TYPE LVAR EAK AO Al ABORT ABS AC ALIGNS ALIGN16 ALIGN24 AMNOP AN AND ASHIFT ASL ASR ASSIGN ASTAT AVO AVI AZ B BO B1 B2 B3 1 38 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 9 Blackfin Processor Assembler Keywords Contd BANG BAR BITCLR BITMUX BITPOS BITSET BITTGL BITTST BIT_XOR_AC BP BREV BRF BRT BY BYTEOP1P BYTEOP16M BYTEOPINS BYTEOP16P BYTEOP2P BYTEOP3P BYTEPACK BYTEUNPACK BXOR BXORSHIFT CALL CARET cC CLI CLIP co CODE COLON COMMA CSYNC DATA DEPOSIT DISALGNEXCPT DIVSDEPOSIT DISALGNEXCPT DIVSDEPOSIT D DOZE DIVQ DIVS DOT EMUCAUSE EMUEXCPT EXCAUSE EXCPT EXPADJ EXTRACT FEXT FEXTSX FLUSH FLUSHINV FP FU GE GF GT H HI HLT HWERRCAUSE 0 1 12 13 IDLE DLE_REQ FLUSH IH INTRP IS SS2 U JUMP JUMP L JUMP S L LBO LB1 LCO BA LE LENGTH LINK LJUMP LMAX LMIN LO LOOP LOOP_BEGIN LOOP_END LPAREN LSETUP LSHIFT LT LTO LT1 LZ 0 1 2 3 AX IN INUS NOP UNOP EG O_INIT OP OT S VisualDSP 5 0 Assembler and Prepro
69. 4 and to Reading a Listing File on page 1 34 VisualDSP 5 0 Assembler and Preprocessor Manual 1 21 Assembler Guide C structs in assembly features accept the full set of legal C symbol names including those that are otherwise reserved in the appropriate assembler For example e In the SHARC assembler 11 12 and 13 are reserved keywords but it is legal to reference them in the context of the C struct in assembly features e Inthe TigerSHARC assembler J1 J2 and J3 are reserved keywords but it is legal to reference them in the context of the C struct in assembly features e In the Blackfin assembler as an example Xx and z are reserved keywords but it is legal to reference them in the context of the C struct in assembly features The examples below show how to access the parts of the struct defined in the header file but they are not complete programs on their own Refer to your DSP project files for complete code examples Blackfin Example IMPORT Coordinate h typedef struct Coordinate int X int Y int vk Coordinate SECTION datal STRUCT Coordinate Coordl X 1 4 y Z 7 1 22 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler SECTION program PO 1 Coordl gt X PO h Coordl gt X P1 1 Coordl gt Y P1 h Coordl gt Y P2 1 Coordl gt Z P2 h Coordl gt Z P3 1 Coord1 0OFFSETOF Coordinate Z P3 h C
70. 5 1 29 128 48 3 0x55 amp Ox0f7 6r 0 8r For information about fraction type support refer to Fractional Type Support on page 1 57 Symbolic Expressions Symbolic expressions contain symbols whose values may not be known until link time For example data 8 data_bufferl data_buffer2 amp OXF strtup 2 data_bufferl LENGTH data_buffer2 2 Symbols in this type of expression are data variables data buffers and program labels In the first three examples above the symbol name repre sents the address of the symbol The fourth example combines that meaning of a symbol with a use of the length operator see Table 1 13 Assembler Operators Table 1 12 lists the assembler s numeric and bitwise operators used in constant expressions and address expressions These operators are listed in group order from highest precedence to lowest precedence Operators with the highest precedence are evaluated first When two operators have the same precedence the assembler evaluates the left most operator first VisualDSP 5 0 Assembler and Preprocessor Manual 1 51 Assembler Syntax Reference Relational operators are supported only in relational expressions in conditional assembly as described in Conditional Assembly Directives on page 1 60 Table 1 12 Operator Precedence Operator Usage Description Designation Processors expression expression in parentheses Parenth
71. ADSP BF544 with the ADSP BF544 processor __ADSPBF547__ Present when running easmblkfn proc ADSP BF547 with the ADSP BF547 processor __ADSPBF548___ Present when running easmblkfn proc ADSP BF548 with the ADSP BF548 processor __ADSPBF549___ Present when running easmblkfn proc ADSP BF549 with the ADSP BF549 processor __ADSPBF561__ Present when running easmblkfn proc ADSP BF561 with the ADSP BF561 processor Table 2 3 SHARC Feature Preprocessor Macros Macro Definition __ADSP21000__ Always 1 for SHARC processor tools __ADSP21020__ Present when running easm21K proc ADSP 21020 with the ADSP 21020 processor __ADSP21060__ Present when running easm21K proc ADSP 21060 with the ADSP 21060 processor __ADSP21061__ Present when running easm21K proc ADSP 21061 with the ADSP 21061 processor __ADSP21062__ Present when running easm21K proc ADSP 21062 with the ADSP 21062 processor __ADSP21065L__ Present when running easm21K proc ADSP 21065L with the ADSP 21065L processor __ADSP21160__ Present when running easm21K proc ADSP 21160 with the ADSP 21160 processor __ADSP21161__ Present when running easm21K proc ADSP 21161 with the ADSP 21161 processor __ADSP2106x__ Present when running easm21K with the ADSP 2106x proces sors 2 18 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor Table 2 3 SHARC Feature Preprocessor Macros Contd
72. BAL funk1l funki RTS funkl end GLOBAL funk2 funk2 RTS funk2 end If you have global functions without ending labels the assembler provides warnings when debug information is generated GLOBAL funk3 funk3 RTS Warning ea1121 test asm 14 funk3 g assembly with global function without ending label Use funk3 end or VisualDSP 5 0 Assembler and Preprocessor Manual 1 35 Assembler Guide funk3 END to mark the ending boundary of the function for debugging information for automated statistical profiling of assembly functions 4 Add ending labels or selectively disable the warning by adding the Wsuppress 1121 option to the Additional options field on the Assembly page refer to WARNING ea1121 Missing End Labels on page 1 157 for more information 5 Choose Statistical Profiling gt New Profile or Linear Profiling gt New Profile as appropriate Assembler functions automatically appear in the profiling window along with C functions Click on the function name to bring up the source containing the function definition 1 36 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Assembler Syntax Reference When developing a source program in assembly language include preprocessor commands and assembler directives to control the program s processing and assembly You must follow the assembler rules and syntax conventions to define symbols identifiers and expressions and to
73. Building with unknown VisualDSP version endif Generating Make Dependencies The assembler can generate make dependencies for a file allowing VisualDSP and other makefile based build environments to determine when to rebuild an object file due to changes in the input files The assem bly source file and any files identified in the include commands IMPORT directives or buffer initializations in VAR and STRUCT directives consti tute the make dependencies for an object file When you request make dependencies for the assembly the assembler produces the dependencies from buffer initializations The assembler also invokes the preprocessor to determine the make dependency from include commands and the compiler to determine the make dependencies from the IMPORT headers For example easmblkfn proc ADSP BF533 MM main asm main doj VisualDSP Blackfin include defBF532 h ain doj VisualDSP Blackfin include defBF533 h main doj VisualDSP Blackfin include def_LPBlackfin h ain doj main asm ain doj input_data dat VisualDSP 5 0 Assembler and Preprocessor Manual 1 33 Assembler Guide The original source file main asm is as follows include defBF533 h GLOBAL input_frame BYTE input_frame N input_data dat load in 256 values from a test file In this case defBF533 h includes defBF532 h which also includes def_LPBlackfin h Reading a Listing File A listing
74. CISION is defined The PRECISION directive determines the number of bits to be truncated to match the number of significant bits see on page 1 112 The ROUND_ directives determine how the assembler handles the floating point values in constant declarations and variable initializations To configure the floating point rounding modes of the target processor system you must set up control registers on the chip using instructions specific to the processor core The ROUND_ directives use the following syntax ROUND_mode where The mode string specifies the rounding scheme used to fit a value in the destination format Use one of the following IEEE standard modes ROUND_NEAREST default ROUND_PLUS rounds to round to positive infinity ROUND_MINUS rounds to round to negative infinity ROUND_ZERO selects round to zero VisualDSP 5 0 Assembler and Preprocessor Manual 1 119 Assembler Syntax Reference In the following examples the numbers with four decimal places are reduced to three decimal places and are rounded accordingly ROUND_NEAREST Selects Round to Nearest scheme the default setting A 5 is added to the digit that follows the third decimal digit the least significant bit LSB The result is truncated after the third decimal digit LSB 1 2581 rounds to 1 258 8 5996 rounds to 8 600 5 3298 rounds to 5 329 6 4974 rounds to 6 496 ROUND_ZERO Selects Round to Zero
75. DSP BF525 processor __ADSPBF526__ Present when running easmblkfn proc ADSP BF526 with the ADSP BF526 processor __ADSPBF527__ Present when running easmblkfn proc ADSP BF527 with the ADSP BF527 processor __ADSPBF531___ Present when running easmblkfn proc ADSP BF531 __ADSP21531__ with the ADSP BF531 processor __ADSPBF532___ Present when running easmblkfn proc ADSP BF532 __ADSP21532__ with the ADSP BF532 processor __ADSPBF533___ Present when running easmblkfn proc ADSP BF533 __ADSP21533__ with the ADSP BF533 processor __ADSPBF534___ Present when running easmblkfn proc ADSP BF534 __ADSP21534__ with the ADSP BF534 processor __ADSPBF535___ Present when running easmblkfn proc ADSP BF535 __ADSP21535__ with the ADSP BF535 processor __ADSPBF536__ Present when running easmblkfn proc ADSP BF536 with the ADSP BF536 processor __ADSPBF537__ Present when running easmblkfn proc ADSP BF537 with the ADSP BF537 processor __ADSPBF538___ Present when running easmblkfn proc ADSP BF538 with the ADSP BF538 processor __ADSPBF539__ Present when running easmblkfn proc ADSP BF539 with the ADSP BF539 processor __ADSPBF542___ Present when running easmblkfn proc ADSP BF542 with the ADSP BF542 processor VisualDSP 5 0 Assembler and Preprocessor Manual 2 17 Preprocessor Guide Table 2 2 Blackfin Feature Preprocessor Macros Contd Macro Definition __ADSPBF544___ Present when running easmblkfn proc
76. E EtCR RA 1 116 REFERENCE Provide Better Info in an X REF File 1 118 RETAIN_NAME Stop Linker from Eliminating Symbol 1 118 ROUND_ Select Floating Point Rounding 00 1 119 SECTION Declare a Memory Section scsusiininosniss 1 122 Common SECTION Attributes wo cece ceeceeeeceeeeeee 1 122 vi VisualDSP 5 0 Assembler and Preprocessor Manual CONTENTS DOUBLE Qualifiers seriinciminentesitinrestativtinainent 1 123 Tiga SHARC Specific Quelifiets snscscsmisnsssn 1 124 SHARC Specific Qualibi rg soc dasa onstinetvacedvansenswaieeds 1 125 Initialization Section Qualifiers scccrcscavsussascreesecdacvensases 1 126 SEGMENT and ENDSEG Legacy Directives n s 1 128 SEPARATE MEM SEGMENTS arisrosensenronn 1 128 SEL Sera Sete Alia econo ous ieee 1 129 SHORT Defines and initializes 2 byte data objects 1 129 STRUCT Create a Struct Variable cc ccuiccuicpiexseshectuavancudus 1 130 TYPE Change Default Symbol Type ccescccccscoseinnseesersrens 1 134 VAR Declare a Data Variable or Butler snsrorsrsenenisi 1 135 VAR and ASCII String Initialization Support 1 138 WEAK Support Weak Symbol Definition and Reference 1 140 Assembler Command Line Reietence vrrercsinesinssiniinisin 1 141 Ranning rhe Assembler cscs ts casa snaieasteuonaetmineatardbedaeenaiees 1 142 Assembler Command Line Switch Descriptions 06 1 144 saligo braneh lines esi aageseiacaiciwiecswmncisaimtiesraaenwinainerbenanaaas
77. IL LCE loop counter buffer s length FO DM 15 M6 get next sample loopend Although the SHARC assembler accepts the source code written with the legacy operator it is recommended to use LENGTH in place of VisualDSP 5 0 Assembler and Preprocessor Manual 1 55 Assembler Syntax Reference Numeric Formats Depending on the processor architectures the assemblers support binary decimal hexadecimal floating point and fractional numeric formats bases within expressions and assembly instructions Table 1 14 describes the notation conventions used by the assembler to distinguish between numeric formats Table 1 14 Numeric Formats Convention Description Oxnumber The 0x prefix indicates a hexadecimal number Bitnumber The B or bi prefix indicates a binary number bitnumber number number e number Entry for floating point number number No prefix and no decimal point indicates a decimal number numberr The r suffix indicates a fractional number Due to the support for b and B binary notation the preprocessor stringization functionality is turned off by default to avoid possible undesired stringization For more information refer to the processor s Argument stringize and the assembler s flags pp opt1 opt2 com mand line switches Representation of Constants in Blackfin The Blackfin assembler keeps an internal 32 b
78. ING a1121 missing end labels 1 157 warnings multi issue conflicts 1 161 printing 2 56 suppressing See Wnumber warning suppression preprocessor switch warning warning message preprocessor command 2 39 warn print warnings preprocessor switch 2 56 WEAK assembler directive 1 140 VisualDSP 5 0 Assembler and Preprocessor Manual INDEX weak symbol binding 1 140 w skip warning messages Werror number assembler switch 1 168 assembler switch 1 167 Winfo number informational messages preprocessor switch 2 55 assembler switch 1 168 Wsuppress number assembler switch 1 169 Wno info no informational messages Wwarn error assembler switch 1 169 assembler switch 1 168 Wwarn number assembler switch 1 169 Wnumber warning suppression assembler switch 1 168 Z preprocessor switch 2 56 wrapping opcode listings 1 100 writing assembly programs 1 4 ZERO_INIT memory section 1 127 section qualifier 1 126 I 12 VisualDSP 5 0 Assembler and Preprocessor Manual
79. Multi Line Code Macros with Arguments on page 2 12 e Debugging Macros on page 2 13 2 8 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor Macro Definition and Usage Guidelines A macro definition can be any text that may occur legally in the source file that references the macro In assembly files the macro may expand to include instructions directives register names constants and so on In LDFs a macro may expand to include LDF commands memory descriptions and other items that are legal in an LDF The macro definition may also have other macro names that are replaced with their own definitions The following guidelines are provided to help you construct macros and use them appropriately e A macro definition must begin with define and must end with a carriage return e Macro termination If a macro definition ends with a terminator on the instruction one semicolon for SHARC and Blackfin processors two semicolons for TigerSHARC processors do not place a terminator at the end of the macro usage in an assem bly statement However if a macro definition does not end with a terminator each instance of the macro usage must be followed by the terminator in the assembly statement Be consistent with regard to how you use terminators in macro definitions Examples shown in this section omit the terminator in the macro definition and use the terminator in the assembly text Note that t
80. NARY Include Contents of a File on page 1 92 NOTE Blackfin processors only Defines the width of the left margin of a listing LIST NOLIST on Starts listing of source lines Starts listing of data opcodes _DATFILE Starts listing of data initialization files _DEFTAB Sets the default tab width for listings _LOCTAB n T_WRAPDATA on page 1 100 Sets the local tab width for listings Starts wrapping opcodes that don t fit listing column LONG on page 1 101 Supports four byte data initializer lists for GNU compatibility NOTE Blackfin processors only ESSAGE on page 1 102 Alters the severity of an error warning or informational mes sage generated by the assembler EWPAGE on page 1 106 Inserts a page break in a listing NOCOMPRESS on page 1 107 Terminates compression NOTE ADSP 2146x SHARC processors only VisualDSP 5 0 Assembler and Preprocessor Manual 1 69 Assembler Syntax Reference Table 1 17 Assembler Directive Summary Cont d Directive Description NOLIST on page 1 94 Stops listing of source lines NOLIST_DATA on page 1 95 Stops listing of data opcodes NOLIST_DATFILE on page 1 96 Stops listing of data initialization files NOLIST_WRAPDATA on page 1 100 Stops wrapping opcodes that do not fit listing column PAGELENGTH on page 1 108
81. Object files produced by the processor assembler may be used as input to the linker and archiver You can archive the output of an assembly process into a library file d1b which can then be linked with other objects into an executable Use the linker to combine separately assembled object files and objects from library files to produce an executable file For more information about the linker and archiver refer to the VisualDSP 5 0 Linker and Utilities Manual A binary object file doj and an optional listing 1st file are final results of the successful assembly The assembler listing file is a text file read for information on the results of the assembly process The listing file also provides information about the imported C data structures The listing file tells which imports were used within the program followed by a more detailed section See the 1 4 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Data initialization file DAT Assembly source file ASP Preprocessor Intermediate preprocessed file 1S Assembler Header file H Object file OBJ Listing file LST Figure 1 1 Assembler Input and Output Files IMPORT directive on page 1 90 The file shows the name total size and layout with offset for the members The information appears at the end of the listing You must specify the 1 switch on page 1 159 to produce a listing file
82. P VTIMEROLP VTIMERLHP VTIMERILP LBUFRXO LBUFRX1 LBUFRX2 LBUFRX3 LBUFTXO LBUFTX1 LBUFTX2 LBUFTX3 LCO LCI KB2 KB3 LCTLO LCTLI LCTL2 LCTL3 LRCTLO LRCTLI LRCTL2 LRCTL3 LRSTATO LRSTATI LRSTAT2 LRSTAT3 VisualDSP 5 0 Assembler and Preprocessor Manual 1 47 Assembler Syntax Reference Table 1 11 TigerSHARC Processor Assembler Keywords Cont d LRSTATCO LRSTATC1 LRSTATC2 LRSTATC3 LSTATO LSTAT LSTAT2 LSTAT3 LSTATCO LSTATC1 LSTATC2 LSTATC3 LTCTLO LTCTL LTCTL2 LTCTL3 LTSTATO LTSTAT1 LTSTAT2 LTSTAT3 LTSTATCO LTSTATC1 LTSTATC2 LTSTATC3 ISRO ISR1 ISR2 SRCTL RETI RETIB RETS RTI OSPID PMASKH PMASKL PRF PRFCNT RETAIN_NAME SERIAL_H SERIAL_L SFREG SQCTL SQCTLST SQCTLCL SQSTAT TESTMODES TIMEROL TIMERIL TIMEROH TIMERIH TMRINOL TMRINOH TMRINIL TMRINIH TRCB TRCBMAS TRCBPTR TRCBVAL VIRPT WPOCTL WPICTL WP2CTL WPOSTAT WPISTAT WP2STAT WOH WOL W1H WIL W2H W2L Conditions which may be prefixed with X Y XY NX NY and XY AEQ ALE ALT MEQ MLE MLT SEQ SF1 SFO SLT Conditions which may be prefixed with J K NJ and NK EQ LE LT CBQ CB1 Conditions which may be prefixed with N ISFO ISF1 LCOE LC1E B FLAGO_IN FLAGI_IN FLAG2_IN FLAG3_IN 1 48 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Extend these sets of keywords with symbols that declare sections variables constants and addr
83. PAGE OCOMPRESS OLIST_DATA NOLIST_DATFILE NOLIST_WRAPDATA PAGELENGTH PAGEWIDTH PRECISION ROUND MINUS ROUND_NEAREST ROUND_PLUS ROUND_ZERO PREVIOUS SECTION STRUCT VAR EAK ABS ACS ACT ADDRESS AND ASHIFT ASTAT AV BO B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B12 B13 B14 B15 BB BCLR BF BIT BITREV BM BSET BTGL BTSTS BY CA CACHE CALL CH c CJUMP CL CLIP COMP COPYSIGN cos CURLCNTR VisualDSP 5 0 Assembler and Preprocessor Manual 1 41 Assembler Syntax Reference Table 1 10 SHARC Processor Assembler Keywords Cont d DADDR DB DEC DEF DIM D DMALE DMA1S DMAZE DMA2S DMADR DMABANK1 DMABANK2 DMABANK3 DMAWAIT D0 DOVL EB ECE EF ELSE EMUCLK UCLK2 EMUIDLE UN DEF EOS EQ EX EXP EXP2 z 5 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 FADDR FDEP FEXT FILE FIX FLAGO_IN FLAGI_IN FLAG2_IN FLAG3_IN FLOAT FLUSH FMERG FOREVER FPACK FRACTIONAL FTA FTB FTC FUNPACK GCC_COMPILED GE GT 0 2 13 14 5 6 7 18 19 10 1 12 113 114 15 DLEI15 DLE16 IF IMASK MASKP NC RPTL JUMP LO L1 L2 L3 L4 L5 L6 L7 L8 L9 10 11 L12 L13 L14 15 LA LADDR LCE LCNTR LE LADDR LCE LCNTR LE 15 LA LADDR LCE LCNTR 1 42 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 10 SHARC Processor Assembler Keywords Cont d
84. Preprocessor Manual 2 21 Preprocessor Command Reference Options in VisualDSP on page 1 170 for the Assemble page For more information see the VisualDSP User s Guide and Visu alDSP online Help Preprocessor Command Reference This section provides reference information about the processor s prepro cessor commands and operators used in source code including their syntax and usage examples It provides the summary and descriptions of all preprocessor commands and operators The preprocessor reads code from a source file asm or 1df modifies it according to preprocessor commands and generates an altered prepro cessed source file The preprocessed source file is an input file for the assembler or linker it is purged when a binary object file doj is created Preprocessor command syntax must conform to these rules e Must be the first non whitespace character on its line e Cannot be more than one line in length unless the backslash character is inserted e Cannot come from a macro expansion The preprocessor operators are defined as special operators when used in a define command Preprocessor Commands and Operators Table 2 5 lists preprocessor commands Table 2 6 lists preprocessor operators Sections that begin on page 2 24 describe each of the prepro cessor commands and operators 2 22 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor Table 2 5 Preprocessor Command Summary
85. SECTION directive or end of file Table 1 4 lists the sections in the source program Table 1 4 Sections in Source Programs Section Blackfin SHARC TigerSHARC Data Section datal seg_dmda datal Variables and buffers are declared and can be constdata data2 initialized Program Section seg_rth seg_pmco program Data instructions and possibly other types of program statements are in this section including state ments that are needed for conditional assembly Figure 1 2 Figure 1 3 on page 1 14 and Figure 1 4 on page 1 17 describe assembly code file structure for each processor family They show how a program divides into sections that match the memory segmentation VisualDSP 5 0 Assembler and Preprocessor Manual 1 9 Assembler Guide of a DSP system Notice that an assembly source may contain preproces sor commands such as include to include other files in source code ifdef for conditional assembly or define to define macros The SECTIONS commands define the SECTION placements in the system s physical memory as defined by the linker s MEMORY command Assembler directives such as VAR or BYTE for Blackfin processors appear within sections to declare and initialize variables Code File Structure for SHARC Processors Figure 1 2 describes assembly code file structure for SHARC processors Looking at Figure 1 2 notice that the PRECISION and ROUND_ZERO directives inform the
86. SHARC preprocessors 2 18 for TigerSHARC processors 2 20 preprocessor operator 2 25 preprocessor operators generate unique label 2 43 concatenate 2 42 stringization 2 40 variable length argument list 2 25 PREVIOUS assembler directive 1 115 proc target processor assembler switch 1 164 programs assembling 1 4 content 1 6 listing files 1 34 preprocessing 1 24 structure 1 7 writing in assembly 1 4 project settings assembler 1 170 preprocessor 1 24 2 21 Q qualifiers 1 58 1 102 VisualDSP 5 0 Assembler and Preprocessor Manual 1 9 INDEX question mark preprocessor operator 2 43 R R32 qualifier 1 58 relational expressions 1 61 operators 1 52 RESOLVE command in LDF 1 135 rounding modes 1 119 ROUND_MINUS rounding mode assembler directive 1 119 ROUND_NEAREST rounding mode assembler directive 1 119 ROUND_PLUS rounding mode assembler directive 1 119 ROUND_ZERO rounding mode assembler directive 1 119 RUNTIME_INIT section qualifier 1 126 S save temps save intermediate files assembler switch 1 165 searching system include files 2 52 section name symbol 1 122 qualifier DM data memory 1 125 qualifier NW normal word memory 1 125 qualifier PM code and data 1 125 qualifier RAM random access memory 1 125 qualifier SW short word memory 1 125 type identifier 1 123 SECTION start or embed a sectio
87. SPBLACKFIN _ macro 1 26 2 16 __ADSPLPBLACKFIN__ macro 1 26 __ADSPTS101__ macro 1 30 2 20 __ADSPTS201__ macro 1 30 2 20 __ADSPTS202__ macro 1 30 2 20 __ADSPTS203__ macro 1 30 2 20 __ADSPTS20x__ macro 1 30 __ADSPTS__ macro 1 30 2 20 ALIGN address alignment assembler directive 1 72 align branch lines assembler switch 1 149 ALIGN_CODE code address alignment assembler directive 1 74 anomaly detect assembler switch 1 149 1 162 anomaly warn assembler switch 1 149 anomaly workaround assembler switch 1 150 arithmetic fractional 1 59 mixed fractional 1 59 ASCII string directive 1 67 1 76 string initialization 1 79 1 116 1 138 asm files 1 3 assembler overview 1 3 Blackfin feature macros 1 25 command line syntax 1 142 debugging syntax errors 2 13 directive syntax 1 6 1 67 expressions constant and address 1 50 file extensions 1 143 instruction set 1 6 keywords 1 38 numeric bases 1 56 operators 1 52 producing code for specified processor 1 164 program content 1 6 running from command line 1 142 run time environment 1 2 setting options 1 141 1 170 SHARC feature macros 1 25 source files asm 1 4 special operators 1 52 symbols 1 49 TigerSHARC feature macros 1 25 I 2 VisualDSP 5 0 Assembler and Preprocessor Manual assembler directives ALIGN 1 72 ALIGN_CODE 1 74 ASCII 1 76 BSS 1 67 BYTE BYTE2 BYTE4 1 77 COMPRESS 1 81 conditional
88. The default branch p switch makes branch instructions JUMP CALL use the branch target buffer BTB This is the default behavior It is still possible to make branch instructions not use the BTB when default branch p is used by adding the NP instruction option for example JUMP label NP This switch is used with TigerSHARC processors only Dmacro definition The D define macro switch directs the assembler to define a macro and pass it to the preprocessor See Using Assembler Feature Macros on page 1 25 for the list of predefined macros For example Dinput defines input as 1 Dsamples 10 defines samples as 10 Dpoint Start defines point as the string Start double size 32 The double size 32 switch directs the assembler to add DOUBLE32 to SECTIONs in the source file that do not have double size qualifiers For SECTIONs in the source file that already have a double size qualifier this option is ignored and a warning is produced For more information see SECTION Declare a Memory Section on page 1 122 1 152 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler double size 64 The double size 64 switch directs the assembler to add DOUBLE64 to SECTIONs in the source file that do not have double size qualifiers For SECTIONs in the source file that already have a double size qualifier this option is ignored and a warning is produced The double size any fl
89. VAR four 1 0r generates an error VAR orange VAR five 1 0r generates a warning The POP qualifier changes the severity of the messages back to previous severities Example for TigerSsHARC Processors MESSAGE INFO 3012 SECTION program RET D3 generates an informational MESSAGE ERROR 3012 RETIS generates an error MESSAGE INFO 3012 RETI generates an informational MESSAGE POP 3012 RET Isi generates an error 2nd directive MESSAGE POP 3012 RETI generates an informational 1st directive MESSAGE POP 3012 RETI 23 generates a warning the default for this message The DEFAULT qualifier is used to redefine the default severity for messages It can be placed anywhere in a source file It only takes affect when the message severity has not been changed by a MESSAGE directive 1 104 VisualDSP 5 0 Assembler and Preprocessor Manual Example for TigerSHARC Processors MESSAGE DEFAULT ERROR 1177 MESSAGE DEFAULT INFO 1177 SECTION program VAR one 1 0r MESSAGE ERROR 1177 VAR two 1 0r MESSAGE RESTORE 1177 VAR three 1 0r MESSAGE RESTORE_CL 1177 VAR four 1 0r gen gen gen gen Assembler erates an informational erates an error erates an informational erates a warning The Werror number number Wwarn number number Wno info or Wsuppress number number assembler switches
90. __ADSP21267__ macro 1 28 2 19 __ADSP21362__ macro 1 29 2 19 __ADSP21363__ macro 1 29 2 19 __ADSP21364__ macro 1 29 2 19 __ADSP21365__ macro 1 29 2 19 __ADSP21366__ macro 1 29 2 19 __ADSP21367__ macro 1 29 2 19 __ADSP21368__ macro 1 29 2 19 __ADSP21369__ macro 1 29 2 19 __ADSP21371__ macro 1 29 2 20 __ADSP21375__ macro 1 29 2 20 __ADSP2137x__ macro 1 29 2 19 __ADSP21462__ macro 1 29 2 20 __ADSP21465__ macro 1 29 2 20 __ADSP21467__ macro 1 29 2 20 __ADSP21469__ macro 1 30 2 20 __ADSPBF512__ macro 1 26 2 16 __ADSPBF514__ macro 1 26 2 16 __ADSPBF516__ macro 1 26 2 16 __ADSPBF51x__ macro 1 26 2 16 __ADSPBF522__ macro 1 26 2 17 __ADSPBF523__ macro 1 26 2 17 __ADSPBF524 __ macro 1 26 2 17 __ADSPBF525__ macro 1 26 2 17 __ADSPBF526__ macro 1 27 2 17 __ADSPBF527__ macro 1 27 2 17 VisualDSP 5 0 Assembler and Preprocessor Manual I 1 INDEX __ADSPBF52x__ macro 1 26 2 16 __ADSPBF531__ macro 1 27 2 17 __ADSPBF532__ macro 1 27 2 17 __ADSPBF533__ macro 1 27 2 17 __ADSPBF534__ macro 1 27 2 17 __ADSPBF535__ macro 1 27 2 17 __ADSPBF536__ macro 1 27 2 17 __ADSPBF537__ macro 1 27 2 17 __ADSPBF538__ macro 1 27 2 17 __ADSPBF539__ macro 1 27 2 17 __ADSPBF542___ macro 1 27 2 17 __ADSPBF544__ macro 1 27 2 18 __ADSPBF547__ macro 1 27 2 18 __ADSPBF548___ macro 1 27 2 18 __ADSPBF549__ macro 1 28 2 18 __ADSPBF54x__ macro 1 26 2 16 __ADSPBF561__ macro 1 28 2 18 __AD
91. ab width only affects the current source file Syntax LIST_DEFTAB expression where expression evaluates to an integer greater than or equal to 0 In the absence of a LIST_DEFTAB directive the default tab width defaults to 4 A value of 0 sets the default tab width Example Tabs here are expanded to the default of 4 columns LIST_DEFTAB 8 Tabs here are expanded to 8 columns LIST_LOCTAB 2 Tabs here are expanded to 2 columns But tabs in include_1l h will be expanded to 8 columns d include include_1 h LIST_DEFTAB 4 Tabs here are still expanded to 2 columns VisualDSP 5 0 Assembler and Preprocessor Manual 1 97 Assembler Syntax Reference But tabs in include_2 h will be expanded to 4 columns d include include_2 h 1 98 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler LIST LOCTAB Set the Local Tab Width for Listings Tab characters in source files are expanded to blanks in listing files under the control of two internal assembler parameters that set the tab expansion width The default tab width is normally in control but it can be overrid den if the local tab width is explicitly set with a directive The LIST_LOCTAB directive sets the local tab width and the LIST_DEFTAB directive sets the default tab width see on page 1 97 Both the default tab width and the local tab width can be changed any number of times via the LIST_DEFTAB and
92. able 1 25 A detailed description of each assembler switch starts on page 1 149 Table 1 25 Assembler Command Line Switch Summary Switch Name Purpose align branch lines Aligns branch lines to avoid ADSP TS101 processor on page 1 149 sequencer anomaly NOTE TigerSHARC processors only anomaly detect id1L id2 Issues a warning or an error for an anomaly id on page 1 149 anomaly warn Checks assembly instructions against hardware anoma id1L id2 al1 none lies on page 1 149 NOTE Blackfin processors only anomaly workaround id1 id2 Implements a workaround for an anomaly id sd on page 1 150 1 144 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 25 Assembler Command Line Switch Summary Contd Switch Name Purpose char size 8 on page 1 151 Adds CHAR8 to SECTIONs in the source file NOTE TigerSHARC processors only char size 32 on page 1 151 Adds CHAR32 to SECTIONs in the source file NOTE TigerSHARC processors only char size any on page 1 151 Adds CHARANY to SECTIONs in the source file NOTE TigerSHARC processors only default branch np on page 1 151 default branch p on page 1 152 Makes branch lines default to NP to avoid ADSP TS101 processor sequencer anomaly NOTE TigerSHARC processors only Makes branch lines default to the Branch Target Buffer BTB NOTE TigerSHARC pr
93. ag should be used to avoid a linker warning when compiling C C sources with double size 64 Warning Example Warning 112151 Input sections have inconsistent qualifiers as follows For more information see SECTION Declare a Memory Section on page 1 122 double size any The double size any switch directs the assembler to add DOUBLEANY to SECTIONs in the source file that do not have double size qualifiers making SECTION contents independent of size of double type For SECTIONs in the source file that already have a double size qualifier this option is ignored and a warning is produced For more information see SECTION Declare a Memory Section on page 1 122 expand symbolic links The expand symbolic links switch directs the assembler to correctly access directories and files whose name or path contain Cygwin path components VisualDSP 5 0 Assembler and Preprocessor Manual 1 153 Assembler Command Line Reference expand windows shortc uts The expand windows shortcuts switch directs the assembler to correctly access directories and files whose name or path contain Windows shortcuts file attr ath val The file attr file attribute switch directs the assembler to add an attribute attr to the object file The attribute will be given the value val or 1 if the value is omitted Attr should follow the rules for naming symbols Val should be double quoted unless it follows the rules
94. ample long file name e Append the appropriate file name extension to each file Table 1 24 summarizes file extension conventions accepted by the VisualDSP environment Table 1 24 File Name Extension Conventions Extension File Description asm Assembly source file Note The assembler treats files with unrecognized or not existing extensions as assembly source files is Preprocessed assembly source file wh Header file lst Listing file doj Assembled object file in ELF DWARF 2 format dat Data initialization file Assembler command line switches are case sensitive For example the following command line easmblkfn proc ADSP BF535 1 pList lst Dmax 100 v o bin p1 doj pl asm VisualDSP 5 0 Assembler and Preprocessor Manual 1 143 Assembler Command Line Reference runs the assembler with proc ADSP BF535 specifies assembles instructions unique to ADSP BF535 processors 1 pList 1st directs the assembler to output the listing file Dmax 100 defines the preprocessor macro max to be 100 v displays verbose information on each phase of the assembly o bin p1 doj specifies the name and directory for the assembled object file pl asm identifies the assembly source file to assemble Assembler Command Line Switch Desc riptions This section describes the assembler command line switches in ASCII col lation order A summary of the assembler switches appears in T
95. as the source language the architecture and the specific processor These feature macros allow programmers to use prepro cessor conditional commands to configure the source for assembly based on the context Table 1 5 lists the set of feature macros for Blackfin processors Table 1 6 on page 1 28 lists the set of feature macros for SHARC processors Table 1 7 on page 1 30 lists the set of feature macros for TigerS HARC processors VisualDSP 5 0 Assembler and Preprocessor Manual 1 25 Assembler Guide Table 1 5 Feature Macros for Blackfin Processors D_LANGUAGE_ASM 1 Always present D__ADSPBLACKFIN__ 1 Always present D__ADSPLPBLACKFIN__ 1 Always present for non ADSP BF535 processors D__ADSPBF51x__ 1 Present when running easmb proc ADSP BF512 easmbl kfn proc ADSP BF514 easmblkfn proc ADSP BF516 D__ADSPBF52x__ 1 Present when running easmblkfn proc ADSP BF522 easmb proc ADSP BF523 easmb proc ADSP BF524 easmb proc ADSP BF525 easmb proc ADSP BF526 easmb proc ADSP BF527 D__ADSPBF54x__ 1 Present when running easmblkfn proc ADSP BF542 easmb proc ADSP BF544 easmblkfn proc ADSP BF547 easmblkfn proc ADSP BF548 easmb proc ADSP BF549 D__ADSPBF512_ Present when running easmblkfn proc ADSP BF512 with the ADSP BF512 processor D__ADSPBF514_ Present when running eas blkfn proc ADSP BF514 with the ADSP BF514 processor D__ADSPBF516__ Present whe
96. assembler not to expand directories or files whose name or path contain Windows shortcuts no temp data file The no temp data file switch directs the assembler not to write temporary data to a memory disk As part of a space saving measure the assembler stores all data declarations into a file This is to allow large sources to assemble more quickly by free ing valuable memory resources By default the temporary data files are stored into the system temporary folder for example C Documents and Settings User Local Settings Temp and is given the prefix Easmb1lkfnNode These files are removed by the assembler but if for any reason the assembler does not complete these files will not be deleted and persist in the temporary folder These files can always be safely deleted in such circumstances after the assembler has stopped This command line option allows the user to turn off this default feature When turned off all data is stored into internal memory and not written to the disk nomal word code or nwc The normal word code or nwc switch directs the assembler to encode input sections bearing the PM qualifier see Table 1 20 for execution from normal word memory The switch is used with the ADSP 2146x SHARC processors only VisualDSP 5 0 Assembler and Preprocessor Manual 1 163 Assembler Command Line Reference o filename The o filename output file switch directs the assembler to use the specif
97. asses each comma separated option to the preprocessor Use flags pp with caution For example if pp legacy comment syntax is enabled the comment characters become unavailable for non comment syntax g The g generate debug information switch directs the assembler to generate complete data type information for arrays functions and the C structs This switch also generates DWARF2 function information with starting and ending ranges based on the myFunc myFunc end label boundaries as well as line number and symbol information in DWARF2 binary format allowing you to debug the assembly source files When the assembler s g switch is in effect the assembler produces a warning when it is unable to match a end label to a matching beginning label This feature can be disabled using the Wnumber number switch see on page 1 168 1 156 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler WARNING ea1121 Missing End Labels Warning eal121 occurs on assembly file debug builds using the g switch when a globally defined function or label for a data object is missing its corresponding ending label with the naming convention label end For example Warning eall21 gfxeng_thickarc asm 42 _gfxeng_thickarc g assembly with global function without ending label Use _gfxeng_thickarc end or _gfxeng_thickarc END to mark the ending boundary of the function for debugging information for automated st
98. at contains only the INPUT_SECTIONS command for input sections defining the symbol Symbols with assigned priority are mapped after absolutely placed symbols but before symbols without assigned priority The symbols are placed into memory segments based on the order that the segments are appear in the 1df file Therefore an output section target ing a higher priority memory segment should appear before an output section targeting a lower priority segment Example of Assembler Code section program funcl fFunc2 section Ll_code JIT fune PRIORITY _L1_func 10 PRIORITY _funcl 11 PRIORITY _func2 12 1 116 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Example of LDF Code LILA INPUT_SECTIONS OBJECTS L1_code gt L1_A LILA INPUT_SECTIONS OBJECTS L1_code program gt L1_B L2 INPUT_SECTIONS OBJECTS program gt L2 The preceding two examples result in the linker executing the following three steps 1 Because _func2 is assigned the highest priority 12 in the assem bler code the linker first tries to map it into the L1_B memory segment If _func2 does not fit into L1_B it tries the L2 segment 2 Because _funcl is assigned the middle priority 11 in the assem bler code the linker first tries to map it into the L1_B memory segment If _func2 does not fit into L1_B it tries the L2 segment 3 Because _L1_func is assigned the lowest p
99. atistical profiling of assembly functions The ending label marks the boundary of the end of a function Compiled code automatically provides ending labels Hand written assembly code needs to have the ending labels explicitly added to tell the tool chain where the ending boundary is This information is used to automate statistical profiling of assembly functions It is also needed by the linker to eliminate unused functions and other features To suppress a specific assembler warning by unique warning number the assembler provides the following option Wsuppress 1121 It is highly recommended that warning ea1121 not be suppressed and the code be updated to have ending labels Functions Code _gfxeng_vertspan Le spl tps rts VisualDSP 5 0 Assembler and Preprocessor Manual 1 157 Assembler Command Line Reference Add an ending label after rts Use the prefix end and begin the label with to have it treated as an internal label that is not displayed in the debugger global _gfxeng_vertspan _gfxeng_vertspan LSS pit ps rts _gfxeng_vertspan end h elp The h or help switch directs the assembler to output to standard output a list of command line switches with a syntax summary The idirectory or 1 switch include directory path directs the assembler to append the specified directory or a list of directories separated by semicolons to the search path for included files
100. bler For example VAR x 13 Hello world 0 VAR x Hello world 0 The trailing zero character is optional It simulates ANSI C string representation The assemblers also accept ASCII characters within comments Note special characters handling VAR s1 lst line 13 10 2nd line 13 10 0 carriage return VAR s2 say hello 13 10 0 quotation mark VAR s3 say 39 hello 39 13 10 0 simple quotation marks VisualDSP 5 0 Assembler and Preprocessor Manual 1 139 Assembler Syntax Reference WEAK Support Weak Symbol Definition and Reference The WEAK directive supports weak binding for a symbol Use this directive where the symbol is defined replacing the GLOBAL directive to make a weak definition and the EXTERN directive to make a weak reference Syntax WEAK symbol where symbol the user defined symbol Although the linker generates an error if two objects define global symbols with identical names it allows any number of instances of weak defini tions of a name All will resolve to the first or to a single global definition of a symbol One difference between EXTERN and WEAK references is that the linker does not extract objects from archives to satisfy weak references Such references left unresolved have the value 0 The WEAK or GLOBAL scope directive is required to make symbols available for placement through RESOLVE commands
101. bler and Preprocessor Manual 1 161 Assembler Command Line Reference no anomaly detect id1 id2 The no anomaly detect switch directs the assembler to switch off any check for a specific anomaly ID in the assembler No assembler warning or error will be issued when the assembler encounters assembly code that the anomaly will have an impact upon This option overrules any default behavior for the anomaly The switch parameter is id anomaly identifier for example 05 00 0245 or 05000245 A warning may be issued if the assembler always implements a workaround for the anomaly instead of a check no anomaly workaround id 1 id2 The no anomaly workaround switch directs the assembler to switch off any workaround for a specific anomaly id in the assembler The assembler will not alter the user assembly code so that it cannot encounter the anomaly This option overrules any default behavior for the anomaly The switch parameter is id anomaly identifier for example 05 00 0245 or 05000245 A warning may be issued if the assembler always checks for the anomaly and has no workaround no expand symbolic links The no expand symbolic links switch directs the assembler not to expand any directories or files whose name or path contain Cygwin path components 1 162 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler no expand windows shortc uts The no expand windows shortcuts switch directs the
102. bler and Preprocessor Manual 2 19 Preprocessor Guide Table 2 3 SHARC Feature Preprocessor Macros Cont d Macro Definition __ADSP21371__ Present when running easm21K proc ADSP 21371 with the ADSP 21371 processor __ADSP21375__ Present when running easm21K proc ADSP 21375 with the ADSP 21375 processor __2146x__ Present when used with the ASDP 2146x processors 214xx__ __ADSP21462__ Present when running easm21K proc ADSP 21462 with the ADSP 21462 processor __ADSP21465__ Present when running easm21K proc ADSP 21465 with the ADSP 21465 processor __ADSP21467__ Present when running easm21K proc ADSP 21467 with the ADSP 21467 processor __ADSP21469__ Present when running easm21K proc ADSP 21469 with the ADSP 21469 processor Table 2 4 TigerSHARC Feature Preprocessor Macros Macro Definition __ADSPTS__ Always 1 for the TigerSHARC processor tools __ADSPTS101__ Equal 1 when used with the ASDP TS101 processor __ADSPTS201__ Equal 1 when used with the ASDP TS201 processor __ADSPTS202__ Equal 1 when used with the ASDP TS202 processor __ADSPTS203__ Equal 1 when used with the ASDP TS203 processor 2 20 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor D__VISUALDSPVERSION_____ Predefined Macro Preproces sor The macro applies to all Analog Devices processors The D__VISUALDSPVERSION__ predefined macro provid
103. bout conditional stalls only default stallcheck al Displays all stall information swc exclude namel name2 The swc exclude name switch directs the assembler to exclude the named input section s from the effect of the short word code swe switch The switch is used with the ADSP 2146x SHARC processors only v erbose The v or verbose switch directs the assembler to display version and command line information for each phase of assembly version The version display version switch directs the assembler to display version information for the assembler and preprocessor programs W The w disable all warnings switch directs the assembler not to display warning messages generated during assembly VisualDSP 5 0 Assembler and Preprocessor Manual 1 167 Assembler Command Line Reference Wenrror number number The Werror number switch turns the specified assembler messages into errors For example Werror 1177 turns warning message ea1177 into an error This switch optionally accepts a list such as number Many error messages cannot be altered in severity as the assembler behavior is unknown Winfo number number The Winfo number switch turns the specified assembler messages into informational messages For example Winfo 1177 turns warning message eal177 into an informational message This switch optionally accepts a list such as number Many error m
104. by e Including system header files and user defined header files e Defining macros and symbolic constants e Providing conditional assembly Specify preprocessing options with preprocessor commands lines that start with a character In the absence of commands the preprocessor performs these three global substitutions e Replaces comments with single spaces e Deletes line continuation characters e Replaces macro references with corresponding expansions The following cases are notable exceptions to the described substitutions e The preprocessor does not recognize comments or macros within the file name delimiters of an include command e The preprocessor does not recognize comments or predefined macros within a character or string constant Header Files and include Command Header h files contain lines of source code to be included textually inserted into another source file Typically header files contain declara tions and macro definitions 2 4 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor The include preprocessor command includes a copy of the header file at the location of the command There are three forms for the include command as described next System Header Files Syntax include lt filename gt The file name is placed between a pair of angle bracket characters The file name in this form is interpreted as a system header file These files are used to declare global definiti
105. cessing continues with MM See M for more information Mo filename The Mo switch specifies the name of the make dependencies file output make rule that the preprocessor generates when using the M or MM switch The switch overrides default of make dependencies to stdout VisualDSP 5 0 Assembler and Preprocessor Manual 2 53 Preprocessor Command Line Reference Mt filename The Mt switch specifies the name of the target file output make rule for the named source for which the preprocessor generates the make rule using the M or MM switch The Mt fileneme switch overrides the default filename is file See M for more information o filename The o switch directs the preprocessor to use output the specified filename argument for the preprocessed assembly file The preprocessor directs the output to stdout when no o option is specified stringize The stringize switch enables the preprocessor stringization operator By default this switch is off When set this switch turns on the preproces sor stringization functionality see Argument which by default is turned off to avoid possible undesired stringization For example there is a conflict between the stringization operator and the assembler s boolean constant format in the following macro definition i fdefine bool_const b 00000001 tokenize dot The tokenize dot switch parses identifiers using C language rules instead of assembler rules wi
106. cessor Manual 1 39 Assembler Syntax Reference Table 1 9 Blackfin Processor Assembler Keywords Contd ONES OR OUTC PO P1 P2 P3 P4 P5 PACK PC PERCENT PLUS PM PREFETCH PRNT R RO R1 R2 R3 R32 R4 R5 R6 R7 RAISE RBRACE RBRACK RETI RETN RETS RETX RND RND12 RND20 RNDH RNDL ROL ROR ROT ROT_L_AC ROT_R_AC RPAREN RSDL RTE RT RT RTS RTX RUNTIME_INIT R1_COLONO RETAIN_NAME S S2RND SAA SAA1H SAALL SAA2H SAA2L SAA3H SAA3L SAT SCO SEARCH SHT_TYPE SIGN SIGNBITS SLASH SLEEP SKPF SKPT SP Ss SSF SSF_RND_HI SSF_TRUNC SSF_TRUNC_HI SSF_RND SSF_TRUNC SSYN STI STRUCT STT_TYPE su SYSCFG T TESTSET TFU TH TL TST UNLINK UNLNK UNRAISE uu V VIT_MAX W W32 WEAK X XB XH XOR Z ZERO_INIT 1 40 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 9 Blackfin Processor Assembler Keywords Cont d _ADI_ _DATE_ _FILE_ _LastSuffix_ LINE_ _TIME_ Table 1 10 SHARC Processor Assembler Keywords ADI __DATE__ FILE __LastSuffix__ LINE ORMAL_WORD_CODE SHORT_WORD_CODE TIME ALIGN COMPRESS ELIF ELSE ENDIF EXTER FILE FILE_ATTR FORCECOMPRESS GLOBAL F PORT LEFTMARGIN LIST LIST_DATA LIST_DATFILE LIST_DEFTAB LIST_LOCTAB LIST_WRAPDATA NEW
107. cessor Manual 1 77 Assembler Syntax Reference If the file name is not found in the current directory the assembler looks in the directories in the processor include path You may use the I switch see on page 1 158 to add a directory to the processor include path Initializing from files is useful for loading buffers with data such as filter coefficients or FFT phase rotation factors that are generated by other programs The assembler determines how the values are stored in memory when it reads the data files Ellipsis represents a comma delimited list of parameters initExpressions parameters sets initial values for variables and buffer elements The optional 7ength parameter defines the length of the associated buffer in words The number of initialization elements defines Jength of an implicit size buffer The brackets that enclose the optional 7ength are required For more information see the following BYTE examples In addition use a R32 qualifier BYTE4 R32 to support 32 bit initialization for use with 1 31 fracts see on page 1 57 The following lines of code demonstrate BYTE directives Bufferl TYPE Bufferl STT_OBJECT BYTE 5 65 73 initialize three 8 bit memory locations for data label Bufferl Bufferl end BYTE samples 123 124 125 126 127 declare an implicit length buffer and initialize it with five 1 byte constants BYTE4 R32 points 1 01r 1 02r 1
108. ct Support in Assembly Built In Functions on page 1 63 e The conditional assembly directives are processed by the assembler in a later pass Therefore you are able to write a relational or logical expression whose value depends on the value of a define For example IF tryit lt some code gt ELIF tryit gt 3 lt some more code gt ELSE lt some more code gt ENDIF If you have define tryit 2 the code lt some code gt is assembled and lt some more code gt is not assembled e There are no parallel assembler directives for C style directives define include ifdef if defined name ifndef and so on 1 62 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler C Struct Support in Assembly Built In Functions The assemblers support built in functions that enable you to pass infor mation obtained from the imported C struct layouts The assemblers currently support two built in functions OFFSETOF and SIZEOF OFFSETOF Built In Function The OFFSETOF built in function is used to calculate the offset of a specified member from the beginning of its parent data structure OFFSETOF struct typedef memberName where struct typedef a struct VAR or a typedef can be supplied as the first argument memberName a member name within the struct or typedef second argument For SHARC and TigerSHARC processors OF FSETOF units are in words For Blackfin processors OFFSETOF
109. d accepts in symbol names For example the following command sequence define VAR my_var VAR x does not cause any change to the variable declaration The text VAR is treated as a single identifier which does not match the macro name VAR b The standard C preprocessor treats VAR as two tokens and VAR and makes the following substitution my_var x The assembler preprocessor also produces assembly style strings single quote delimiters instead of C style strings Finally under command line switch control the assembler preprocessor supports legacy assembler commenting formats and Writing Preprocessor Commands Preprocessor commands begin with a pound sign and end with a car riage return The pound sign must be the first non white space character on the line containing the command If the command is longer than one line use a backslash and a carriage return to continue the command on the next line Do not place any characters between the backslash and the carriage return Unlike assembly directives preprocessor commands are case sensitive and must be lowercase For more information on preprocessor commands see Preprocessor Command Line Reference on page 2 45 VisualDSP 5 0 Assembler and Preprocessor Manual 2 3 Preprocessor Guide For example d Finclude string h ifdefine MAXIMUM 100 When the preprocessor runs it modifies the source code
110. d windows shortcuts aos cess acuccascceseensecpnacaecaatnens 1 163 po temp datatile cactsiudcaiacheirinaatntleatewienentuaanindetentl 1 163 normal word code Of NWC sssssessssssesssseesssserresssseresssesee 1 163 AS EE ar eases 1 164 a ESEE EA E E EN E IA T A 1 164 OC PIOREO ea hina ees 1 164 EEE a E AAA 1 165 short word code OF WC airieiiprndseniidikeki ait R 1 165 EN ISON VETSIOD arinnar eee ARS 1 165 BE oenina E 1 166 alle he nan N 1 166 swc exclude namel mame2 ccccsssccccssssesceceessscceeees 1 167 EE ORO saa S E nite 1 167 EUS nisbatini kaiaa eiiiai 1 167 E E E E E E N E E E T 1 167 Werror numberLnumber cscsccsisccceanieeaineuwinwin 1 168 Winfo number number eeccssseesssssssssssssssresssseressrrersese 1 168 O r A 1 168 Waumber AIPA EE scedoscdwaidichsewasevdsecsuaseiecasqendesudousbsionose 1 168 Wsuppress namberhnumber ssrsisiarsakikirscnira 1 169 Wwarn mum ber tM BEE ssicsciascseeciceweverienessuvoeeessesiaccdoes 1 169 VisualDSP 5 0 Assembler and Preprocessor Manual ix CONTENTS PW WEAPON secs crenata 1 169 Specifying Assembler Options in VisualDSP 0 1 170 PREPROCESSOR Preprosta ot AdE r 2 2 Writing Preprocessor Commands srrniesnsinsrirarnnereernni 2 3 Header Files and inclide Command a ceseasecssacsecrcucecseorerouncaenss 2 4 System Header Files sscsonensnranssnriranaani as 2 5 User Header Files scsiciceictivisateicadiuicinnncaimeisiseiauseiaduaeeianiels 2 5 peence of TOIS paran ee 2 6
111. de and interrupt service routines seg_Swco A section in short word memory that holds instructions encoded for execution from short word memory NOTE Applies to the ADSP 2146x processors only Table 1 2 Suggested Input Section Names for a TigerSHARC ldf File SECTION Name Description datal A section that holds data in memory block M1 data2 A section that holds data in memory block M2 specified with the PM memory qualifier program A section that holds code 1 8 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 3 Suggested Input Section Names for a Blackfin ldf File SECTION Name Description datal A section that holds data program A section that holds code constdata A section that holds global data which is declared as constant and literal constants such as strings and array initializers Use sections in a program to group elements to meet hardware constraints For example the ADSP BF535 processor has a separate program and data memory in Level 1 memory only Level 2 memory and external memory are not separated into instruction and data memory To group the code that resides in off chip memory declare a section for that code and place that section in the selected memory with the linker The example assembly program defines three sections Each section begins with a SECTION directive and ends with the occurrence of the next
112. defines a type referenced in headerfile2 h an attempt to import the second file into assembly will fail One solution is to have the assembler call the compiler once for the set of import statements The compiler then has all the information it needs when processing the second header file In other words create a third file to be imported in place of headerfile2 h This file would simply consist of these lines include headerfilel h include headerfile2 h 1 90 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler The IMPORT directive does not allocate space for a variable of this type Allocating space requires the STRUCT directive see on page 1 130 The assembler takes advantage of knowing the struct layouts The assem bly programmer may reference struct data members by name in assembler source as one would do in C The assembler calculates the offsets within the structure based on the size and sequence of the data members If the structure layout changes the assembly code need not change It just needs to get the new layout from the header file via the compiler Make dependencies track the IMPORT header files and know when a rebuild is needed Use the flags compiler assembler switch on page 1 154 to pass options to the C compiler for IMPORT header file compilations An IMPORT directive with one or more EXTERN directives allows code in the module to refer to a struct variable that was declared and ini
113. der and the name of the assembly source file easm21K L switchl switch2 sourceFile easmts L switchl switch2 sourceFile easmb1 kf switchl switch2 sourceFile Table 1 23 explains these arguments Table 1 23 Assembler Command Line Arguments Argument Description easm21K Name of the assembler program for SHARC TigerSHARC and Blackfin pro easmts cessors respectively easmbl kfn switch Switch or switches to process The command line interface offers many optional switches that select operations and modes for the assembler and pre processor Some assembler switches take a file name as a required parameter sourceFile Name of the source file to assemble The name of the source file to assemble can be provided as e ShortFileName a file name without quotes no special characters e LongFileName a quoted file name may include spaces and other special path name characters The assembler outputs a list of command line options when run without arguments same as h elp 1 142 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler The assembler supports relative path names and absolute path names When you specify an input or output file name as a parameter follow these guidelines for naming files e Include the drive letter and path string if the file is not in the current project directory e Enclose long file names in double quotation marks for ex
114. directive 1 128 error error message preprocessor command 2 30 expand symbolic links assembler switch 1 153 expand windows shortucts assembler switch 1 154 expressions 1 51 EXTERN global label assembler directive 1 82 EXTERN STRUCT assembler directive 1 83 F feature macros See assembler and preprocessor macros FILE_ATTR assembler directive 1 86 file attr file attribute assembler switch 1 154 file format ELF Executable and Linkable Format 1 3 __ FILE _ macro 2 16 FILE override filename assembler directive 1 85 files asm assembly source 1 3 dat data 1 3 dlb library 1 4 doj object 1 3 h header 1 3 is preprocessed assembly 1 164 2 13 list of extensions 1 143 naming conventions 1 143 flags compiler assembler switch 1 154 flags pp assembler switch 1 156 floating point data 1 112 1 119 FORCECOMPRESS assembler directive 1 87 formats numeric 1 56 four byte data initializer lists 1 69 fractional data type arithmetic 1 59 fracts 1 0r special case 1 59 1 15 format 1 58 1 31 format 1 58 constants 1 57 mixed type arithmetic 1 59 signed values 1 57 g generate debug info assembler switch 1 156 GLOBAL global symbol assembler directive 1 68 1 88 global symbols 1 88 H hardware anomalies warnings 1 149 1 150 header files h extension source files 1 3 system 2 5 tokens 2 6 user 2 5 hex value decoding 1 31
115. e Oct 02 2000 _LANGUAGE_ASM Always set to 1 _LANGUAGE_C Equals 1 when used for C compiler calls to specify IMPORT headers Replaces _LANGUAGE_ASM Table 2 2 Blackfin Feature Preprocessor Macros Macro Definition __ADSPBLACKFIN__ Always 1 for Blackfin processor tools __ADSPBF51x__ Present when running easmb1kfn with the ADSP BF5 1x pro cessors __ADSPBF52x__ Present when running easmb1kfn with the ADSP BF52x pro cessors __ADSPBF54x__ Present when running easmb1kfn with the ADSP BF54x pro cessors __ADSPBF512___ Present when running easmblkfn proc ADSP BF512 with the ADSP BF512 processor __ADSPBF514___ Present when running easmblkfn proc ADSP BF514 with the ADSP BF514 processor __ADSPBF516__ Present when running easmblkfn proc ADSP BF516 with the ADSP BF516 processor 2 16 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor Table 2 2 Blackfin Feature Preprocessor Macros Contd Macro Definition __ADSPBF522___ Present when running easmblkfn proc ADSP BF522 with the ADSP BF522 processor __ADSPBF523___ Present when running easmblkfn proc ADSP BF523 with the ADSP BF523 processor __ADSPBF524___ Present when running easmblkfn proc ADSP BF524 with the ADSP BF524 processor __ADSPBF525___ Present when running easmblkfn proc ADSP BF525 with the A
116. e File Stucture for Blackfin Processors Figure 1 4 describes the Blackfin processor s assembly code file structure and shows how a program divides into sections that match the memory segmentation of Blackfin processors Data Section Assembler Directive Data Section Assembler Directive Preprocessor Commands for Conditional Assembly Code program Section Assembler Label Assembly Instructions Assembler Label RB SECTION constdata p VAR buffer1 6 buffer1 dat _ SECTION data1 p VAR buffer2 0x100 ifdef INCLUDE_BUFFER3 VAR buffer3 0x100 endif gt SECTION program global my_function my_function m PO RO lo R1 Pt 19 RO 0 R1 P0 R2 10 LSETUP begin_loop end_loop LCO P1 begin_loop R1 R2 R2 l0 end_loop RO RO R1 NS II R1 P0 Il NOP R1 R2 RO RO R1 my_function end Figure 1 4 Assembly Source File Structure for Blackfin Processors VisualDSP 5 0 Assembler and Preprocessor Manual 1 17 Assembler Guide You can use sections in a program to group elements to meet hardware constraints For example the ADSP BF535 processor has a separate pro gram and data memory in Level 1 memory only Level 2 memory and external memory are not separated into instruction and data memory LDF for Blac kfin Processors Listing 1 3 on page 1 18 shows a sample user defined linker
117. e is assembled using the anomaly warn a11 selection This will cause the assembler to issue a warning for all anomalies it knows about To date this includes the following anomaly IDs 05000165 05000209 05000227 05000244 05000245 F3F008 F3F013 F3FO21 Any combination of these warning IDs can be used as part of the command line option This switch is used with Blackfin processors only anomaly workaround id The anomaly workaround switch directs the assembler to switch on any workaround instruction for a specific hardware anomaly Switch parame ter is id anomaly identifier for example 05 00 0245 or 05000245 The workaround may result in an assembler altering the user assembly code so that it cannot encounter the anomaly The assembler may issue a warning to indicate that it has altered the user assembly code This option overrules any default behavior for the anomaly A warning may be issued if the assembler always checks for the anomaly and has no workaround 1 150 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler char size 8 The char size 8 switch directs the assembler to add CHAR8 to SECTIONs in the source file that do not have char size qualifiers For SECTIONs in the source file that already have a char size qualifier this option is ignored and a warning is produced For more information see SECTION Declare a Memory Section on page 1 122 This switch is used with Tige
118. e symbols do not conflict with the linker s keywords in the 1df file The linker uses sections name symbols to place code and data in the processor s memory For details see the VisualDSP 5 0 Linker and Utilities Manual Ensure that SECTION name symbols do not begin with the dot e Terminate the definition of address label symbols with a colon e The reserved word list for processors includes some keywords with commonly used spellings therefore ensure correct syntax spelling Address label symbols may appear at the beginning of an instruction line or stand alone on the preceding line The following disassociated lines of code demonstrate symbol usage BYTE2 xoperand xoperand is a 16 bit variable BYTE4 input_array 10 input_array is a 32 bit wide data buffer with 10 elements sub_routine_l sub_routine_l is a label x7 SECTION kernel kernel is a section name Xy Assembler Expressions The assembler can evaluate simple expressions in source code The assembler supports two types of expressions constant expressions and symbolic expressions 1 50 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Constant Expressions A constant expression is acceptable where a numeric value is expected in an assembly instruction or in a preprocessor command Constant expres sions contain an arithmetic or logical operation on two or more numeric constants For example 2 9e
119. ee the VisualDSP 5 0 C C Compiler and Library Manual for the appropriate target processor 1 20 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler When writing a C or C program that interfaces with assembly observe the same rules that the compiler follows as it produces code to run on the processor These rules for compiled code define the compiler s run time environment Complying with a run time environment means following rules for memory usage register usage and variable names The definition of the run time environment for the C C compiler is provided in the VisualDSP 5 0 C C Compiler and Library Manual for the appropriate target processor which also includes a series of examples to demonstrate how to mix C C and assembly code Using Assembler Support for C Structs The assembler supports C typedef struct declarations within assembly source These assembler data directives and built ins provide high level programming features with C structs in the assembler Data Directives IMPORT see on page 1 90 EXTERN STRUCT see on page 1 83 STRUCT see on page 1 130 C Struct in Assembly Built Ins OFFSETOF struct typedef field see on page 1 63 SIZEOF struct typedef see on page 1 63 Struct References struct gt field support nests see Struct References on page 1 64 For more information on C struct support refer to the flags compiler command line switch on page 1 15
120. eferences to labels in the last macro expansion The following example assumes the macro loop from the previous example Some macros for appending a suffix to a label itdefine makelab a b adHFb define Attach a b makelab a _ b define LastLabel foo Attach foo __LastSuffix__ jump back to label in the previous expansion JUMP LastLabel mylabel The above expands to the last macro expansion had a suffix of 3 JUMP mylabel_3 2 44 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor Preprocessor Command Line Reference The pp preprocessor is the first step in the process of building assembling compiling and linking your programs The pp preprocessor is run before the assembler and linker using the assembler or linker as the com mand line tool You can also run the preprocessor independently from its own command line This section contains e Running the Preprocessor e Preprocessor Command Line Switches on page 2 46 Running the Preprocessor To run the preprocessor from the command line type the name of the program followed by arguments in any order pp switchl switch2 J sourceFile Table 2 8 summarizes these arguments Table 2 8 Preprocessor Command Line Argument Summary Argument Description pp Name of the preprocessor program switch Switch or switches to process The preprocessor offers several switches that are used to s
121. elect its operation and modes Some preprocessor switches take a file name as a required parameter sourceFile Name of the source file to process The preprocessor supports relative path names and absolute path names The pp exe outputs a list of command line switches when runs without this argument VisualDSP 5 0 Assembler and Preprocessor Manual 2 45 Preprocessor Command Line Reference For example the following command line pp Dfilter_taps 100 v o bin pl is pl asm runs the preprocessor with Dfilter_taps 100 defines the macro filter_taps as equal to 100 v displays verbose information for each phase of the preprocessing 0 bin pl is specifies the name and directory for the intermediate preprocessed file pl asm specifies the assembly source file to preprocess Most switches without arguments can be negated by prefixing no to the switch For example nowarn turns off warning 9 messages and nocs turns off omitting style comments Preprocessor Command Line Switches The preprocessor is controlled through the switches or VisualDSP options of other development tools such as the compiler assembler and linker Note that the preprocessor pp exe can operate independently from the command line with its own command line switches Table 2 9 lists pp exe switches A detailed description of each switch appears beginning on page 2 48 Table 2 9 Preprocessor C
122. emp data file Suppresses writing temporary data to a disk file on page 1 163 NOTE Blackfin processors only no source dependency Suppresses output of the source filename in the depen on page 1 161 dency output produced when M or MM has been specified normal word code Encodes input sections bearing the PM qualifier nwc see Table 1 20 for execution from normal word mem on page 1 163 ory NOTE ADSP 2146x processors only o filename Outputs the named object binary file on page 1 164 pp Runs the preprocessor only does not assemble on page 1 164 proc processor Specifies a target processor for which the assembler on page 1 164 should produce suitable code save temps Saves intermediate files on page 1 165 short word code Encodes input sections bearing the PM qualifier SWC see Table 1 20 for execution from short word memory on page 1 165 NOTE ADSP 2146x processors only si revision version Specifies silicon revision of the specified processor on page 1 165 Sp Assembles without preprocessing on page 1 166 stallcheck none cond al1 Displays stall information on page 1 166 e none no messages e cond conditional stalls only default e all all stall information NOTE Blackfin processors only VisualDSP 5 0 Assembler and Preprocessor Manual 1 147 Assembler Command Line Reference Table 1 25 Assembler Command Line Swi
123. en you use the 1 switch Syntax PAGEWIDTH expression where expression evaluates to an integer Depending on setting of the LEFTMARGIN directive this integer should be at least equal to e LEFTMARGIN value plus 46 for Blackfin processors e LEFTMARGIN value plus 49 for TigersHARC processors e LEFTMARGIN value plus about 66 for SHARC processors You cannot set this integer to less than 46 49 or 66 respectively There is no upper limit If LEFTMARGIN O and the PAGEWIDTH value is not specified the actual page width is set to any number over 46 49 or 66 respectively To change the number of characters per line in the entire listing place the PAGEWIDTH directive at the beginning of the assembly source file VisualDSP 5 0 Assembler and Preprocessor Manual 1 109 Assembler Syntax Reference Example PAGEWIDTH 72 starts a new line after 72 characters are printed on one line assuming the LEFTMARGIN setting is 0 You can set the page width only once per source file If the assembler encounters multiple occurrences of the directive it ignores all of them except the last directive 1 110 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler PORT Legacy Directive Used with SHARC processors only The PORT legacy directive assigns port name symbols to I O ports Port name symbols are global symbols that correspond to memory mapped I O ports defined in the 1df f
124. ence UIST_DATFILE NOLIST DATFILE Listing Data Initialization Files The LIST_DATFILE NOLIST_DATFILE directives off by default turn the listing of data initialization files on and off Nested source files inherit the current setting of this directive pair but a change to the setting made in a nested source file will not affect the parent source file The LIST_DATFILE NOLIST_DATFILE directives do not take any qualifiers or arguments Syntax LIST_DATFILE NOLIST_DATFILE These directives can appear multiple times anywhere in a source file and their effect depends on their location in the source file They are used in assembly source files but not in data initialization files 1 96 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler LIST_ DEFTAB Set the Default Tab Width for Listings Tab characters in source files are expanded to blanks in listing files under the control of two internal assembler parameters that set the tab expansion width The default tab width is normally in control but it can be overrid den if the local tab width is explicitly set with a directive The LIST_DEFTAB directive sets the default tab width and the LIST_LOCTAB directive sets the local tab width see on page 1 99 Both the default tab width and the local tab width can be changed any number of times via the LIST_DEFTAB and LIST_LOCTAB directives The default tab width is inherited by nested source files but the local t
125. er preprocessor command 2 36 Linker Description Files ldf 1 7 1 8 LIST assembler directive 1 94 LIST_DATA assembler directive 1 95 LIST_DATFILE assembler directive 1 96 LIST_DEFTAB assembler directive 1 97 listing files data initialization 1 96 lst extension 1 4 1 34 named 1 159 opcodes 1 95 1 100 producing 1 4 LIST_LOCTAB assembler directive 1 99 LIST_WRAPDATA assembler directive 1 100 l named listing file assembler switch 1 159 LO assembler operator 1 53 local symbols 1 88 local tab width 1 97 1 99 LONG assembler directives 1 101 long form initialization 1 131 M macro argument converting into string constant 2 40 VisualDSP 5 0 Assembler and Preprocessor Manual 1 7 INDEX macros Blackfin assembler 1 25 debugging 2 13 defining 2 7 2 9 2 24 2 25 expansion 1 25 2 6 predefined by preprocessor 2 15 SHARC assembler 1 25 TigerSHARC assembler 1 25 make dependencies 1 33 1 91 meminit linker switch 1 126 memory initializer 1 126 RAM random access memory 1 125 sections declaring 1 122 types 1 7 1 125 MESSAGE assembler directive 1 102 micaswarn assembler switch 1 161 M make rule only assembler switch 1 160 preprocessor switch 2 53 MM make rule and assemble assembler switch 1 160 preprocessor switch 2 52 2 53 Mo output make rule assembler switch 1 161 preprocessor switch 2 53 Mt output make rule for named file assembler switc
126. er and Preprocessor Manual Assembler LEFTMARGIN Set the Margin Width of a Listing File The LEFTMARGIN directive sets the margin width of a listing page It specifies the number of empty spaces at the left margin of the listing file 1st which the assembler produces when you use the 1 switch In the absence of the LEFTMARGIN directive the assembler leaves no empty spaces for the left margin The assembler compares the LEFTMARGIN and PAGEWIDTH values against one another If the specified values do not allow enough room for a properly formatted listing page the assembler issues a warning and adjusts the directive that was specified last to allow an acceptable line width Syntax LEFTMARGIN expression where expression evaluates to an integer from 0 to 100 Default is 0 There fore the minimum left margin value is 0 and the maximum left margin value is 100 To change the default setting for the entire listing place the LEFTMARGIN directive at the beginning of your assembly source file Example LEFTMARGIN 9 the listing line begins at column 10 You can set the margin width only once per source file If the assembler encounters multiple occurrences of the LEFTMARGIN directive it ignores all of them except the last directive VisualDSP 5 0 Assembler and Preprocessor Manual 1 93 Assembler Syntax Reference UST NOLIST Listing Source Lines and Opcodes The LIST NOLIST directives on by defaul
127. er is optional Table 1 20 lists the SHARC specific qualifiers Table 1 20 SHARC Specific Qualifiers Memory Section Type Description PM or Code Section contains instructions and or data in 48 bit words DM or Data Section contains data in 40 bit words DATA64 Section defines data in 64 bit words DMAONLY Placement qualifier for a section to be placed in memory and accessed through DMA only The qualifier passes to the linker a request to place the section in a memory segment with the DMAONLY qualifier which applies to memory accessed through the external parallel port of the ADSP 2126x and some ADSP 2136x processors NW Placement qualifier for a normal word section Instructions will be assembled as normal 48 bit instructions and loaded into a 48 bit memory segment Unlike PM sections NW sections are always 48 bits and unaffected by the short word code or swe switch See on page 1 165 for more information Note Applicable to the ADSP 2146x processors only SW Placement qualifier for a 16 bit short word section Instructions will be assembled and loaded into a 16 bit short word memory segment Instructions will be assembled as compressed 16 or 32 bit instructions if possible See short word code or swc for more information Note Applicable to the ADSP 2146x processors only Example SECTION DM DMAONLY seg_extm VAR _external_var 100 VisualDSP 5 0 A
128. es VisualDSP product version information The macro allows a pre processing check to be placed within code It can be used to differentiate between Visu alDSP releases and updates The assemblers and linker predefine D__VISUALDSPVERSION__ in calls to the preprocessor For further information on the product version encoding including parameters and examples see D__VISUALDSPVERSION__ Pre defined Macro on page 1 31 Specifying Preprocessor Options When developing a DSP project it may be useful to modify the preprocessor s default options Because the assembler compiler and linker automatically run the preprocessor as your program is built unless you skip processing entirely these project development tools can receive input for the preprocessor program and direct its operation The way the preprocessor options are set depends on the environment used to run the project development software You can specify preprocessor options from the preprocessor s command line or via the VisualDSP environment e From the operating system command line select the preprocessor s command line switches For more information on these switches see Preprocessor Command Line Switches on page 2 46 e Inthe VisualDSP environment select the preprocessor s options in the Assemble or Link pages of the Project Options dialog box accessible from the Project menu Refer to Specifying Assembler VisualDSP 5 0 Assembler and
129. eses All evaluates first S Ones complement Tilde All Unary minus Minus Multiply Asterisk All Divide Slash Modulus Percentage Addition Plus All Subtraction Minus lt Shift left All gt gt Shift right amp Bitwise AND All Bitwise inclusive OR All A Bitwise exclusive OR TigerSHARC and SHARC amp amp Logical AND TigerSHARC only Logical OR TigerSHARC only If right shifting a negative value ones are shifted in from the MSB which preserves the sign bit The assembler also supports special operators Table 1 13 lists and describes special operators used in constant and address expressions The ADDRESS and LENGTH operators can be used with external symbols apply them to symbols that are defined in other sections as GLOBAL symbols 1 52 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 13 Special Assembler Operators Operator Usage Description ADDRESS symbol Address of symbol Note Used with SHARC and TigerSHARC assemblers only BITPOS constant Bit position Blackfin processors only HI expression LO expression LENGTH symbol symbol Extracts the most significant 16 bits of expression Extracts the least significant 16 bits of expression Note Used with the Blackfin assembler only where HI LO replaces the ADRRESS operator The expression in the HI and LO operators can be either symbolic or constant Length o
130. ess labels When defining symbols in assembly source code follow these conventions e Define symbols that are unique within the file in which they are declared If you use a symbol in more than one file use the GLOBAL assembly directive to export the symbol from the file in which it is defined Then use the EXTERN assembly directive to import the symbol into other files e Begin symbols with alphabetic characters Symbols can use alphabetic characters A Z and a z digits 0 9 and the special characters and _ as well as dot dollar sign and underscore Symbols are case sensitive so input_addr and INPUT_ADDR define unique variables The dot point or period as the first character of a symbol triggers special behavior in the VisualDSP environment A symbol with a second character Such symbols will not appear in the symbol table which is accessible in the debugger A symbol name in which the first two characters are dots will not appear even in the symbol table of the object as the first character cannot have a digit as the The compiler and run time libraries prepend _ to avoid using symbols in the user namespace that begin with an alphabetic character e Do not use a reserved keyword to define a symbol VisualDSP 5 0 Assembler and Preprocessor Manual 1 49 Assembler Syntax Reference e Match source and LDF sections symbols Ensure that SECTION nam
131. essages cannot be altered in severity as the assembler behavior is unknown Wno info The Wno info switch turns off all assembler informational messages Wnumber number The Wnumber warning suppression switch selectively disables warnings specified by one or more message numbers For example W1092 disables warning message ea1092 Optionally this switch accepts a list such as number See also g on page 1 156 1 168 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Wsuppress number number The Wsuppress number switch selectively turns off assembler messages For example Wsuppress 1177 turns off warning message eal177 Optionally this switch accepts a list such as number Many error messages cannot be altered in severity as the assembler behavior is unknown Wwam number number The Wwarn number switch turns the specified assembler messages into warnings For example Wwarn 1154 turns error message ea1154 into a warning Optionally this switch accepts a list such as number Many error messages cannot be altered in severity as the assembler behavior is unknown Wwam eror The Wwarn error switch displays all the assembler warning messages as errors VisualDSP 5 0 Assembler and Preprocessor Manual 1 169 Assembler Command Line Reference Specifying Assembler Options in VisualDSP Within the VisualDSP IDDE specify tool settings for project bui
132. essed Syntax COMPRESS VisualDSP 5 0 Assembler and Preprocessor Manual 1 81 Assembler Syntax Reference EXTERN Refer to a Globally Available Symbol The EXTERN directive allows a code module to reference global data structures symbols and so on that are declared as GLOBAL in other files For additional information see the GLOBAL directive on page 1 88 Syntax EXTERN symboINamel symboIName2 where symbo1Name the name of a global symbol to import A single EXTERN directive can reference any number of symbols on one line separated by commas Example EXTERN coeffs This code declares an external symbol to reference the global symbol coeffs declared in the example code in the GLOBAL directive description 1 82 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler EXTERN STRUCT Refer to a Struct Defined Elsewhere The EXTERN STRUCT directive allows a code module to reference a struct defined in another file Code in the assembly file can then reference the data members by name just as if they were declared locally Syntax EXTERN STRUCT typedef structvarName where typedef the type definition for a struct VAR structvarName a struct VAR name The EXTERN STRUCT directive specifies a struct symbol name declared in another file The naming conventions are the same for structs as for variables and arrays e Ifa struct was declared in a C file refer
133. evision 0 1 If silicon version none is used no errata workarounds are enabled whereas specifying silicon version any enables all errata workarounds for the target processor If the si revision switch is not used the assembler will build for the target processor s latest known silicon revision and will enable any errata workarounds appropriate for the latest silicon revision The __SILICON_REVISION__ macro is set by the assembler to two hexadecimal digits representing the major and minor numbers in the silicon revision For example 1 0 becomes 0x100 and 10 21 becomes Oxal5 If the silicon revision is set to any the _ SILICON_REVISION _ macro is set to Oxf fff If the si revision switch is set to none the assembler will not set the __SILICON_REVISION__ macro sp The sp skip preprocessing switch directs the assembler to assemble the source file into an object file without running the preprocessor When the assembler skips preprocessing no preprocessed assembly file is is created stallcheck The stallcheck option switch provides the following choices for displaying stall information This switch is used with Blackfin processors only 1 166 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 26 stallcheck Options stallcheck Option Description stal lcheck none Displays no messages for stall information stallcheck cond Displays information a
134. f defined __ADSPBF535__ VisualDSP 5 0 Assembler and Preprocessor Manual 2 31 Preprocessor Command Reference ifdef The ifdef if defined command begins an ifdef endif pair and instructs the preprocessor to test whether the macro is defined Each ifdef command must have a matching endif command Syntax ifdef macroSymbol where macroSymbol macro identifying symbol Example ifdef _ ADSPBF535__ Includes text after ifdef only when __ADSPBF535__ has been defined dfendif 2 32 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor itndef The ifndef if not defined command begins an ifndef endif pair and directs the preprocessor to test for an undefined macro The preprocessor considers a macro undefined if it has no defined value Each ifndef command must have a matching endif command Syntax dFifndef macroSymbol where macroSymbol macro identifying symbol Example ifndef _ ADSPBF535__ Includes text after ifndef only when __ADSPBF535__ is not defined dfendif VisualDSP 5 0 Assembler and Preprocessor Manual 2 33 Preprocessor Command Reference inc lude The include command directs the preprocessor to insert the text from a header file at the command location There are two types of header files system and user However the include command may be presented in three forms e iinclude lt filename gt used with system header files e
135. f symbol in number of elements in a buffer array Address pointer to symbol Blackfin Processor Example The following example demonstrates how Blackfin assembler operators are used to load the length and address information into registers define n 20 SECTION datal VAR real_data n SECTION program RO P0 LOOP loopl LCO P1 LOOP_BEGIN loop1 LOOP_END loop data section n number of input sampless code section PO L real_data PO H real_data P1 LENGTH real_data buffer s length get next sample VisualDSP 5 0 Assembler and Preprocessor Manual 1 53 Assembler Syntax Reference The code fragment above initializes PO and P1 to the base address and length respectively of the real_data buffer The loop is executed 20 times The BITPOS operator takes a bit constant with one bit set and returns the position of the bit Therefore BITP0S 0x10 would return 4 and BITPOS 0x80 would return 7 For example i tdefine DLAB 0x80 define EPS 0x10 RO DLAB EPS z cc BITSET RO BITPOS DLAB TigerSHARC Processor Example The following example demonstrates how assembler operators are used to load the length and address information into registers when setting up circular buffers in TigerSHARC processors SECTION datal Data segment VAR real_datatn n number of input samples SECTION program Code segment
136. fine symbols identifiers expressions and to describe different numeric and comment formats e Assembler Command Line Reference on page 1 141 Provides reference information on the assembler s switches and conventions The code examples in this manual have been compiled using VisualDSP 5 0 The examples compiled with other versions of VisualDSP may result in build errors or different output although the highlighted algorithms stand and should continue to stand in future releases of VisualDSP VisualDSP 5 0 Assembler and Preprocessor Manual 1 1 Assembler Guide Assembler Guide In VisualDSP 5 0 you can run the assembler drivers for each processor family from the VisualDSP integrated debugging and development environment IDDE or from an operating system command line The assembler processes assembly source data and header files to produce an object file Assembler operations depend on two types of controls assembler directives and assembler switches VisualDSP 5 0 supports the following assembler drivers e easm21k exe for SHARC processors e easmts exe for TigersHARC processors e easmbikfn exe for Blackfin processors This section describes how to develop new programs in the Analog Devices processor assembly language It provides information on how to assemble your programs from the operating system s command line Software developers using the assembler should be familiar with these topics e
137. g SECTION directive or the end of file instruction comprise the content of the section TigerSHARC and Blackfin Syntax SECTION qualifier qualifier sectionName sectionType SHARC Syntax SECTIONE TYPE qualifier sectionName sectionType All qualifiers are optional and more than one qualifier can be used Common SECTION Attributes The following are common syntax attributes used by the assembler e sectionName section name symbol which is not limited in length and is case sensitive Section names must match the corresponding input section names used by the 1af file to place the section Use the default 1df file included in the lt instal _path gt 1df subdirectory of the VisualDSP installation directory or write your own 1df file Some sections starting with names have certain meaning within the linker Do not use the dot as the initial character in sectionName 1 122 VisualDSP 5 0 Assembler and Preprocessor Manual 9S Assembler The assembler generates re locatable sections for the linker to fill in the addresses of symbols at link time The assembler implicitly prefixes the name of the section with the rela string to form a re locatable section To avoid ambiguity ensure that your section names do not begin with rela sectionType an optional ELF section type identifier The assembler uses the default SHT_PROGBITS when this identifier is absent For example
138. h 1 161 preprocessor switch 2 54 N N boundary alignment 1 137 nested struct references 1 65 NEWPAGE assembler directive 1 106 1 118 no anomaly workaround assembler switch 1 162 NOCOMPRESS assembler directive 1 107 no expand symbolic links assembler switch 1 162 no expand windows shortucts assembler switch 1 163 NO_INIT memory section 1 127 section qualifier 1 126 NOLIST assembler directive 1 94 NOLIST_DATA assembler directive 1 95 NOLIST_DATFILE assembler directive 1 96 NOLIST_WRAPDATA assembler directive 1 100 normal word code assembler switch 1 163 __ NORMAL WORD_CODE _ macro 1 30 no source dependency assembler switch 1 161 no temp data file assembler switch 1 163 nowarn preprocessor switch 2 56 numeric formats 1 56 NW 48 bit normal word section qualifier 1 125 nwc assembler switch 1 163 O object files doj extension 1 4 OFFSETOF built in function 1 63 o output assembler switch 1 164 preprocessor switch 2 54 opcodes large 1 100 P PAGELENGTH assembler directive 1 108 PAGEWIDTH assembly directive 1 109 PM 48 bit word section qualifier 1 125 PORT declare port assembler legacy directive 1 111 1 118 pp proceed with preprocessing assembler switch 1 164 pragma preprocessor command 2 37 PRECISION assembler directive 1 112 1 114 1 115 1 8 VisualDSP 5 0 Assembler and Preprocessor Manual preprocessor guide 2 1 2 2
139. h help assembler switch 1 158 2 50 1 6 VisualDSP 5 0 Assembler and Preprocessor Manual HI assembler operator 1 53 I I assembler switch see flags compiler switch IF conditional assembly directive 1 60 ifdef test if defined preprocessor command 2 32 ifndef test if not defined preprocessor command 2 33 if test if true preprocessor command 2 31 i include directory path assembler switch 1 158 preprocessor switch 2 51 I include search path assembler option 1 155 i less includes preprocessor switch 2 51 IMPORT assembler directive 1 90 header files 1 33 1 91 INC BINARY assembler directive 1 92 INCBIN assembler directive 1 69 include files system header files 2 5 user header files 2 5 include insert a file preprocessor command 2 5 2 7 2 34 initialization section qualifiers 1 126 INPUT_SECTION_ALIGN command 1 72 input section alignment instruction 1 72 intermediate source file is 1 5 I search system include files preprocessor switch 2 52 is preprocessed assembly files 1 164 2 13 K keywords assembler 1 38 INDEX L _ LANGUAGE_ASM macro 1 26 1 28 1 30 2 16 _LANGUAGE_C macro 2 16 __LASTSUFFIX__ macro 2 16 2 44 LEFTMARGIN assembler directive 1 93 legacy directives PORT 1 111 1 118 SEGMENT ENDSEG 1 128 LENGTH assembler operator 1 53 li listing with include assembler switch 1 159 __LINE__ macro 2 16 line output line numb
140. he mac statement in the following Blackfin example has a VisualDSP 5 0 Assembler and Preprocessor Manual 2 9 Preprocessor Guide define mac mrf mrf R2 R5 ssfr macro definition R2 R1 RO macro usage set parameters R5 DM I1 M0 mac Line continuation A macro definition can be split across multiple lines for readability When a macro definition is longer than one line place a backslash character at the end of each line except the last line for line continuation Incorrect define MultiLineMacro instructionl instruction2 instruction3 Notice that the backslash in the def ine line is missing Correct tdefine MultiLineMacro instructionl instruction2 instruction3 No characters are permitted on a line after a backslash A warning is generated when there is white space after what might have been intended as a line continuation For example define macrol instructionl whitespace instruction2 instruction3 Warning pp0003 header h 3 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor The backslash at the end of this line is followed by whitespace It is not a line continuation e Comments within define Use C style comments comment within multi line macros Otherwise the line continuation character will cause the next line to be concatenated to the com ment thus becoming part of the comment The preprocessor supports C
141. ialized to zero Example 4 Short Form STRUCT Directive to Initialize an Array STRUCT structWithArrays XXX 5 1 2 3 4 1 2 Example 5 Initializing a Pointer A struct may contain a pointer Initialize pointers with symbolic references EXTERN outThere VAR myStringL abcde 0 STRUCT structWithPointer PPP scalar 5 myPtrl myString myPtr2 outThere by Example 6 Initializing a Nested Structure A struct may contain a struct Use fully qualified references to initialize nested struct members The struct name is implied For example the reference scalar nestedOne gt scalar implied and nested gt scalarl nestedOne gt nested gt scalarl implied STRUCT NestedStruct nestedOne scalar 10 nested gt scalarl 5 nested gt array 0x1000 0x1010 0x1020 VisualDSP 5 0 Assembler and Preprocessor Manual 1 133 Assembler Syntax Reference TYPE Change Default Symbol Type The TYPE directive directs the assembler to change the default symbol type of an object This directive may appear in the compiler generated assembly source file s Syntax TYPE symbolName symbolType where symbo1Name the name of the object to which the symbol Type is applied symbolType an ELF symbol type sTT_ Valid ELF symbol types are listed in the ELF h header file By default a label has an STT_FUNC symbol type and a variable or buffer name defined in a sto
142. ied filename argument as the output file This switch names the output whether for conventional production of an object a preprocessed assemble produced file is or make dependency M By default the assembler uses the root input file name for the output and appends a doj extension Some examples of this switch syntax are easmblkfn proc ADSP BF535 pp o testl is test asm preprocessed output goes into testl is easmbl kfn proc ADSP BF535 o debug prog3 doj prog3 asm specify directory and filename for the object file PP The pp proceed with preprocessing only switch directs the assembler to run the preprocessor but stop without assembling the source into an object file When assembling with the pp switch the is file is the final result of the assembly By default the output file name uses the same root name as the source with the is extension proc processor The proc processor target processor switch specifies that the assembler produces code suitable for the specified processor The processor identifiers directly supported by VisualDSP 5 0 are listed in VisualDSP online Help For example easm21K proc ADSP 21161 o bin p1 doj pl asm easmts proc ADSP TS201 o bin p1 doj pl asm 1 164 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler easmblkfn proc ADSP BF533 o bin pl doj pl asm If the processor identifier is unknown to the assembler it attempts to read required switches
143. iedel ice pusssiinanipelaatisuinasmanmidandasswidial ienaa 2 48 E E E E E E T 2 49 E oa rotamer ea ine eae aime 2 49 EOI r A E EEEO E G 2 50 BE T RA EA 2 50 A UET WERA PAER A EIN BE REAA RE TE Rr A E 2 50 Dmacroleder issia ai 2 50 E E E E E 2 50 VisualDSP 5 0 Assembler and Preprocessor Manual xi CONTENTS tl econ A nme E 2 51 a E E A ENEA AEE AE A E O E E 2 51 E EE E E E EE AEEA EEA PO A E EE EEEE 2 52 T r ee ote Pea CE Mens Nene nat vee nn Cnet 2 53 USUI E E E E E E eleemaseraad 2 53 Me Die0ane sos c0 cinsisolanseten sada irn E 2 53 e anaE car N 2 54 TE a S 2 54 E A E E E E A E A E E E a a 2 54 st kenizedot sresierisiekarneni innra nnii nRa 2 54 NTN dens cokas pat caneonansedbuaene aadeeneatbebuadaeneebaialbeneardeacebanses 2 53 a e E EE EE T E E AAEE E SEET EEE A T 2 55 E E E A A E 2 55 EE A ann 2 55 a T OM S N E A EE E A T 2 56 S E E A N N E E E E E 2 56 INDEX xii VisualDSP 5 0 Assembler and Preprocessor Manual PREFACE Thank you for purchasing Analog Devices Inc development software for digital signal processing DSP applications Purpose The VisualDSP 5 0 Assembler and Preprocessor Manual contains infor mation about the assembler and preprocessor utilities for the following Analog Devices Inc processor families Blackfin ADSP BFxxx SHARC ADSP 21xxx and TigerSsHARC ADSP TSxxx processors The manual describes how to write assembly programs for these processors and provides reference
144. ile The PORT directive uses the following syntax PORT portName where portName a globally available port symbol Example PORT pl declares 1 0 port Pl PORT p2 declares I 0 port P2 To declare a port using the SHARC assembler syntax use the VAR directive for port identifying symbols and the linker description file for corresponding I O sections The linker resolves port symbols in the 1af file For more information on the linker description file see the VisualDSP 5 0 Linker and Utilities Manual VisualDSP 5 0 Assembler and Preprocessor Manual 1 111 Assembler Syntax Reference PRECISION Select Floating Point Precision Used with SHARC processors only The PRECISION directive controls how the assembler interprets float ing point numeric values in constant declarations and variable initializations To configure the floating point precision of the target processor system you must set up control registers of the chip using instructions specific to the processor core Use one of the following options PRECISION 32 PRECISION 40 where The precision of 32 or 40 default specifies the number of significant bits for floating point data The equal sign following the PRECISION keyword is optional Note that the PRECISION directive applies only to floating point data Precision of fixed point data is determined by the number of digits specified The PRECISION directive
145. ile asm DaDef is not passed to the compiler ccblkfn proc ADSP BF535 c debug types DbDef DbDefTwo 2 myHeader h See Using Assembler Feature Macros on page 1 25 for the list of predefined macros including default macros Include Options The 1 include search path options and flags compiler arguments are passed to the C compiler for each IMPORT header compilation The compiler include path is always present automatically Use the flags compiler switch to control the order that the include directories are searched The flags compiler switch attributes take precedence from the assembler s I options For example easmblkfn proc ADSP BF535 I aPath DaDef flags compiler I cPath I file asm ccblkfn proc ADSP BF535 c debug types I cPath I myHeader h VisualDSP 5 0 Assembler and Preprocessor Manual 1 155 Assembler Command Line Reference The IMPORT C header files are preprocessed by the C compiler preprocessor The struct headers are standard C headers and the standard C compiler preprocessor is needed The rest of the assembly program including its include files are processed by the assembler preprocessor Assembly programs are preprocessed using the pp preprocessor the assembler linker preprocessor as well as 1 and D options from the assembler command line However the pp call does not receive the flags compiler switch options flags pp opti opt2 The flags pp switch p
146. in a single line comment Conditional Assembly Directives Conditional assembly directives are used for evaluation of assembly time constants using relational expressions The expressions may include relational and logical operations In addition to integer arithmetic the operands may be the C structs in the SIZEOF and OFFSETOF assembly built in functions that return integers The conditional assembly directives include ams F constant relational expression e ELIF constant relational expression WEESES e ENDIF Conditional assembly blocks begin with an IF directive and end with an ENDIF directive Table 1 16 shows examples of conditional directives Optionally any number of ELIF and ELSE directive pairs may appear within a pair of IF and ENDIF directives The conditional directives are each terminated with a semi colon just like all existing assembler 1 60 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 16 Relational Operators for Conditional Assembly Operator Purpose Conditional Directive Examples Not IF 0 gt Greater than IF SIZEOF myStruct gt 16 gt Greater than or equal to IF SIZEOF myStruct gt 16 lt Less than IF SIZEOF myStruct lt 16 lt Less than or equal to IF SIZEOF myStruct lt 16 Equality IF 8 SIZEOF myStruct Not equal IF 8 SIZEOF myStr
147. ing easm2 proc ADSP 21364 D__2136x__ with the ADSP 21364 processors D__ADSP21365__ Present when running easm2 proc ADSP 21365 D__2136x__ with the ADSP 21365 processors D__ADSP21366__ Present when running easm2 proc ADSP 21366 D__2136x__ with the ADSP 21366 processors D__ADSP21367__ Present when running easm2 proc ADSP 21367 D__2136x__ with the ADSP 21367 processors D__ADSP21368_ Present when running easm2 proc ADSP 21368 D__2136x__ with the ADSP 21368 processors D__ADSP21369__ Present when running easm2 proc ADSP 21369 D__2136x__ with the ADSP 21369 processors D__ADSP2137x__ Present when running easm2 proc ADSP 2137x D__2137x__ with the ADSP 2137x processors D__ADSP21371__ Present when running easm2 proc ADSP 21371 D__2137x__ with the ADSP 21371 processors D__ADSP21375__ Present when running easm2 proc ADSP 21375 D__2137x__ with the ADSP 21375 processors D__ADSP21462_ Present when running easm2 proc ADSP 21462 D__2146x__ with the ADSP 21462 processors D__214xx__ D__ADSP21465__ 1 Present when running easm21K proc ADSP 21465 D__2146x__ with the ADSP 21465 processors D__214xx__ D__ADSP21467__ 1 Present when running easm21K proc ADSP 21467 D__2146x__ with the ADSP 21467 processors D__214xx__ VisualDSP 5 0 Assembler and Preprocessor Manual 1 29 Assembler Guide Table 1 6 Feature Macros for SHARC Processors Cont d D__ADSP21469__ 1 Present when run
148. ins For example pp Idirl Idir2 I Idir3 Idir4 myfile asm When searching for include incl h the preprocessor searches in the source directory then dirl dir2 dir3 and dir4 in that order When searching for include lt inc2 h gt the preprocessor searches for the file in dir3 and then dir4 The 1 switch marks the point where the system search path starts 2 52 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor The M switch directs the preprocessor to output a rule generate make rule only suitable for the make utility describing the dependencies of the source file The output a make dependencies list is written to stdout in the standard command line format target_file dependency_file ext where dependency_file ext may be an assembly source file or a header file included with the include preprocessor command When the o filename switch is used with M the o option is ignored To specify an alternate target name for the make dependencies use the Mt filename switch To direct the make dependencies to a file use the Mo filename switch MM The MM switch directs the preprocessor to output a rule generate make rule and preprocess suitable for the make utility describing the depen dencies of the source file The output a make dependencies list is written to stdout in the standard command line format The only difference between MM and M actions is that the prepro
149. ion of 1 0r within the 1 31 representation Fractional Arithmetic The assembler provides support for arithmetic expressions using operations on fractional constants consistent with the support for other numeric types in constant expressions as described in Assembler Expres sions on page 1 50 The internal intermediate representation for expression evaluation is a double floating point value Fract range checking is deferred until the expression is evaluated For example i tdefine fromSomewhereElse 0 875r SECTION datal VAR localOne fromSomewhereElse 0 005r Result 88r is within the legal range VAR xyz 1 5r 0 9r Result 6r is within the legal range L503 Error 1 5r out of range VAR abc Mixed Type Arithmetic The assembler does not support arithmetic between fracts and integers For example SECTION datal VAR myFract 1 0 5r Error eal998 fract asm 2 User Error Illegal mixing of types in expression VisualDSP 5 0 Assembler and Preprocessor Manual 1 59 Assembler Syntax Reference Comment Conventions The assemblers support C and C style formats for inserting comments in assembly sources The assemblers do not support nested comments Table 1 15 lists and describes assembler comment conventions Table 1 15 Comment Conventions Convention Description comment A string encloses a multiple line comment comment A pair of slashes beg
150. ire ment its value must be a power of 2 In TigerSsHARC processors the expression value is usually 4 When aligning a data item or instruction the assembler adjusts the address of the current location counter to the next address that is divisible by the value of the expression The expres sion set to 0 or 1 signifies no address alignment requirement In the absence of the ALIGN_CODE directive the default address alignment is 1 Example ALIGN_CODE 0 no alignment requirement ALIGN_CODE 1 no alignment requirement ECTION program LIGN_CODE 4 N gt 1 74 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler JUMP LABEL Jump instruction aligned to four word boundary If necessary padding will be done with NOPs VisualDSP 5 0 Assembler and Preprocessor Manual 1 75 Assembler Syntax Reference ASCII Used with Blackfin processors only The ASCII directive initializes a data location with one or more charac ters from a double quoted ASCII string This is equivalent to the BYTE directive Note that the syntax differs from the BYTE directive as follows e There is no sign e The string is enclosed in double quotes not single quotes Syntax ASCII string Example SECTION datal ASCII_String TYPE ASCII_String STT_OBJECT ASCII ABCD ASCII_String end Byte_String TYPE Byte_String STT_OBJECT Byte ABCD Byte_String end
151. ired argument to the 1i switch For more information see Reading a Listing File on page 1 34 VisualDSP 5 0 Assembler and Preprocessor Manual 1 159 Assembler Command Line Reference The M generate make rule only assembler switch directs the assembler to generate make dependency rules suitable for the make utility describing the dependencies of the source file No object file is generated for M assemblies For make dependencies with assembly use the MM switch The output an assembly make dependencies list is written to stdout in the standard command line format target_file dependency_file ext dependency_file ext may be an assembly source file a header file included with the include preprocessor command a data file or a header file imported via the IMPORT directive The Mo filename switch writes make dependencies to the filename specified instead of lt stdout gt For consistency with the compilers when o filename is used with M the assembler outputs the make dependencies list to the named file The Mo filename takes precedence if both o filename and Mo filename are present with M MM The MM generate make rule and assemble assembler switch directs the assembler to output a rule suitable for the make utility describing the dependencies of the source file The assembly of the source into an object file proceeds normally The output an assembly make dependencies list is written
152. it signed representation of all constant values Keep this in mind when working with immediate values The immediate value is used by the assembler to determine the instruction length 16 or 32 bit The assembler selects the smallest opcode that can accommodate the immediate value 1 56 VisualDSP 5 0 Assembler and Preprocessor Manual If there is no opcode that can accommodate the value semantic error ea5003 is reported Examples RO 64 LX RO OxBF RO OXxFFBF F RO OxFFFFFFBF RO 0x8000 ie 16 bit instruction 64 7 bit immedia te value 32 bit instruction 191 mediate val immediate val ediate val immediate val Fractional Type Support e ERROR 65471 doesn t fit es 32 bit instruction 65 e ERROR 32768 doesn t fit es fits into fits into into 7 or fits into into 7 or Assembler Fractional fract constants are specially marked floating point constants to be represented in fixed point format A fract constant uses the float ing point representation with a trailing r where r stands for fract 9 The legal range is 1 1 This means the values must be greater than or equal to 1 and less than 1 Fracts are represented as signed values For example VAR myFractsL 0 5r Constants are examples of legal VAR OutOfRangeFract Error Fract constant
153. ize is deter mined by the number of initializers Brackets 1 enclosing the optional 7ength is required For more information see the following VAR examples 1 136 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler initExpressions parameters set initial values for variables and buffer elements With Blackfin processors the assembler uses a R32 qualifier VAR R32 to support 32 bit initialization for use with 1 31 fracts see on page 1 57 The following code demonstrate some VAR directives VAR buf1 0x1234 Define one initialized variable VAR 0x1234 0x5678 Define two initialized words VAR samples 10 11 12 13 14 Declare and initialize an implicit length buffer since there are five values this has the same effect as samples 5 Initialization values for implicit size buffer must be in curly brackets VAR Ins Outs Remains Declare three uninitialized variables VAR samples 100 inits dat Declare a 100 location buffer and initialize it with the contents of the inits dat file VAR taps 100 Declare a variable and initialize the variable to 100 VAR twiddles 10 phase dat Declare a 10 location buffer and load the buffer with the contents of the phase dat file VAR Fract_Var_R32 0 fr32FormatFract dat All Blackfin processor memory accesses require proper alignment Therefore when loading or storing
154. laces the macro with the code xr0 j31 0x3F j31 0xCO xr0 Vaniable Length Argument Definitions A macro can also be defined with a variable length argument list by means of the operator define test a lt definition gt For example the code above defines a macro named test which takes two or more arguments It is invoked like any other macro although the number of arguments can vary For example in the macro definition the __VA_ARGS__ identifier is available to take on the value of all of the trailing arguments including the commas all of which are merged to form a single item See Table 2 7 VisualDSP 5 0 Assembler and Preprocessor Manual 2 25 Preprocessor Command Reference Table 2 7 Sample Variable Length Argument List Sample Argument List Description test 1 Error the macro must have at least one more argument than formal parameters not counting test 1 2 Valid entry test 1 2 3 4 5 Valid entry For example the following code Fdefine test a bar a testbar __VA_ARGS__ expands into test 1 2 gt bar 1 testbar 2 test 1 2 3 4 5 gt bar 1 testbar 2 3 4 5 2 26 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor elif The elif command else if is used within an if endif pair The e1if includes an alternative condition to test when the initial if condition evaluates as FALSE The prepr
155. lds Use the Project menu to open the Project Options dialog box Figure 1 5 shows an example of the Project page of the Project Options dialog box showing selections for a Blackfin processors Project Options for dot_product_asm x Eh General Its Project fy Language Settings Target tists Processor Z Revision Automatic gt Eh Preprocessor E Processor 1 Type Executable file z Th Processor 2 E Profile guided Optimization Name dot_product_asm E Warning fy Assemble ifaw ees I fig Link jez General Compiler C C Compiler for Blackfin z ee LDF Preprocessing E Elimination Assembler Blackfin Family Assembler E Processor ce Blackfin Faiy tiker i fel Load Linker Blackfin Family Linker Gh Options Loader Blackfin Family Loader Eh Compression Eh Kernel Splitter z fA Splitter Th Pre build i eae Co Fay Post build Settings for configuration Debug fal Add Startup Code LDF X Cancel Figure 1 5 Example Project Options Dialog Box Project Page This dialog box allows you to select the target processor type and name of the executable file as well as VisualDSP tools available for use with the selected processor 1 170 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler When using the VisualDSP IDDE use the Assemble page of the Project Options dialog box Figure 1 6 to select and or set assembler functional options Project Options
156. lp system and a technical library CD Analog Devices Web Site The Analog Devices Web site www analog com provides information about a broad range of products analog integrated circuits amplifiers converters and digital signal processors To access a complete technical library for each processor family go to http www analog com processors technical_library The manuals selection opens a list of current manuals related to the product as well as a link to the previous revisions of the manuals When locating your manual title note a possible errata check mark next to the title that leads to the current correction report against the manual xvi VisualDSP 5 0 Assembler and Preprocessor Manual Preface Also note MyAnalog com is a free feature of the Analog Devices Web site that allows customization of a Web page to display only the latest infor mation about products you are interested in You can choose to receive weekly e mail notifications containing updates to the Web pages that meet your interests including documentation errata against all manuals MyAn alog com provides access to books application notes data sheets code examples and more Visit MyAnalog com to sign up If you are a registered user just log on Your user name is your e mail address VisualIDSP Online Documentation Online documentation comprises the VisualDSP Help system software tools manuals hardware tools manuals processor manuals Di
157. lter the Severity of an Assembler Message The MESSAGE directive can be used to alter the severity of an error warning or informational message generated by the assembler for all or part of an assembly source Syntax where ESSAGE qualifier warnidl warnid2 ESSAGE qualifier warnidl warnid2 UNTIL sym ESSAGE qualifier warnidl warnid2 FOR n LINES ESSAGE DEFAULT qualifier warnidl warnid2 warnidll warnid2 is a list of one or more message identification numbers A qualifier can be ERROR change messages to errors WARN change messages to warnings INFO change messages to informational messages SUPPRESS do not output the messages RESTORE_CL change the severity of the messages back to the default values they had at the beginning of the source file after the command line arguments were processed but before any DEFAULT directives have been processed 1 102 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler e RESTORE change the severity of the messages back to the default values they had at the beginning of the source file after the com mand line arguments were processed and after any DEFAULT directives have been processed e POP change the severity of the messages back to what they were prior to the previous MESSAGE directive The RESTORE RESTORE_CL and POP qualifiers cannot be used with the UNTIL FOR or DEFAULT f
158. mands Syntax Hendi f Example if condition Hendi f The preprocessor includes text within the section only if the test is true VisualDSP 5 0 Assembler and Preprocessor Manual 2 29 Preprocessor Command Reference Herror The error command causes the preprocessor to raise an error The preprocessor uses the text following the terror command as the error message Syntax jferror messageText where messageText user defined text To break a long messageText without changing its meaning place a back slash character at the end of each line except the last line Example ifndef _ ADSPBF535_ dferror MyError Expecting a ADSP BF535 Check the Linker Description File Hendi f 2 30 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor The if command begins an if endif pair Statements inside an if endif pair can include other preprocessor commands and condi tional expressions The preprocessor processes instructions inside the Hif endif pair only when condition that follows the if evaluates as TRUE Every if command must terminated with an endif command Syntax if condition where condition expression to evaluate as TRUE nonzero or FALSE zero Example if x 100 test for TRUE condition The preprocessor includes text within the section if the test is true Hendi f More examples if x 100 amp amp y 20 i
159. mation used when building programs from a command line or from within the VisualDSP 5 0 environment Software developers who use the preprocessor should be familiar with e Writing Preprocessor Commands on page 2 3 e Header Files and include Command on page 2 4 e Writing Macros on page 2 7 e Using Predefined Preprocessor Macros on page 2 15 e Specifying Preprocessor Options on page 2 21 Compiler Preprocessor The compiler has it own preprocessor that enables the use of preprocessor commands within C C source The compiler preprocessor automati cally runs before the compiler This preprocessor is separate from the assembler preprocessor and has some features that may not be used within your assembly source files For more information refer to the Visu alDSP C C Compiler and Library Manual for the target processor Assembler Preprocessor The assembler preprocessor differs from the ANSI C standard preproces sor in several ways First the assembler preprocessor supports a operator see on page 2 43 that directs the preprocessor to generate a unique label for each macro expansion Second the assembler preproces 9 sor does not treat as a separate token Instead is always treated as 2 2 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor part of an identifier This behavior matches the assembler s behavior which uses to start directives an
160. mbler linker preprocessor processes macros in assembly source files and linker description files 1df Macros provide for text substitution The term macro defines a macro identifying symbol and its corresponding definition that the preprocessor uses to substitute the macro reference s VisualDSP 5 0 Assembler and Preprocessor Manual 2 7 Preprocessor Guide For example use macros to define symbolic constants or to manipulate register bit masks in an assembly program based on a macro argument as follows Define a symbolic constant d fdefine MAX_INPUT 256 Mask peripheral x interrupt tdefine SIC_MASK x 1 lt lt x amp 0X1F Macros can be defined to repeat code sequences in assembly source code When you pass parameters to a code macro the macro serves as a general purpose routine that is usable in many different programs The block of instructions that the preprocessor substitutes can vary with each new set of arguments A macro differs from a subroutine call During assembly each instance of a macro inserts a copy of the same block of instructions so multiple copies of that code appear in different locations in the object code By comparison a subroutine appears only once in the object code and the block of instructions at that location are executed for every call For more information see define on page 2 24 e Macro Definition and Usage Guidelines on page 2 9 e Examples of
161. meter Description MM VersionMajor The major release number for example 4 in release 4 5 mm VersionMinor The minor release number for example 5 in release 4 5 UU VersionPatch The number of the release update for example 6 in release 4 5 update 6 xx Reserved for future use always 00 initially version In the Error Check example below the D__VISUALDSPVERSION__ Oxffffffff string is displayed as part of an error message when the version information is unable to be encoded Code Example Legacy dif defined __VISUALDSPVERSION__ dtwarning Building with VisualDSP 4 5 Update 5 or prior No __VISUALDSPVERSION__ available Hendi f Code Example VisualDSP 4 5 Update 6 or Later if __VISUALDSPVERSION__ gt 0x04050600 warning Building with VisualDSP 4 5 Update 6 or later endif Code Example Error Check if __VISUALDSPVERSION__ Oxffffffff dferror Unexpected build problems unknown VisualDSP Version Hendi f Code Fxamples Assembly if __VISUALDSPVERSION__ 0x05000000 Building with VisualDSP 5 0 VAR VersionBuildString Building with VisualDSP 5 0 1 32 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler elif __VISUALDSPVERSION__ 0x04050600 Building with VisualDSP 4 5 Update 6 VAR VersionBuildStringL Building with VisualDSP 4 5 Update Te else Building with unknown VisualDSP version VAR VersionBuildString
162. n assembler directive 1 122 initialization qualifiers 1 126 SEGMENT legacy directive assembler directive 1 128 SSEPARATE_MEM_SEGMENTS assembler directive 1 128 1 129 SET assembler directive 1 71 SHF_ALLOC flag 1 127 SHF_INIT flag 1 127 SHORT assembler directives 1 129 SHORT EXPRESSION LIST assembler directive 1 71 short form initialization 1 131 short word code assembler switch 1 165 1 167 __ SHORT_WORD_CODE __ macro 1 30 SHT_DEBUGINFO section type 1 123 SHT_NULL section type 1 123 SHT_PROGBITS identifier 1 123 memory section 1 127 SHT_PROGBITS section type 1 123 __SILICON_REVISION__ macro 1 166 si revision silicon revision assembler switch 1 166 SIZEOF built in function 1 63 source files asm 1 4 special characters dot 1 49 special operators assembler 1 52 sp skip preprocessing assembler switch 1 166 stallcheck assembler switch 1 166 stall information 1 166 statistical profiling enabling in assembler source 1 35 string initialization 1 79 1 138 stringization preprocessor operator 2 40 stringize double quotes preprocessor switch 2 54 struct layout 1 91 1 130 references 1 64 variable 1 130 STRUCT struct variable assembler directive 1 130 STT_ symbol type 1 134 SW 16 bit short word section qualifier 1 125 VisualDSP 5 0 Assembler and Preprocessor Manual swc assembler switch 1 165 1 167 switches See assembler and preprocess
163. n Attribute in the Object File 1 86 FORCECOMPRESS Compress the Next Instruction 1 87 GLOBAL Make a Symbol Available Globally 0 0 1 88 AMPORT Provide Structure Layout Information 1 90 VisualDSP 5 0 Assembler and Preprocessor Manual v CONTENTS INC BINARY Include Contents of a File 0 0 1 92 LEFTMARGIN Set the Margin Width of a Listing File 1 93 LIST NOLIST Listing Source Lines and Opcodes 1 94 LIST_DATA NOLIST_DATA Listing Data Opcodes 1 95 LIST_DATFILE NOLIST_DATFILE Listing Data Initialization Files vocassadasserdavesusesavcsndeaminenscrasuenasarinccoues 1 96 LIST_DEFTAB Set the Default Tab Width for Listings 1 97 LIST_LOCTAB Set the Local Tab Width for Listings 1 99 LIST_WRAPDATA NOLIST_WRAPDATA sscansivins 1 100 LONG Defines and initializes 4 byte data objects 1 101 MESSAGE Alter the Severity of an Assembler Message 1 102 NEWPAGE Insert a Page Break in a Listing File 1 106 ANOCOMPRESS Terminate Compression sesse 1 107 PAGELENGTH Set the Page Length of a Listing File 1 108 PAGEWIDTH Set the Page Width of a Listing File 1 109 ee Lero DIENE ponani a 1 111 PRECISION Select Floating Point Precision c 00rs 1 112 PREVIOUS Revert to the Previously Defined Section 1 114 PRIORITY Allow Prioritized Symbol Mapping in Linker 1 115 Laker nt Co eve en eee a nee ReneS enti REORINR On
164. n running eas blkfn proc ADSP BF516 with the ADSP BF516 processor D__ADSPBF522_ Present when running easmblkfn proc ADSP BF522 with the ADSP BF522 processor D__ADSPBF523_ Present when running easmblkfn proc ADSP BF523 with the ADSP BF523 processor D__ADSPBF524__ Present when running easmblkfn proc ADSP BF524 with the ADSP BF524 processor D__ADSPBF525__ Present when running easmb proc ADSP BF525 with the ADSP BF525 processor 1 26 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 5 Feature Macros for Blackfin Processors Contd D__ADSPBF526__ Present when running easmblkfn proc ADSP BF526 with the ADSP BF526 processor D__ADSPBF527__ Present when running easm fn proc ADSP BF527 with the ADSP BF527 processor D__ADSPBF531__ Present when running easm fn proc ADSP BF531 D__ADSP21531__ with the ADSP BF531 processor D__ADSPBF532_ Present when running easmblkfn proc ADSP BF532 D__ADSP21532__ with the ADSP BF532 processor D__ADSPBF533_ Present when running easmblkfn proc ADSP BF533 D__ADSP21533__ with the ADSP BF533 processor D__ADSPBF534__ Present when running easmblkfn proc ADSP BF534 with the ADSP BF534 processor D__ADSPBF535__ Present when running easm fn proc ADSP BF535 D__ADSP21535__ with the ADSP BF535 processor
165. ncludefilename the code above evaluates to include header h define preprocessor macro to build system include file fdefine syshdr name lt name 4 h gt use the preprocessor macro in a include command d Finclude syshdr adi the code above evaluates to include lt adi h gt 2 6 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor Include Path Search It is good programming practice to distinguish between system header files and user header files The only technical difference between the two different notations is the directory search order that the assembler follows to locate the specified header file For example when using Blackfin processors the include lt file gt search order is 1 The include path specified by the 1 switch 2 lt install_path gt VisualDSP Blackfin include folders The include file search order is 1 The local directory the directory in which the source file resides 2 The include path specified by the I switch 3 lt install_path gt VisualDSP Blackfin include folders If you use the 1 and the 1 switches on the command line the system search path include lt gt is modified in such a manner that search the directories specified with the I switch that appear before the directory specified with the 1 switch are ignored For syntax information and usage examples on the include preprocessor command see include Writing Macros The asse
166. ne Documentation ersorinisrassrens xvii Se Library CEY senpasa S xviii Notacon Convetion erena a xviii ASSEMBLER Asembler uide ae R A 1 2 Assembler Overview sarrsrinnseenricsisreran 1 3 Writing Assembly Programs scicsiisstisintcsiassinriaaducrneaduannes 1 4 Program Conti vsrsinseasnnieain nonan 1 6 Assembly DCLG serrenpirwosnesenoninis 1 6 VisualDSP 5 0 Assembler and Preprocessor Manual iii CONTENTS Assembler Directives corccsunnomennamnionr arana 1 6 Pieproccsot Common ciao cose tenciissercteaneseenmiiarnsceaess 1 7 TOAD YCE ennan E N 1 7 Code File Structure for SHARC Processors eesseeeeeees 1 10 LDF for SHARC Processors acremsensoirenkbiedreriieii 1 10 Code File Structure for TigerSHARC Processors 1 13 LOF for Tigers HARC Processors cciecmesnnucuseenns 1 13 Code File Structure for Blackfin Processors scccsiserseesinusees 1 17 LDF for Blackfin Processors serscceriuresrncnemiasi 1 18 Program Interfacing Requirements cicsceciseensavsirentawsiennannssncy 1 20 Using Assembler Support for C Structs ssssusnssninesasnri 1 21 Preprocessing a Progam eonreonaniiiran a 1 24 Using Assembler Feature Macros srursirsirnariecronnsasis 1 25 D__VISUALDSPVERSION __ Predefined Macro 1 31 Generating Make Dependencies asi sc cssucesssssunensensindenonsysaewionsainey 1 33 A le File settee 1 34 Enabling Statistical Profiling for Assembly Functions 1 35 Assembler Syotax CENCE soso cdercicunomineieereewes 1 37 A
167. nes csall The csa11 switch directs the preprocessor to accept comments in all formats Dmacro def The Dmacro switch directs the preprocessor to define a macro If you do not include the optional definition string def the preprocessor defines the macro as value 1 Similar to the C compiler you can use the D switch to define an assembly language constant macro Some examples of this switch are Dinput defines input as 1 Dsamples 10 defines samples as 10 Dpoint Start defines point as Start D_LANGUAGE_ASM 1 defines _LANGUAGE_ASM as 1 h elp The h or help switch directs the preprocessor to send to standard output the list of command line switches with a syntax summary 2 50 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor The i less includes switch may be used with the M or MM switches to direct the preprocessor to not output dependencies on any system files System files are any files that are brought in using include lt gt Files included using Hinclude double quote characters are included in the dependency list The idirectory or Idirectory switch direct the preprocessor to append the specified directory or a list of directories separated by semicolons to the search path for included header files see on page 2 34 No space is allowed between i and the path name The preprocessor searches for included files delimited by double q
168. ning easm21K proc ADSP 21469 D__2146x__ 1 with the ADSP 21469 processors D__ 214xx__ 1 D__NORMAL_WORD_CODE__ 1 Present when running easm2 proc ADSP 21462 easm2 proc ADSP 21465 easm2 proc ADSP 21467 easm21K proc ADSP 21469 and building in normal word mode D__SHORT_WORD_CODE__ 1 Present when running easm2 proc ADSP 21462 easm2 proc ADSP 21465 easm2 proc ADSP 21467 easm21K proc ADSP 21469 and building in short word mode Table 1 7 Feature Macros for TigersHARC Processors D_LANGUAGE_ASM Always present D__ADSPTS__ 1 Always present D__ADSPTS101__ Present when running easmts proc ADSP TS101 with the ADSP TS101 processor D__ADSPTS201__ Present when running easmts proc ADSP TS201 with the ADSP TS201 processor D__ADSPTS202__ Present when running easmts proc ADSP TS202 with the ADSP TS202 processor D__ADSPTS203__ Present when running easmts proc ADSP TS203 with the ADSP TS203 processor D__ADSPTS20x__ Present when running easmts proc ADSP TS201 with the ADSP TS201 processor easmts proc ADSP TS202 with the ADSP TS202 processor asmts proc ADSP 1S203 with the ADSP TS203 processor 1 30 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler For IMPORT headers the assembler calls the compiler driver with the appropriate processor option and the compiler sets the machine constants acc
169. nkum Abridged C library and FLEXnet License Tools documentation You can search easily across the entire VisualDSP documentation set for any topic of interest For easy printing supplementary Portable Documentation Format pdf files for all manuals are provided on the VisualDSP installation CD Each documentation file type is described as follows File Description chm Help system files and manuals in Microsoft help format htm or Dinkum Abridged C library and FLEXnet license tools software html documentation Viewing and printing the htm1 files requires a browser such as Internet Explorer 6 0 or higher pdf VisualDSP and processor manuals in PDF format Viewing and printing the pdf files requires a PDF reader such as Adobe Acrobat Reader 4 0 or higher VisualDSP 5 0 Assembler and Preprocessor Manual xvii Notation Conventions Technical Library CD The technical library CD contains seminar materials product highlights a selection guide and documentation files of processor manuals Visu alDSP software manuals and hardware tools manuals for the following processor families Blackfin SHARC TigerSsHARC ADSP 218x and ADSP 219x To order the technical library CD go to http www analog com proces sors technical_library navigate to the manuals page for your processor click the request CD check mark and fill out the order form Data sheets which can be downloaded
170. nning easm2 proc ADSP 21060 D__2106x__ with the ADSP 21060 processors D__ADSP21061_ Present when running easm2 proc ADSP 21061 D__2106x__ with the ADSP 21061 processors D__ADSP21062_ Present when running easm2 proc ADSP 21062 D__2106x__ with the ADSP 21062 processors D__ADSP21065L__ 1 Present when running easm2 proc ADSP 21065L D__2106x__ with the ADSP 21065L processors D__ADSP21160__ Present when running easm2 proc ADSP 21160 D__2116x__ with the ADSP 21160 processors D__ADSP21161__ Present when running easm2 proc ADSP 21161 D__2116x__ with the ADSP 21161 processors D__ADSP21261_ Present when running easm2 proc ADSP 21261 D__2126x__ with the ADSP 21261 processors D__ADSP21262_ Present when running easm2 proc ADSP 21262 D__2126x__ with the ADSP 21262 processors D__ADSP21266__ Present when running easm2 proc ADSP 21266 D__2126x__ with the ADSP 21266 processors D__ADSP21267__ Present when running easm2 proc ADSP 21267 D__2126x__ with the ADSP 21267 processors 1 28 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Table 1 6 Feature Macros for SHARC Processors Contd D__ADSP21362__ Present when running easm2 proc ADSP 21362 D__2136x__ with the ADSP 21362 processors D__ADSP21363_ Present when running easm2 proc ADSP 21363 D__2136x__ with the ADSP 21363 processors D__ADSP21364_ Present when runn
171. ocessor tests each e1if condition inside the pair and processes instructions that follow the first true elif There can be an unlimited number of e1if commands inside one if Fend pair Syntax elif condition where condition expression to evaluate as TRUE nonzero or FALSE zero Example qd Me ih telif X 2 The preprocessor includes text within the section and excludes all other text before else when X 2 else endif VisualDSP 5 0 Assembler and Preprocessor Manual 2 27 Preprocessor Command Reference else The else command is used within an if endif pair It adds an alternative instruction to the if endif pair Only one else com mand can be used inside the pair The preprocessor executes instructions that follow else after all the preceding conditions are evaluated as FALSE zero If no else text is specified and all preceding if and elif conditions are FALSE the preprocessor does not include any text inside the Hif endif pair Syntax else Example if X telif X else The preprocessor includes text within the section and excludes all other text before felse when x 1 and x 2 dfendif 2 28 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor endif The endif command is required to terminate if endif ifdef endif and ifndef endif pairs Ensure that the number of if commands matches the number of endif com
172. ocessors only Dmacrol definition on page 1 152 Passes macro definition to the preprocessor double size 32 on page 1 152 Adds DOUBLE32 to the SECTIONs in the source file double size 64 on page 1 153 Adds DOUBLE64 to the SECTIONs in the source file double size any on page 1 153 expand symbolic links on page 1 153 Adds DOUBLEANY to the SECTIONs in the source file Enables support for Cygwin style paths expand windows shortcuts on page 1 154 Enables support for Windows shortcuts file attr attr value on page 1 154 Creates an attribute in the generated object file flags compiler optl s on page 1 154 Passes each comma separated option to the compiler Used when compiling IMPORT C header files flags pp optl on page 1 156 Passes each comma separated option to the preprocessor VisualDSP 5 0 Assembler and Preprocessor Manual 1 145 Assembler Command Line Reference Table 1 25 Assembler Command Line Switch Summary Contd Switch Name Purpose 9g on page 1 156 Generates debug information DWARF 2 format hLelp on page 1 158 Outputs a list of assembler switches i I directory pathname on page 1 158 Searches a directory for included files filename on page 1 159 Outputs the named listing file li filename on page 1 159 M on page 1 160
173. ommand Line Switch Summary Switch Name Description cpredef Enables the stringization operator and provides on page 2 48 C compiler style preprocessor behavior 2 46 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor Table 2 9 Preprocessor Command Line Switch Summary Cont d gt cs Treats as a comment all text after on page 2 49 on a single line cs Treats as a comment all text within on page 2 49 cs Treats as acomment all text after on page 2 50 cs Treats as a comment all text within on page 2 50 csall Accepts comments in all formats on page 2 50 Dmacrol definition Defines macro on page 2 50 h elp Outputs a list of command line switches on page 2 50 i Outputs only makefile dependencies for include files speci on page 2 51 fied in double quotes i Idirectory Searches directory for included files on page 2 51 Indicates where to start searching for system include files on page 2 52 which are delimited by lt gt 7 Makes dependencies only on page 2 53 MM Makes dependencies and produces preprocessor output on page 2 53 Mo filename Specifies f7 ename for the make dependencies output file on page 2 53 Mt filename Makes dependencies for the specified source file on page 2 54 o filename Outputs named object file on page 2 54 stringize Enables st
174. on implies that DOUBLE s are not used in this section in any way that would require consistency checking with any other section TigerSHARC Specific Qualifiers In addition the TigerSsHARC specific qualifierl qualifier2 can be one of the following listed in Table 1 19 Table 1 19 TigerSHARC Specific Qualifiers CHAR8 CHAR32 CHARANY CHARS are represented as 8 bit CHARs are represented as Section does not include code types Shorts are represented 32 bit types Shorts are rep that depends on the size of as 16 bit types resented as 32 bit types CHAR The char size qualifiers are used to ensure that object files are consistent when linked together and with run time libraries A section may have a double size qualifier and a char size qualifier It cannot have two char size qualifiers Sections in the same file do not have to have the same type size qualifiers Use of CHARANY in a section implies that char and shorts are not used in this section in any way that would require consistency checking with any other section 1 124 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler SHARC Specific Qualifiers For the SHARC assembler the SECTION directive supports qualifiers that specify the size of data words in the section A qualifier can specify restricted placement for the section Each section that defines data or code must bear an appropriate size qualifier the placement qualifi
175. ons especially memory mapped registers system architecture and processors Example d Finclude lt device h gt d Finclude lt major h gt System header files are installed in the VisualDSP Blackfin include folder for the processor family User Header Files Syntax finclude filename The file name is placed within a pair of double quote characters The file name in this form is interpreted as a user header file These files contain declarations for interfaces between the source files of the program Example d Finclude defTS h d include fft_ovly h VisualDSP 5 0 Assembler and Preprocessor Manual 2 5 Preprocessor Guide Sequence of Tokens Syntax include text In this case text is a sequence of tokens subject to macro expansion by the preprocessor It is an error if after macro expansion the text does not match one of the two header file forms If the text on the line after the include is not placed between double quotes as a user header file or between angle brackets as a system header file the preprocessor performs macro expansion on the text After that expansion the line requires either of the two header file forms Unlike most preprocessor commands the text after the include is available for macro expansion Examples define preprocessor macro with name for include file i tdefine includefilename header h use the preprocessor macro in an include command include i
176. oord1 OFFSETOF Coordinate Z SHARC Example IMPORT Samples h typedef struct Samples nt II int T2 int 13 Samples SECTION DM seg_dmda STRUCT Samples Samplel I1 0x1000 I2 0x2000 13 0x3000 bs SECTION PM seg_pmco doubleMe The code may look confusing but I2 can be used both as a register and a struct member name VisualDSP 5 0 Assembler and Preprocessor Manual 1 23 Assembler Guide B2 Samplel M2 OFFSETOF Samplel 12 RO DM M2 12 RO RO RO DM M2 12 RO For better code readability avoid using STRUCT member names that have the same spelling as assembler keywords This may not always be possible if your application needs to use an existing set of C header files Preprocessing a Program The assembler includes a preprocessor that allows the use of C style preprocessor commands in your assembly source files The preprocessor automatically runs before the assembler unless you use the assembler s sp skip preprocessor switch Table 2 5 on page 2 23 lists preprocessor commands and provides a brief description of each command You can see the command line that the assembler uses to invoke the pre processor by adding the v switch on page 1 167 to the assembler command line or by selecting the Generate verbose output option on the Assemble page of the Project Options dialog box See Specifying Assem bler Options in VisualDSP on page 1
177. or switches symbol See assembler symbols assembler operator 1 53 conventions 1 49 types 1 134 symbolic alias setting 1 71 expressions 1 51 syntax assembler command line 1 142 assembler directives 1 67 constants 1 51 instruction set 1 6 macros 2 7 preprocessor commands 2 22 system header files 2 5 2 52 T tab characters in source files 1 97 1 99 width changing 1 97 width default 1 99 temporary data file not written to a memory disk 1 163 TEXT assembler directive 1 71 __ TIME _ macro 2 16 tokenize dot identifier parsing preprocessor switch 2 54 tokens macro expansion 1 25 2 6 trailing zero character 1 80 two byte data initializer lists 1 71 TYPE change default type assembler directive 1 134 INDEX U Uname undefine macro preprocessor switch 2 55 undef undefine preprocessor command 2 38 unique labels generating 2 43 user header files 2 5 V __VA_ARGS _ identifier 2 25 2 26 VAR and VAR INIT24 declare variable assembler directives 1 77 1 135 variable length argument list 2 25 version display version assembler switch 1 167 preprocessor switch 2 55 VisualDSP Assemble page 1 35 1 170 1 171 2 21 Project Options dialog box 1 35 1 37 1 170 1 171 2 21 setting assembler options 1 35 1 170 1 171 setting preprocessor options 2 21 __VISUALDSPVERSION__ macro 1 31 2 21 v verbose assembler switch 1 167 preprocessor switch 2 55 W WARN
178. ordingly and defines D_LANGUAGE_C 1 This macro is present when used for C compiler calls to specify headers It replaces D_LANGUAGE_ASM For example easm2lk proc adsp 21262 assembly gt cc21K proc adsp 21262 easmts proc ADSP TS101 assembly gt ccts proc ADSP TS101 easmblkfn proc ADSP BF535 assembly gt ccblkfn proc ADSP BF535 Use the verbose switch to verify what macro is default defined Refer to Chapter 1 in the VisualDSP 5 0 C C Compiler and Library Manual of the appropriate target processor for more information D__VISUALDSPVERSION__ Predefined Macro The macro applies to all Analog Devices processors The D__VISUALDSPVERSION__ predefined macro provides product version information to VisualDSP The macro allows a preprocessing check to be placed within code and is used to differentiate between VisualDSP releases and updates Syntax D__VISUALDSPVERSION__ OxMMmmUUxx Table 1 8 explains the macro parameters The 0xMMmmUUxx information is obtained from the lt instal _path gt Sys tem VisualDSP ini file Initially xx is set to 00 If an unexpected problem occurs while trying to locate VisualDSP ini or while extracting information from the VisualDSP ini file the __VISUALDSPVERSION__ macro is not encoded to the VisualDSP product VisualDSP 5 0 Assembler and Preprocessor Manual 1 31 Assembler Guide Table 1 8 D__VISUALDSPVERSION__ Decoding of Hex Value Para
179. orms of the MESSAGE directive The DEFAULT qualifier cannot be used with the UNTIL or FOR forms of the MESSAGE directive The simple form of the MESSAGE directive changes the severity of messages until another MESSAGE directive is seen It can be placed anywhere in a source file Messages that could not be associated with a source line can be reported with line number 0 These cannot be altered in severity by a MESSAGE directive This should be done by using the Werror Wwarn Winfo or Wsuppress assembler switches see Assem bler Command Line Switch Descriptions on page 1 144 Example ESSAGE ERROR 1049 ECTION program AR twol2 1 generates an error ESSAGE SUPPRESS 1049 AR three 3 1 2 generates no message ESSAGE WARN 1049 VAR four 4 1 2 3 generates a warning zs 2S SS The temporary forms of the MESSAGE directive UNTIL and FOR changes the severity of messages until the specified label or for the specified number of source lines The temporary forms of the MESSAGE directive must start and end within a single SECTION directive VisualDSP 5 0 Assembler and Preprocessor Manual 1 103 Assembler Syntax Reference Example for TigerSsHARC Processors ECTION program S VAR one 1 0r generates a warning MESSAGE ERROR 1177 UNTIL sym VAR two 1 0r generates an error sym VAR three 1 0r generates a warning MESSAGE ERROR 1177 FOR 3 LINES VAR apple
180. ple in Blackfin processors outer I1 RO Outer R1 0X1234 JUMP outer jumps back 2 instructions Assembler Directives Assembler directives begin with a period and end with a semicolon The assembler does not differentiate between directives in lowercase or uppercase This manual prints directives in uppercase to distinguish them from other assembly statements 1 6 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler For example Blackfin processors SECTION datal BYTE2 sqrt_coeffl2 0x5D1D OxA9ED For a complete description of the assembler s directive set see Assembler Directives on page 1 67 Preprocessor Commands Preprocessor commands begin with a pound sign and end with a carriage return The pound sign must be the first non white space character on the line containing the command If the command is longer than one line use a backslash and a carriage return to continue the command onto the next line Do not put any characters between the backslash and the carriage return Unlike assembler directives preprocessor commands are case sensitive and must be lowercase For example d include string h define MAXIMUM 100 For more information see Writing Preprocessor Commands on page 2 3 For a list of the preprocessor commands see Preprocessor Command Line Reference on page 2 45 Program Structure An assembly source file defines code instructions
181. qualifiers or arguments Syntax LIST_WRAPDATA NOLIST_WRAPDATA These directives can appear multiple times anywhere in a source file and their effect depends on their location in the source file 1 100 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler LONG Defines and initializes 4 byte data objects Used with Blackfin processors only The LONG directive declares and optionally initializes four byte data objects It is effectively equivalent to BYTE4 initExpression1 initExpression2 For more information see BYTE Declare a Byte Data Variable or Buffer on page 1 77 Syntax When declaring and or initializing memory variables or buffer elements use the following format Note that the terminating semicolon is optional LONG initExpressionl initExpression2 LONG constExpressionl constExpression2 L where 7nitExpressions parameters contain one or more comma separated symbol value expressions constExpressions parameters contain a comma separated list of con stant values The following lines of code demonstrate LONG directives Define an initialized variable LONG buf1 0x1234 Define two initialized variables LONG 0x1234 0x5678 Declare three 8 byte areas of memory initialized to 3 4 and 5 respectively LONG 0x0003 Ox0004 Ox0005 VisualDSP 5 0 Assembler and Preprocessor Manual 1 101 Assembler Syntax Reference MESSAGE A
182. r macro is limited only by the memory available during preprocessing Recursive macro expansion however is not allowed Refer to define on page 2 24 for more information on the define command Examples of Multi Line Code Macros with Arguments The following are examples of multi line code macros with arguments Blackfin Code Example define false 0 define xchg xv yv 2 12 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor PO xv Pl yv RO P0 RI P1 P1 RO POJ R1 SHARC Code Example d fdefine ccall x R2 16 I6o I7 JUMP pc x db DM 17 M7 R2 DMC 17 M7 PC Macro Usage in Code Section lt instruction code here gt ccall labell lt instruction code here gt labell NOP lt instruction code here gt TigerSHARC Code Example itdefine copy src dest JO src3 Jl dest RO J0 0 J1 0 RO Debugging Macros If you get an unexpected syntax error from the assembler on a macro expansion it can be helpful to debug the macro by looking at what the preprocessor produced post preprocessing The intermediate file produced by the preprocessor is the is output file VisualDSP 5 0 Assembler and Preprocessor Manual 2 13 Preprocessor Guide From the VisualDSP IDDE select the Save temporary files check box on the Assemble page of the Project Options dialog box If you are run ning the assembler from the command line add the sa
183. rSHARC processors only char size 32 The char size 32 switch directs the assembler to add CHAR32 to SECTIONs in the source file that do not have char size qualifiers For SECTIONs in the source file that already have a char size qualifier this option is ignored and a warning is produced For more information see SECTION Declare a Memory Section on page 1 122 This switch is used with TigerSHARC processors only char size any The char size any switch directs the assembler to add CHARANY to SECTIONs in the source file that do not have char size qualifiers For SECTIONs in the source file that already have a char size qualifier this option is ignored and a warning is produced For more information see SECTION Declare a Memory Section on page 1 122 This switch is used with TigerSsHARC processors only default branch np The default branch np branch lines default to NP switch directs the assembler to stop branch instructions JUMP CALL from using the branch target buffer BTB This can be used to avoid a sequencer anomaly VisualDSP 5 0 Assembler and Preprocessor Manual 1 151 Assembler Command Line Reference present on the ADSP TS101 processor only It is still possible to make branch instructions use the BTB when default branch np is used by adding the P instruction option for example JUMP labl P This switch is used with TigerSHARC processors only default branch p
184. rage directive has an STT_OBJECT symbol type 1 134 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler VAR Declare a Data Variable or Buffer The VAR directive declares and optionally initializes variables and data buffers A variable uses a single memory location and a data buffer uses an array of memory locations When declaring or initializing variables e A VAR directive may appear only within a section The assembler associates the variable with the memory type of the section in which the VAR appears e A single VAR directive can declare any number of variables or buffers separated by commas on one line Unless the absolute placement for a variable is specified with a RESOLVE command from an 1df file the linker places variables in consecutive memory locations For example VAR d f k 50 sequentially places symbols x y and 50 elements of the buffer z in the processor memory Therefore code example may look like VAR d VAR f VAR k 50 e The number of initializer values may not exceed the number of variables or buffer locations that you declare e The VAR directive may declare an implicit size buffer by using empty brackets The number of initialization elements defines the Jength of the implicit size buffer At runtime the length oper ator can be used to determine the buffer size For example SECTION datal VAR buffer 1 2 3 4 SECTION program LO LENGTH buffer
185. ringization includes a string in double quotes on page 2 54 VisualDSP 5 0 Assembler and Preprocessor Manual 2 47 Preprocessor Command Line Reference Table 2 9 Preprocessor Command Line Switch Summary Cont d o tokenize dot Treats on page 2 54 dot as an operator when parsing identifiers Uname Undefines a macro on the command line on page 2 55 vLerbose Displays information about each preprocessing phase on page 2 55 version Displays version information for the preprocessor on page 2 55 w Removes all preprocessor generated warnings on page 2 55 Wnumber Suppresses any report of the specified warning on page 2 56 warn Prints warning messages default on page 2 56 The following sections describe preprocessor command line switches c predef The cpredef switch directs the preprocessor to produce C compiler style strings in all cases By default the preprocessor produces assembler style strings within single quotes for example string unless the cpredef switch is used The cpredef switch sets the following C compiler style behaviors e Directs the preprocessor to use double quotation marks rather than the default single quotes as string delimiters for any preprocessor generated strings The preprocessor generates strings for predefined 2 48 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor mac
186. riority 10 in the assem bler code the linker first tries to map it into the L1_A memory segment If _L1_func does not fit into L1_A it tries the L1_B segment VisualDSP 5 0 Assembler and Preprocessor Manual 1 117 Assembler Syntax Reference REFERENCE Provide Better Info in an X REF File Used with Blackfin processors only The REFERENCE directive is used by the compiler to provide better information in an X REF file generated by the linker This directive is used when there are indirect symbol references that would otherwise not appear in an X RFF file The REFERENCE directive uses the following syntax REFERENCE symbol where symbol is a symbol Example REFERENCE P1 REFERENCE P2 RETAIN_NAME Stop Linker from Eliminating Symbol The RETAIN_NAME directive stops the linker from eliminating the symbol when linking the generated object file This directive has the same effect as the KEEP LDF command has when used with the linker Syntax The RETAIN_NAME directive uses the following syntax RETAIN_NAME symbol where symbol is a user defined symbol 1 118 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler For information on KEEP refer to the VisualDSP 5 0 Linker and Utilities Manual ROUND_ Select Floating Point Rounding Used with SHARC processors only The ROUND_ directives control how the assembler interprets literal floating point numeric data after PRE
187. rocessor Command Reference undef The undef command directs the preprocessor to undefine a macro Syntax dfFundef macroSymbol where macroSymbol macro created with the define command Example dfundef BUFFER_SIZE undefines a macro named BUFFER_SIZE 2 38 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor waming The warning command causes the preprocessor to issue a warning The preprocessor uses the text following the twarning command as the warning message Syntax warning messageText where messageText user defined text To break a long messageText without changing its meaning place a backslash character at the end of each line except the last line Example ifndef ADSPBF535_ dfwarning MyWarning Expecting a ADSPBF535 Check the Linker Description File Hendi f VisualDSP 5 0 Assembler and Preprocessor Manual 2 39 Preprocessor Command Reference Argument The argument stringization operator directs the preprocessor to con vert a macro argument into a string constant The preprocessor converts an argument into a string when macro arguments are substituted into the macro definition The preprocessor handles white space in string to literal conversions by e Ignoring leading and trailing white spaces e Converting white space in the middle of the text to a single space in the resulting string Syntax i toString where toString
188. ros that are expressed as string constants and as a result of the stringize operator in macro definitions see Table 2 1 on page 2 16 for the predefined macros e Enables the stringize operator in macro definitions By default the stringize operator is disabled to avoid conflicts with constant definitions see stringize e Parses identifiers using C language rules instead of assembler rules In C the character is an operator and is not considered part of an identifier In the assembler the is considered part of a directive or label With cpredef the preprocessor treats as an operator The following example shows the difference in effect of the two styles i tdefine end last what label end looks like with cpredef label last end parsed as ident and macro expanded what label end looks like without cpredef asm rules label end end not parsed separately cs The cs switch directs the preprocessor to treat as a comment all text after ona single line cs The cs switch directs the preprocessor to treat as a comment all text within on multiple lines VisualDSP 5 0 Assembler and Preprocessor Manual 2 49 Preprocessor Command Line Reference cs The cs switch directs the preprocessor to treat as a comment all text after on a single line cs The cs switch directs the preprocessor to treat as a comment all text within on multiple li
189. sembler can generate a warning for the VAR zz initialization SECTION NO_INIT seg_bss VAR xx 1000 VAR zz 25 Warning ea1141 example asm 3 zz 1 126 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Data directive with assembly time initializers found in SECTION seg_bss with qualifier NO_INIT Likewise the assembler generates a warning for an explicit initialization to 0 in a ZERO_INIT section SECTION ZERO_INIT seg_bsz VAR xx 1000 VAR zz 0 The assembler calculates the size of NO_INIT and ZERO_INIT sections exactly as for the standard SHT_PROGBITS sections These sections like the sections with initialized data have the SHF_ALLOC flag set Alignment sections are produced for NO_INIT and ZERO_INIT sections Table 1 22 Section Qualifiers Section Header Types and Section Header Flags SECTION Qualifier ELF SHT_ Elf h ELF SHF _ Elf h Section Header Type Section Header Flag SECTION NO_INIT SHT_NOBITS SHF_ALLOC SECTION ZERO_INIT SHT_NOBITS SHF_ALLOC SHF_INIT SECTION RUNTIME_INIT SHT_PROGBITS SHF_ALLOC SHF_INIT For more information refer to the VisualDSP 5 0 Linker and Utilities Manual VisualDSP 5 0 Assembler and Preprocessor Manual 1 127 Assembler Syntax Reference SEG MENT and ENDSEG Legacy Directives Used with SHARC processors only Releases of the ADSP 210xx DSP development software prior to VisualDSP
190. ssembler Keywords and Symbols siseinsserisisiisieenensim 1 38 PR GT Epei eana 1 50 Assembler CORN sencis en 1 51 Momen e DIAN dagina A A 1 56 Representation of Constants in Blackfin serissuirissrniriss 1 56 Fisetional Tyre att carae an 1 57 iv VisualDSP 5 0 Assembler and Preprocessor Manual CONTENTS 131 Frac berenseomsenrin ain 1 58 LEE a EE E E O E T T OET 1 59 Fracional Fa IRN asses ecadaaionntiacenenmenetmumedees 1 59 Mixed Type Arithmetic sic ceaciamneeccuneunaeseunaimanes 1 59 Comment Conycntigfs srsnerinioinieirniiakeiabieiii kitak 1 60 Conditional Assembly Directives sorusemscrsserocsnosorsorni 1 60 C Struct Support in Assembly Built In Functions 0 0 0 0 1 63 OFFSE TOF Puilt In Punci n csisiicicctretimanensecane 1 63 SIZEOF Built In Pianeta csser a 1 63 Stroe References So canccicictaded nase endear noes 1 64 Assembler Directives scirent eoin n a 1 67 ALIGN Specify an Address Alignment ceccsosisissnenas 1 72 ALIGN_CODE Specify an Address Alignment 1 74 C dct ae ar Gua eae sees 1 76 BYTE Declare a Byte Data Variable or Buffer cccccccesnecesss 1 77 ASCI String Initialization Support accasssscasmecsossrsnevtennss 1 79 A ADAP RESS Start Compression sii taiesaitenriaciassccausaeseaagens 1 81 EXTERN Refer to a Globally Available Symbol 1 82 EXTERN STRUCT Refer to a Struct Defined Elsewhere 1 83 FILE Override the Name of a Source File eeeeeeeee eee 1 85 FILE_ATTR Create a
191. ssembler and Preprocessor Manual Assembler align branch lines This switch is used with TigerSHARC processors only The align branch lines switch directs the assembler to align branch instructions JUMP CALL CJMP CUMP_CALL RETI and RTI on quad word boundaries by inserting NOP instructions prior to the branch instruction This may be done by adding NOP instructions in free slots in previous instruction lines anomaly detect id1 id2 The anomaly detect switch directs the assembler to check assembly instructions for a specific hardware anomaly Switch parameter is id anomaly identifier for example 05 00 0245 or 05000245 The check may result in an assembler warning or error when the assembler encounters assembly code on which the anomaly has an impact This option overrules any default behavior for the anomaly A warning may be issued if the assembler always implements a workaround for the anomaly instead of a check anomaly wam fid1 id2 all none The anomaly warn switch directs the assembler to check assembly instructions against hardware anomalies Switch parameters are id anomaly identifier for example 05 00 0245 or 05000245 all uses all identifiers known to the assembler none do nothing VisualDSP 5 0 Assembler and Preprocessor Manual 1 149 Assembler Command Line Reference This switch allows the user to control which anomaly warnings are to be displayed Typically cod
192. ssembler and Preprocessor Manual 1 125 Assembler Syntax Reference Initialization Section Qualifiers The SECTION directive may identify how when if a section is initialized The initialization qualifiers common for all supported assemblers are listed in Table 1 21 Table 1 21 SHARC Specific Qualifiers Qualifier Description NO_LINIT The section is sized to have enough space to contain all data elements placed in this section No data initialization is used for this memory section ZERO_INIT Similar to NO_INIT except that the memory space for this section is initial ized to zero at load time or runtime if invoked with the linker s memi nit switch If the meminit switch is not used the memory is initialized at load time when the DXE file is loaded via VisualDSP IDDE or boot loaded by the boot kernel If the memory initializer is invoked the C C run time library CRTL processes embedded information to initial ize the memory space during the CRTL initialization process RUNTIME_INIT If the memory initializer is not run this qualifier has no effect If the mem ory initializer is invoked the data for this section is set during the CRTL ini tialization process Example SECTION NO_INIT seg_bss VAR bigl0x100000 SECTION ZERO_INIT seg_bsz VAR big 0x100000 Initialized data in a NO_INIT or ZERO_INIT section is ignored For example the as
193. ssor automatically replaces each occurrence of the macro reference found throughout the program with the specified predefined value The DSP development tools also define feature macros that can be used in your code The __DATE__ __FILE__ and __TIME__ macros return strings within the single quotation marks suitable for initializing character buffers For more information see VAR and ASCII String Initialization Support on page 1 138 Table 2 1 describes the common predefined macros provided by the pre processor Table 2 2 Table 2 3 on page 2 18 and Table 2 4 on page 2 20 list processor specific feature macros that are defined by the project devel opment tools to specify the architecture and language being processed VisualDSP 5 0 Assembler and Preprocessor Manual 2 15 Preprocessor Guide Table 2 1 Common Predefined Preprocessor Macros Macro Definition AD Defines ADI as 1 __LastSuffix__ Specifies the last value of suffix that was used to build prepro cessor generated labels OLINE Replaces __LINE__ with the line number in the source file that the macro appears on PILE Defines __FILE__ as the name and extension of the file in which the macro is defined for example macro asm __TIME__ Defines __TIME__ as current time in the 24 hour format hh mm ss for example 06 54 35 __DATE__ Defines __DATE__as current date in the format mm dd yyyy for exampl
194. ssors In addition modifications and corrections based on errata reports against the previous revision of the manual have been made xiv VisualDSP 5 0 Assembler and Preprocessor Manual Preface Technical or Customer Support You can reach Analog Devices Inc Customer Support in the following ways Visit the Embedded Processing and DSP products Web site at http www analog com processors technical_support E mail tools questions to processor tools support analog con E mail processor questions to processor support analog com World wide support processor europe analog com Europe support processor china analog com China support Phone questions to 1 800 ANALOGD Contact your Analog Devices Inc local sales office or authorized distributor Send questions by mail to Analog Devices Inc One Technology Way P O Box 9106 Norwood MA 02062 9106 USA VisualDSP 5 0 Assembler and Preprocessor Manual xv Supported Processors Supported Processors The assembler and preprocessor of VisualDSP 5 0 supports the follow ing Analog Devices Inc processors e Blackfin ADSP BFxxx e SHARC ADSP 21xxx e TigerSHARC ADSP TSxxx The majority of the information in this manual applies to all processors For a complete list of processors supported by VisualDSP 5 0 refer to the online Help Product Information Product information can be obtained from the Analog Devices Web site VisualDSP online He
195. symbols on one line separated by commas Example SHARC and TigerSHARC code VAR coeffs 10 declares a buffer VAR taps 100 declares a variable 1 88 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler GLOBAL coeffs taps makes the buffer and the variable visible to other files Example Blackfin code BYTE coeffs 10 declares a buffer BYTE4 taps 100 declares a variable GLOBAL coeffs taps makes the buffer and the variable visible to other files VisualDSP 5 0 Assembler and Preprocessor Manual 1 89 Assembler Syntax Reference IMPORT Provide Structure Layout Information The IMPORT directive makes struct layouts visible inside an assembler program The IMPORT directive provides the assembler with the following structure layout information e The names of typedefs and structs available e The name of each data member e The sequence and offset of the data members e Information as provided by the C compiler for the size of C base types alternatively for the SIZEOF C base types Syntax IMPORT headerfilenamel l headerfilename2 where headerfilename one or more comma separated C header files enclosed in double quotes The system processes each IMPORT directive and each file specified in an IMPORT directive separately Therefore all type information must be available within the context for the individual file If headerfilel h
196. t turn on and off the listing of source lines and opcodes If NOLIST is in effect no lines in the current source or any nested source are listed until a LIST directive is encountered in the same source at the same nesting level The NOLIST directive operates on the next source line so that the line containing a NOLIST appears in the listing and accounts for the missing lines The LIST NOLIST directives do not take any qualifiers or arguments Syntax cS NOLIST These directives can appear multiple times anywhere in a source file and their effect depends on their location in the source file 1 94 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler LIST DATA NOLIST DATA Listing Data Opcodes The LIST_DATA NOLIST_DATA directives off by default turn the listing of data opcodes on and off When NOLIST_DATA is in effect opcodes that correspond to variable declarations do not appear in the opcode column Nested source files inherit the current setting of this directive pair but a change to the setting made in a nested source file do not affect the parent source file The LIST_DATA NOLIST_DATA directives do not take any qualifiers or arguments Syntax LIST_DATA NOLIST_DATA These directives can appear multiple times anywhere in a source file and their effect depends on their location in the source file VisualDSP 5 0 Assembler and Preprocessor Manual 1 95 Assembler Syntax Refer
197. t Location char Town 16 char State 16 struct myStructTag int fieldl struct Location NestedOne VisualDSP 5 0 Assembler and Preprocessor Manual 1 65 Assembler Syntax Reference Assembly Code for Blackfin Processors EXTERN STRUCT myStructTag _myStruct P3 L LO _myStruct gt NestedOne gt State P3 H HI _myStruct gt NestedOne gt State Example 2 Nested Reference When Nested via a Pointer with Appropriate C Declarations When nested via a pointer myStructTagWithPtr which has pNestedOne uses pointer register offset instructions C Code from C header struct Location char Town 16 char State 16 struct myStructTagWithPtr int fieldl struct Location pNestedOne bs Assembly Code for Blackfin Processors in assembly file EXTERN STRUCT myStructTagWithPtr _myStructWithPtr P1 L LO _myStructWithPtr gt pNestedOne P1 H HI _myStructWithPtr gt pNestedOne PO Pl OFFSETOF Location State 1 66 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Assembler Directives Directives in an assembly source file control the assembly process Unlike assembly instructions directives do not produce opcodes during assembly Use the following general syntax for assembler directives directive qualifiers arguments Each assembler directive starts with a period and ends with a semicolon Some directives take qualifiers and arguments A directive s
198. tch Summary Contd Switch Name Purpose swce exclude namel name2 Excludes the named section s from the effect of the on page 1 167 short word code swc switch NOTE ADSP 2146x processors only v or verbose Displays information on each assembly phase on page 1 167 version Displays version information for the assembler and pre on page 1 167 rocessor programs pag P prog w Disables all assembler generated warnings on page 1 167 Werror number number Selectively turn assembler messages into errors on page 1 168 Winfo number number Selectively turns assembler messages into informationals on page 1 168 Wno info Does not display informational assembler messages on page 1 168 Wnumber number Selectively disables warnings by one or more message on page 1 168 numbers For example W1092 disables warning message ea1092 Wsuppress number number Selectively turns off assembler messages on page 1 169 Wwarn number number Selectively turns assembler messages into warnings on page 1 169 Wwarn error Display all assembler warning messages as errors on page 1 169 A description of each command line switch includes information about case sensitivity equivalent switches switches overridden contradicted by the one described and naming and spacing constraints on parameters 1 148 VisualDSP 5 0 A
199. tdata LIBRARIES constdata NPUT_SECTION_ALIGN 1 PUT_SECTIONS OBJECTS ctor LIBRARIES ctor NPUT_SECTION_ALIGN 2 PUT_SECTIONS OBJECTS seg_rth gt MEM_PROGRAM stack ldf_stack_space ldf_stack_end Idf_stack_space MEMORY_SIZEOF MEM_STACK 4 gt MEM_STACK sysstack ldf_sysstack_space ldf_sysstack_end ldf_sysstack_space MEMORY_SIZEOF MEM_SYSSTACK 4 gt MEM_SYSSTACK VisualDSP 5 0 Assembler and Preprocessor Manual 1 19 Assembler Guide heap Allocate a heap for the application ldf_heap_space ldf_heap_end ldf_heap_space MEMORY_SIZEOF MEM_HEAP 1 ldf_heap_length ldf_heap_end ldf_heap_space gt MEM_HEAP argv Allocate argv space for the application ldf_argv_space ldf_argv_end ldf_argv_space MEMORY_SIZEOF MEM_ARGV 1 ldf_argv_length ldf_argv_end ldf_argv_space gt MEM_ARGV Program Interfacing Requirements You can interface your assembly program with a C or C program The C C compiler supports two methods for mixing C C and assembly language e Embedding assembly code in C or C programs e Linking together C or C and assembly routines To embed inline assembly code in your C or C program use the asm construct To link together programs that contain C C and assembly routines use assembly interface macros These macros facilitate the assembly of mixed routines For more information about these methods s
200. te debug info 1 156 h help 1 158 i include directory path 1 158 I include search path option for the flags compiler switch 1 155 li listing with include 1 159 l named listing file 1 159 micaswarn 1 161 M make rule only 1 160 MM generate make rule and assemble 1 160 Mo output make rule 1 161 Mt output make rule for named object 1 161 no anomaly workaround 1 162 no expand symbolic links 1 162 no expand windows shortcuts 1 163 normal word code 1 163 no source dependency 1 161 no temp data file 1 163 nwc normal word code 1 163 o output 1 164 pp proceed with preprocessing 1 164 proc processor 1 164 save temps save intermediate files 1 165 si revision version silicon revision 1 166 sp skip preprocessing 1 166 stallcheck 1 166 swe exclude 1 167 version display version 1 167 v verbose 1 167 Werror number 1 168 Winfo number informational messages 1 168 Wno info no informational messages 1 168 Wnumber warning suppression 1 168 w skip warning messages 1 167 Wsuppress number 1 169 Wwarn error 1 169 Wwarn number 1 169 assembly code embedding inline in C C 1 20 language constant 2 50 language programs writing 1 4 attributes creating in object files 1 86 B backslash character 2 24 binary files including 1 69 BITPOS assembler operator 1 53 1 54 block initialization section qualifiers 1
201. thout the need of other C semantics see cpredef for more information When the tokenize dot switch is used the preprocessor treats as an operator and not as part of an identifier If the notokenize dot switch is used it returns the preprocessor to the default behavior The only benefit 2 54 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor to the negative version is that if it appears on the command line after the cpredef switch it can turn off the behavior of without affecting other C semantics Uname The Uname switch directs the preprocessor to undefine a macro on the command line The undefine macro switch applies only to macros defined on the same command line The functionality provides a way for users to undefine feature macros specified by the assembler or linker v erbose The v erbose switch directs the preprocessor to output the version of the preprocessor program and information for each phase of the preprocessing version The version switch directs the preprocessor to display version information for the preprocessor program The version switch on the assembler command line provides version information for both the assembler and preprocessor The version switch on the preprocessor command line provides preprocessor version information only W The w disable all warnings switch directs the assembler not to display warning messages generated during assembl
202. tialized elsewhere The C struct can be declared in C compiled code or another assembly file The IMPORT directive with one or more STRUCT directives declares and initializes variables of that structure type within the assembler section in which it appears For more information refer to the EXTERN directive on page 1 81 and the STRUCT directive on page 1 130 Example IMPORT CHeaderFile h IMPORT ACME_ITir h ACME_IFir h SECTION program code that uses CHeaderFile ACME_Ilir and ACME_IFir C structs VisualDSP 5 0 Assembler and Preprocessor Manual 1 91 Assembler Syntax Reference INC BINARY Include Contents of a File The INC BINARY directive includes the content of file at the current location You can control the search paths used via the i command line switch on page 1 158 Syntax INC BINARY symbol filename skip count INC BINARY symbol filename skip count where symbol the name of a symbol to associate with the data being included from the file filename the name of the file to include The argument is enclosed in double quotes The skip argument skips a number of bytes from the start of the file The count argument indicates the maximum number of bytes to read Example SECTION datal VAR jim INC BINARY sym bert 10 6 VAR fred INC BINARY Imagel photos Picturel jpg 1 92 VisualDSP 5 0 Assembl
203. ting calls to an assembler when assem bling asm files Changing assembler options in VisualDSP does not affect the assembler calls made by the compiler during the compilation of c cpp files 1 172 VisualDSP 5 0 Assembler and Preprocessor Manual 2 PREPROCESSOR The preprocessor program pp exe evaluates and processes preprocessor commands in source files on all supported processors The preprocessor commands direct the preprocessor to define macros and symbolic con stants include header files test for errors and control conditional assembly and compilation The preprocessor supports ANSI C standard preprocessing with extensions such as and The preprocessor is run by other build tools assembler and linker from the operating system s command line or from within the VisualDSP 5 0 environment The pp preprocessor can also operate from the command line with its own command line switches This chapter contains e Preprocessor Guide on page 2 2 Contains the information on building programs e Preprocessor Command Reference on page 2 22 Describes the preprocessor s commands with syntax and usage examples e Preprocessor Command Line Reference on page 2 45 Describes the preprocessor s command line switches with syntax and usage examples VisualDSP 5 0 Assembler and Preprocessor Manual 2 1 Preprocessor Guide Preprocessor Guide This section describes pp preprocessor infor
204. tion takes one of the following forms BYTE symbolString length initString 0 BYTE symbolString initString 0 Note that the number of initialization characters defines the optional length of a string implicit size initialization VisualDSP 5 0 Assembler and Preprocessor Manual 1 79 Assembler Syntax Reference Example BYTE k 13 Hello world 0 BYTE k Hello world 0 The trailing zero character is optional It simulates ANSI C string representation 1 80 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler COMPRESS Start Compression NOTE Used with the ADSP 2146x SHARC processors only The COMPRESS directive indicates that all of the following instructions in the source file should be compressed if possible The directive has effect on sections assembled as short word Compression is canceled by a NOCOMPRESS directive later in the source file see on page 1 107 COMPRESS is advisory only e There is no guarantee that a particular instruction will be compressed e Instructions can be uncompressed if they are near the end of a DO loop e Whether a particular instruction is compressed can change due to assembler enhancements or bug fixes e There are no warnings if instructions cannot be compressed Therefore it is not recommended to create code layouts tables with fixed size entries that depend on particular instructions being compr
205. to stdout The only difference between MM and M actions is that the assembling continues with MM See M for more information 1 160 VisualDSP 5 0 Assembler and Preprocessor Manual Assembler Mo filename The Mo output make rule assembler switch specifies the name of the make dependencies file that the assembler generates when you use the M or MM switch If Mo is not present the default is lt stdout gt display If the named file is not in the current directory you must provide the path name in double quotation marks The Mo filename switch takes precedence over the o filename switch Mt filename The Mt filename output make rule for named object assembler switch specifies the name of the object file for which the assembler generates the make rule when you use the M or MM switch If the named file is not in the current directory you must provide the path name If Mt is not present the default is the base name plus the doj extension See M for more information micaswam The micaswarn switch treats multi issue conflicts as warnings This switch is used with Blackfin processors only no sourc e dependency The no source dependency switch directs the assembler not to print any thing about dependency between the asm source file and the doj object file when outputting dependency information This switch can only be used in conjunction with the M or MM switches VisualDSP 5 0 Assem
206. uct Logical OR IF 2 4 5 5 amp amp Logical AND IF SIZEOF char 2 amp amp SIZEOF int 4 directives Conditional directives do not have to appear alone on a line These directives are in addition to the C style if elif else and tendif preprocessing directives The IF ELSE ELIF and ENDIF directives in any case are reserved keywords The IF conditional assembly directive must be used to query about C structs in assembly using the SIZEOF and or OFFSETOF built in functions These built ins are evaluated at assembly time so they cannot appear in expressions in if preprocessor directives In addition the SIZEOF and OFFSETOF built in functions see C Struct Support in Assembly Built In Functions on page 1 63 can be used in relational expressions Different code sequences can be included based on the result of the expression For example SIZEOF struct typedef C_base_type is permitted VisualDSP 5 0 Assembler and Preprocessor Manual 1 61 Assembler Syntax Reference The assembler supports nested conditional directives The outer conditional result propagates to the inner condition just as it does in C preprocessing Assembler directives are distinct from preprocessor directives as follows e The directives are evaluated during preprocessing by the preprocessor Therefore preprocessor if directives cannot use assembler built ins see C Stru
207. ue label The operator directs the preprocessor to generate unique labels for iterated macro expansions Within the definition body of a macro define you can specify one or more identifiers with a trailing question mark to ensure that unique label names are generated for each macro invocation The preprocessor affixes _num to a label symbol where num is a uniquely generated number for every macro expansion For example abcd gt abcd_l If a question mark is a part of the symbol that needs to be preserved ensure that is delimited from the symbol For example abcd is a generated label and abcd is not Example i tdefine loop x y mylabel x 1 1 x 2 2 yourlabel y 3 3 y 54537 JUMP mylabel JUMP yourlabel loop bz kjb loop 1t ss loop yc jl Generates the following output mylabel_l bz 1 1 bz 2 2 yourlabel_1l kjb 3 3 kjb 5 5 JUMP mylabel_l JUMP yourlabel_l mylabel_2 1t 1 1 1t 2 2 yourlabel_2 ss 3 3 ss 5 5 JUMP mylabel_2 VisualDSP 5 0 Assembler and Preprocessor Manual 2 43 Preprocessor Command Reference JUMP yourlabel_2 mylabel_3 yc l l yc 2 2 yourlabel_3 J 3 3 Jd1 5 5 JUMP mylabel_3 JUMP yourlabel_3 The last numeric suffix used to generate unique labels is maintained by the preprocessor and is available through a preprocessor predefined macro __LastSuffix__ see on page 2 16 This value can be used to generate r
208. uotation marks in this order 1 The source directory that is the directory in which the original source file resides 2 The directories in the search path supplied by the 1 switch If more than one directory is supplied by the 1 switch they are searched in the order that they appear on the command line 3 The system directory that is the include subdirectory of the VisualDSP installation directory The current directory is the directory where the source file lives not the directory of the assembler program Usage of full path names for the I switch on the command line omitting the disk partition is recommended VisualDSP 5 0 Assembler and Preprocessor Manual 2 51 Preprocessor Command Line Reference The preprocessor searches for included files delimited by lt gt in this order 1 The directories in the search path supplied by the 1 switch sub ject to modification by the 1 switch as shown in I on page 2 52 If more than one directory is supplied by the 1 switch the directories are searched in the order that they appear on the command line 2 The system directory that is the include subdirectory of the VisualDSP installation directory The 1 switch indicates where to start searching for system include files which are delimited by lt gt If there are several directories in the search path the 1 switch indicates where in the path the search for system include files beg
209. use different numeric and comment formats Software developers who write assembly programs should be familiar with e Assembler Keywords and Symbols on page 1 38 e Assembler Expressions on page 1 50 e Assembler Operators on page 1 51 e Numeric Formats on page 1 56 e Comment Conventions on page 1 60 e Conditional Assembly Directives on page 1 60 e C Struct Support in Assembly Built In Functions on page 1 63 e Struct References on page 1 64 e Assembler Directives on page 1 67 VisualDSP 5 0 Assembler and Preprocessor Manual 1 37 Assembler Syntax Reference Assembler Keywords and Symbols The assembler supports predefined keywords that include register and bitfield names assembly instructions and assembler directives The following tables list assembler keywords for supported processors Although the keywords appear in uppercase the keywords are case insensitive in the assembler s syntax For example the assembler does not differentiate between MAX and max Table 1 9 lists the assembler keywords for Blackfin processors Table 1 10 on page 1 41 lists the keywords for SHARC processors Table 1 11 on page 1 44 lists the keywords for TigerSHARC processors Table 1 9 Blackfin Processor Assembler Keywords ALIGN ASCII ASM_ASSERT ASSERT BSS BYTE BYTE
210. ve temps switch see save temps Tips for Debugging Macros Assembly programmers may find it useful to include the processor system header files for pre defined macros that are helpful to assembly language programmers for that processor family These are known as def headers For example an ADSP BF534 programmer would use Header is located in lt install_path gt Blackfin include include defBF534 h A symbol in your program may inadvertently use the same spelling as a define in the def header Typically this results in a syntax error due to the symbol being replaced with a constant or constant expression which is not what you intended For example def8F534 h contains itdefine ALARM 0x0002 Alarm Interrupt Enable If an assembly program uses ALARM as a symbol name it will get a textual replacement of 0x0002 making the program illegal as demonstrated by the following code fragment d include defBF534 h define FALSE 0 define TRUE 1 SECTION datal VAR ALARM FALSE Error ea5004 alarm asm 7 Syntax Error in 2 14 VisualDSP 5 0 Assembler and Preprocessor Manual Preprocessor var 0x0002 1 syntax error is at or near text 0x0002 Attempting error recovery by ignoring text until the Using Predefined Preprocessor Macros In addition to macros you define the pp preprocessor provides a set of predefined macros and feature macros that can be used in assembly code The preproce
211. ween single and samples since VAR creates a four byte word of storage If the target is a processor on which the VAR directive reserves a one address unit such as SHARC three words of padding follow single in the section produced by the assembler ALIGN 1 no alignment requirement SECTION datal ALIGN 2 VAR single aligns the data item on the word boundary at the location with the address value that can be evenly divided by 2 ALIGN 4 VAR samples1 100 datal dat aligns the first data item on the double word boundary at the location with the address value that can be evenly divided by 4 advances other data items consecutively The Blackfin assembler accepts BYTE BYTE2 and BYTE4 as well as VAR VisualDSP 5 0 Assembler and Preprocessor Manual 1 73 Assembler Syntax Reference ALIGN_CODE Specify an Address Alignment Used with TigerSHARC processors only The ALIGN_CODE directive forces the address alignment of an instruction within the SECTION in which it is used ALIGN_CODE is similar to the ALIGN directive but whereas ALIGN causes the code to be padded with Os ALIGN_CODE pads with NoPs The ALIGN_CODE directive is used to align instructions Refer to the VisualDSP 5 0 Linker and Utilities Manual for more infor mation on section alignment Syntax ALIGN_CODE expression where expression evaluates to an integer It specifies an alignment requ
212. y Note that w has the same effect as the nowarn switch VisualDSP 5 0 Assembler and Preprocessor Manual 2 55 Preprocessor Command Line Reference Wnumber The Wnumber warning suppression switch selectively disables warnings specified by one or more message numbers For example W74 disables warning message pp0074 wam The warn switch generates prints warning messages this switch is on by default The nowarn switch negates this action 2 56 VisualDSP 5 0 Assembler and Preprocessor Manual INDEX Symbols preprocessor operator 2 43 Numerics 1 0r fract 1 59 1 15 fract 1 57 1 58 1 31 fract 1 58 1 31 fracts 1 78 __2106x__ macro 1 28 __2116x__ macro 1 28 __2126x__ macro 1 28 __2136x__ macro 1 29 __2137x__ macro 1 29 __2146x__ macro 1 29 __2146x__ preprocessor macro 2 20 __214xx__ macro 1 29 __214xx__ preprocessor macro 2 20 32 bit initialization used with 1 31 fracts 1 78 A absolute address 1 64 ADDRESS assembler operator 1 53 ADI macro 2 16 __ADSP21000__ macro 1 28 2 18 __ADSP21020__ macro 1 28 2 18 __ADSP21060__ macro 1 28 2 18 __ADSP21061__ macro 1 28 2 18 __ADSP21062__ macro 1 28 2 18 __ADSP21065L__ macro 1 28 2 18 __ADSP2106x__ macro 2 18 __ADSP21160__ macro 1 28 2 18 __ADSP21161__ macro 1 28 2 18 __ADSP2116x__ macro 2 19 __ADSP21261__ macro 1 28 2 19 __ADSP21262__ macro 1 28 2 19 __ADSP21266__ macro 1 28 2 19

Download Pdf Manuals

image

Related Search

Related Contents

IR100UD Manual  Refrigerating Circulator KH-5 user manual (English)  KMR 1700 B/LPG  User Manual  CTM-10 Chordfinder / Tuner / Metronom Vorsichtsmaßnahmen  

Copyright © All rights reserved.
Failed to retrieve file