Next Previous Contents

2. Usage

2.1 Command line option overview

The assembler accepts the following options:

---------------------------------------------------------------------------
Usage: ca65 [options] file
Short options:
  -D name[=value]               Define a symbol
  -I dir                        Set an include directory search path
  -U                            Mark unresolved symbols as import
  -V                            Print the assembler version
  -W n                          Set warning level n
  -d                            Debug mode
  -g                            Add debug info to object file
  -h                            Help (this text)
  -i                            Ignore case of symbols
  -l name                       Create a listing file if assembly was ok
  -mm model                     Set the memory model
  -o name                       Name the output file
  -s                            Enable smart mode
  -t sys                        Set the target system
  -v                            Increase verbosity

Long options:
  --auto-import                 Mark unresolved symbols as import
  --bin-include-dir dir         Set a search path for binary includes
  --cpu type                    Set cpu type
  --create-dep name             Create a make dependency file
  --create-full-dep name        Create a full make dependency file
  --debug                       Debug mode
  --debug-info                  Add debug info to object file
  --feature name                Set an emulation feature
  --forget-inc-paths            Forget include search paths
  --help                        Help (this text)
  --ignore-case                 Ignore case of symbols
  --include-dir dir             Set an include directory search path
  --large-alignment             Don't warn about large alignments
  --listing name                Create a listing file if assembly was ok
  --list-bytes n                Maximum number of bytes per listing line
  --macpack-dir dir             Set a macro package directory
  --memory-model model          Set the memory model
  --pagelength n                Set the page length for the listing
  --relax-checks                Relax some checks (see docs)
  --smart                       Enable smart mode
  --target sys                  Set the target system
  --verbose                     Increase verbosity
  --version                     Print the assembler version
---------------------------------------------------------------------------

2.2 Command line options in detail

Here is a description of all the command line options:

--bin-include-dir dir

Name a directory which is searched for binary include files. The option may be used more than once to specify more than one directory to search. The current directory is always searched first before considering any additional directories. See also the section about search paths.

--cpu type

Set the default for the CPU type. The option takes a parameter, which may be one of

6502, 65SC02, 65C02, 65816, sunplus, sweet16, HuC6280

The sunplus cpu is not available in the freeware version, because the instruction set is "proprietary and confidential".

--create-dep name

Tells the assembler to generate a file containing the dependency list for the assembled module in makefile syntax. The output is written to a file with the given name. The output does not include files passed via debug information to the assembler.

--create-full-dep name

Tells the assembler to generate a file containing the dependency list for the assembled module in makefile syntax. The output is written to a file with the given name. The output does include files passed via debug information to the assembler.

-d, --debug

Enables debug mode, something that should not be needed for mere mortals:-)

--feature name

Enable an emulation feature. This is identical as using .FEATURE in the source with two exceptions: Feature names must be lower case, and each feature must be specified by using an extra --feature option, comma separated lists are not allowed.

See the discussion of the .FEATURE command for a list of emulation features.

--forget-inc-paths

Forget the builtin include paths. This is most useful when building customized assembler modules, in which case the standard header files should be ignored.

-g, --debug-info

When this option (or the equivalent control command .DEBUGINFO) is used, the assembler will add a section to the object file that contains all symbols (including local ones) together with the symbol values and source file positions. The linker will put these additional symbols into the VICE label file, so even local symbols can be seen in the VICE monitor.

-h, --help

Print the short option summary shown above.

-i, --ignore-case

This option makes the assembler case insensitive on identifiers and labels. This option will override the default, but may itself be overridden by the .CASE control command.

-l name, --listing name

Generate an assembler listing with the given name. A listing file will never be generated in case of assembly errors.

--large-alignment

Disable warnings about a large combined alignment. See the discussion of the .ALIGN directive for futher information.

--list-bytes n

Set the maximum number of bytes printed in the listing for one line of input. See the .LISTBYTES directive for more information. The value zero can be used to encode an unlimited number of printed bytes.

--macpack-dir dir

This options allows to specify a directory containing macro files that are used instead of the builtin images when a .MACPACK directive is encountered. If --macpack-dir was specified, a .mac extension is added to the package name and the resulting file is loaded from the given directory. This is most useful when debugging the builtin macro packages.

-mm model, --memory-model model

Define the default memory model. Possible model specifiers are near, far and huge.

-o name

The default output name is the name of the input file with the extension replaced by ".o". If you don't like that, you may give another name with the -o option. The output file will be placed in the same directory as the source file, or, if -o is given, the full path in this name is used.

--pagelength n

sets the length of a listing page in lines. See the .PAGELENGTH directive for more information.

--relax-checks

Relax some checks done by the assembler. This will allow code that is an error in most cases and flagged as such by the assembler, but can be valid in special situations.

Examples are:

-s, --smart-mode

In smart mode (enabled by -s or the .SMART pseudo instruction) the assembler will track usage of the REP and SEP instructions in 65816 mode and update the operand sizes accordingly. If the operand of such an instruction cannot be evaluated by the assembler (for example, because the operand is an imported symbol), a warning is issued.

Beware: Since the assembler cannot trace the execution flow this may lead to false results in some cases. If in doubt, use the .ixx and .axx instructions to tell the assembler about the current settings. Smart mode is off by default.

-t sys, --target sys

Set the target system. This will enable translation of character strings and character constants into the character set of the target platform. The default for the target system is "none", which means that no translation will take place. The assembler supports the same target systems as the compiler, see there for a list.

Depending on the target, the default CPU type is also set. This can be overriden by using the --cpu option.

-v, --verbose

Increase the assembler verbosity. Usually only needed for debugging purposes. You may use this option more than one time for even more verbose output.

-D

This option allows you to define symbols on the command line. Without a value, the symbol is defined with the value zero. When giving a value, you may use the '$' prefix for hexadecimal symbols. Please note that for some operating systems, '$' has a special meaning, so you may have to quote the expression.

-I dir, --include-dir dir

Name a directory which is searched for include files. The option may be used more than once to specify more than one directory to search. The current directory is always searched first before considering any additional directories. See also the section about search paths.

-U, --auto-import

Mark symbols that are not defined in the sources as imported symbols. This should be used with care since it delays error messages about typos and such until the linker is run. The compiler uses the equivalent of this switch ( .AUTOIMPORT) to enable auto imported symbols for the runtime library. However, the compiler is supposed to generate code that runs through the assembler without problems, something which is not always true for assembler programmers.

-V, --version

Print the version number of the assembler. If you send any suggestions or bugfixes, please include the version number.

-Wn

Set the warning level for the assembler. Using -W2 the assembler will even warn about such things like unused imported symbols. The default warning level is 1, and it would probably be silly to set it to something lower.


Next Previous Contents