SPRU513Y August 2001 – June 2022 SM320F28335-EP
Copy Source File
.copy "filename"
.include "filename"
The .copy and .include directives tell the assembler to read source statements from a different file. The statements that are assembled from a copy file are printed in the assembly listing. The statements that are assembled from an included file are not printed in the assembly listing, regardless of the number of .list/.nolist directives assembled.
When a .copy or .include directive is assembled, the assembler:
The filename is a required parameter that names a source file. It is enclosed in double quotes and must follow operating system conventions.
You can specify a full pathname (for example, /320tools/file1.asm). If you do not specify a full pathname, the assembler searches for the file in:
For more information about the --include_path option and C2000_A_DIR, see Section 5.6. For more information about C2000_C_DIR, see the TMS320C28x Optimizing C/C++ Compiler User's Guide.
The .copy and .include directives can be nested within a file being copied or included. The assembler limits nesting to 32 levels; the host operating system may set additional restrictions. The assembler precedes the line numbers of copied files with a letter code to identify the level of copying. A indicates the first copied file, B indicates a second copied file, etc.
In this example, the .copy directive is used to read and assemble source statements from other files; then, the assembler resumes assembling into the current file.
The original file, copy.asm, contains a .copy statement copying the file byte.asm. When copy.asm assembles, the assembler copies byte.asm into its place in the listing (note listing below). The copy file byte.asm contains a .copy statement for a second file, word.asm.
When it encounters the .copy statement for word.asm, the assembler switches to word.asm to continue copying and assembling. Then the assembler returns to its place in byte.asm to continue copying and assembling. After completing assembly of byte.asm, the assembler returns to copy.asm to assemble its remaining statement.
copy.asm (source file) |
byte.asm (first copy file) |
word.asm (second copy file) |
---|---|---|
|
|
|
Listing file:
1 000000 .space 29
2 .copy "byte.asm"
1 ** In byte.asm
2 000002 0005 byte 5
3 .copy "word.asm"
1 ** In word.asm
2 000003 ABCD .word 0ABCDh
4 * Back in byte.asm
5 000004 0006 .byte 6
3
4 **Back in original file
5 000005 646F .string "done"
000006 6E65
In this example, the .include directive is used to read and assemble source statements from other files; then, the assembler resumes assembling into the current file. The mechanism is similar to the .copy directive, except that statements are not printed in the listing file.
include.asm (source file) |
byte2.asm (first copy file) |
word2.asm (second copy file) |
---|---|---|
|
|
|
Listing file:
1 000000 .space 29
2 .include "byte2.asm"
3
4 ** Back in original file
5 000007 0064 .string "done"
000008 006F
000009 006E
00000a 0065