<--  back   Last regenerated: 2022-04-20 17:31:36 kio

zasm - Z80 Assembler – Version 4.4

Including C Source Files

#include

Include a single source file or resolve missing Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels from a library.

#include <filename>

Assembler directives: #include
Including C Source Files: #include
#include "utils.ass" ; file in same directory Assembler directives: #include
Including C Source Files: #include
#include "./utils.s" ; file in same directory Assembler directives: #include
Including C Source Files: #include
#include "utils/u1.s" ; file in subdirectory "utils/" Assembler directives: #include
Including C Source Files: #include
#include "main13.c" ; include a c source file

Include a single source file. The file name must be an absolute path or relative to the current source file. The included source is assembled as Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
if it was in the main source file itself. Source file inclusion may be nested.

The included file may be a c source file, which is detected by the filename extension ".c". Then zasm executes sdcc (or any other c compiler) to compile the source.

Topics related to c files:

#include library

Resolve missing Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels from a library.

#include: #include library
#include: #include library
#include library <"directory"> #include: #include library
#include: #include library
#include library <"directory"> resolve * #include: #include library
#include: #include library
#include standard library #include: #include library
#include: #include library
#include standard library resolve _foo, __bar, __mulu16

#include: #include library
#include: #include library
#include library
or #include: #include library
#include: #include library
#include standard library
may be used to automatically resolve undefined Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels. #include: #include library
#include: #include library
#include standard library
requires that you have passed the system library directory with Differences from v3 to v4: Command line options
Command Line Options
Command Line Options: Command line options
command line option -L.

You can either try to resolve all missing Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels, in which case you don't append the resolve keyword or resolve *, or you may limit automatic Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
label resolving to a list of certain Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels. This may be required Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
if you have to spread the additional code over multiple code segments or Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
if certain Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels must go into certain code segments and the included sources do not care for this by themselves.

This is most conveniant to automatically resolve references arising from c source, but may be used with pure assembler source as well.

Naming convention for files in a library directory

Files in the library directory must follow certain naming conventions: they must be named according to the Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
label they define. Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
If a file defines Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
label _foo, then the file must be named _foo.s or _foo.c, or more accurately any _foo.* will be included. Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
If it Pseudo instructions: end, .end
8080 pseudo instructions: END
ends with '.c' then it will be compiled and then included. Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
If a file defines more than one Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
label then you can make symbolic links for the other names which point to this file.

zasm adds directive Assembler directives: #assert
Pseudo instructions: #assert
#assert after the included file to verify, that the promissed Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
label was actually defined:

Source:

#include: #include library
#include: #include library
#include standard library

Generated:

5E30:                   #include: #include library
#include: #include library
#include standard library 5E30: Assembler directives: #include
Including C Source Files: #include
#include "/Projects/sdcc/lib/__mulint.s" 5E30: ; contents from file ... ... 7503: Assembler directives: #assert
Pseudo instructions: #assert
#assert defined(__mulint::) 7503: #include: #include library
#include: #include library
#include standard library 7503: Assembler directives: #include
Including C Source Files: #include
#include "/Projects/sdcc/lib/_check_struct_tm.c" 7503: Assembler directives: #local, #endlocal, .local and .endlocal
Pseudo instructions: #local, #endlocal, .local and .endlocal
Including C Source Files: #local, #endlocal, .local and .endlocal
#local 7503: ; contents from compiled file ... ... 8D96: Assembler directives: #local, #endlocal, .local and .endlocal
Pseudo instructions: #local, #endlocal, .local and .endlocal
Including C Source Files: #local, #endlocal, .local and .endlocal
#endlocal 8D96: Assembler directives: #assert
Pseudo instructions: #assert
#assert defined(_check_struct_tm::) 8D96: #include: #include library
#include: #include library
#include standard library ... ...

You can see how the single #include: #include library
#include: #include library
#include standard library
is expanded into a series of include filename and an Assembler directives: #assert
Pseudo instructions: #assert
#assert defined(labelname::)
is appended to the included source. C sources are also wrapped with Assembler directives: #local, #endlocal, .local and .endlocal
Pseudo instructions: #local, #endlocal, .local and .endlocal
Including C Source Files: #local, #endlocal, .local and .endlocal
#local
... Assembler directives: #local, #endlocal, .local and .endlocal
Pseudo instructions: #local, #endlocal, .local and .endlocal
Including C Source Files: #local, #endlocal, .local and .endlocal
#endlocal
.

#include: #include library
#include: #include library
#include standard library
is generated again and again until no more Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels could be resolved. (This is the way how it works internally.)

As an alternate syntax the Pseudo instructions
8080 Assembler: 8080 pseudo instructions
pseudo instructions "include" and "*include" are recognized.

    include "foo.s"
    *include "bar.s"

Valid HTML   Valid CSS