SPRUI03E June 2015 – January 2023
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 C6X_A_DIR, see Section 5.6. For more information about C6X_C_DIR, see the TMS320C6000 Optimizing 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 00000000 .space 29
2 .copy "byte.asm"
A 1 ** In byte.asm
A 2 0000001d 00000020 .byte 32,1+ 'A'
0000001e 00000042
A 3 .copy "word.asm"
B 1 ** In word.asm
B 2 00000020 0000ABCD .word 0ABCDh, 56q
00000024 0000002E
A 4 ** Back in byte.asm
A 5 00000028 0000006A .byte 67h + 3q
3
4 ** Back in original file
5 00000029 00000064 .string "done"
0000002a 0000006F
0000002b 0000006E
0000002c 00000065
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 00000000 .space 29
2 .include "byte2.asm"
3
4 ** Back in original file
5 00000029 00000064 .string "done"
0000002a 0000006F
0000002b 0000006E
0000002c 00000065