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

# zasm - Z80 Assembler – Version 4.4

# Assembler directives

[<prev] [next>]

| ### #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: Differences from v3 to v4: Command line options Command Line Options Command Line Options: Command line options Command line option -c may be used to point zasm to a certain compiler. Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif If not used, zasm will search in your $PATH for an executable named 'sdcc'. Differences from v3 to v4: Command line options Command Line Options Command Line Options: Command line options Command line option -I may be used to supply the path to the system headers library. Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif If not used, sdcc will use it's built-in default paths. Differences from v3 to v4: Command line options Command Line Options Command Line Options: Command line options Command line option -L may be used to supply the path to the system library sources. This is used by zasm Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endif if you use `#include: #include library #include: #include library#include standard library`. (see below) Directive Assembler directives: #cflags Including C Source Files: #cflags#CFLAGS may be used in your assembler source to tweak the cflags for the c compiler. zasm surrounds included c files with the Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#local and Assembler directives: #local, #endlocal, .local and .endlocal Pseudo instructions: #local, #endlocal, .local and .endlocal Including C Source Files: #local, #endlocal, .local and .endlocal#endlocal directives to avoid problems with identically named static variables. #### #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"

[<prev] [top] [next>]