Include a file: Difference between revisions

Content added Content deleted
No edit summary
Line 15: Line 15:
The COPY instruction includes source statements from the SYSLIB library.
The COPY instruction includes source statements from the SYSLIB library.
<lang 360asm> COPY member</lang>
<lang 360asm> COPY member</lang>
=={{header|6502 Assembly}}==
There are two different directives for including files: <code>include</code> and <code>incbin</code>. <code>include</code> is for code and <code>incbin</code> is for binary data such as graphics. Unlike high-level languages, the location of the <code>include</code> or <code>incbin</code> statement matters. This of course depends on the assembler, but generally speaking, there are a few limitations:
* If you <code>include</code> a macro <i>after</i> that macro is used in your source code, the assembler may raise an error message. If your macros are always before your code this isn't a problem.

* When you <code>include</code> or <code>incbin</code> a file, unless your assembler has linker support, the assembler treats the include statement as though you copied and pasted the entire contents of that file at the location in your document where the <code>include</code>/<code>incbin</code> statement is.

*<code>include</code>/<code>incbin</code> statements can be nested, i.e. an included file can contain its own included files, but there is a limit with how deep you can go. Nesting includes is never actually required, as the example below demonstrates:

<lang 6502asm>;main.asm
include "Subroutines.asm"
;eof

;Subroutines.asm
include "math.asm"
;eof

;math.asm
;eof</lang>

The above is assembled identically to:
<lang 6502asm>;main.asm
include "Subroutines.asm"
include "math.asm"
;eof</lang>




=={{header|AArch64 Assembly}}==
=={{header|AArch64 Assembly}}==