|
Include a single source file or resolve missing Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabels from a library.
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, endifif 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 optionsCommand line option -c may be used to point zasm to a certain compiler. Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endifIf 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 optionsCommand line option -I may be used to supply the path to the system headers library. Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endifIf 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 optionsCommand 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, endifif 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.
Resolve missing Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabels 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: Labelslabels. #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 optionscommand line option -L.
You can either try to resolve all missing Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabels, 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: Labelslabel resolving to a list of certain Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabels. This may be required Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endifif you have to spread the additional code over multiple code segments or Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endifif certain Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabels 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.
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: Labelslabel they define. Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endifIf a file defines Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel _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, endifIf it Pseudo instructions: end, .end 8080 pseudo instructions: ENDends with '.c' then it will be compiled and then included. Assembler directives: #if, #elif, #else, #endif Pseudo instructions: if, endifIf a file defines more than one Pseudo instructions: Label definition Numeric expressions: Labels 8080 Assembler: Labelslabel 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: Labelslabel 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: Labelslabels could be resolved. (This is the way how it works internally.)
As an alternate syntax the Pseudo instructions 8080 Assembler: 8080 pseudo instructionspseudo instructions "include" and "*include" are recognized.
include "foo.s"
*include "bar.s"
| |