22. Running the assembler

The assembler is run from the command line, or from an IDE that interfaces with the assembler using the command line.

22.1. Basic invocation

The assembler is invoked in the following way:

$ as68k [options] sourcefile [options]

As an example, to assemble a source file with debugging information and a list file, you can use:

$ as68k --debug source.c -l

Command line options are optional arguments that tune the behavior of the assembler. They always start with a dash character. There are two variants, single letter options (-l to instruct the assembler to create a list file) starts with a single dash. The other variant is long descriptive options that starts with two dashes.

Some options require arguments. These follow the option, separated by a space or an equals sign (=). For single-argument options, the separator is optional:

$ as68k -Iinclude source.c -D VERBOSE=2 --list-file=tiny-source.lst

In this case the -I option adds include as a directory to scan for header files. The symbol VERBOSE is defined in the preprocessor with value 2. A list file with a specific name is also produced.

The order in which the options appear normally do matter, except for the -I option that adds directories to search for header files. Such directories are searched in the order in which they appear on the command line.

To display the version of the assembler, use --version:

$ as68k --version
Calypsi assembler for Motorola 68000 version 5.16

Command line options are described in Command line options.

22.2. Include search path

Header files are included by surrounding the filename with either double quotes or angled brackets:

#include "myheader.h"
#include <system.h>

Angled brackets are typically for system header files, while double quotes are for application-specific header files.

Note

The installation provides no system header files for the as68k assembler. However, the preprocessor retains its standard behavior of supporting angled include files and searching the installation directory.

The search order for include files is as follows:

  1. Relative to compilation directory (double quote include only)

  2. In directories specified in the -I option in the order they appear on the command line

  3. The system directory, which is the Calypsi installation directory

Header files specified in angle brackets are not searched relative to the compilation directory. Otherwise, their behavior is identical.

Note

More precisely, the system header file directory is relative to the as68k executable. If you move an installation, it will still find the correct system header file directory.

Note

No header files are currently provided with the assembler. The preprocessor search path exists for consistency with the C compiler.

22.3. Assembler output

The assembler outputs one or two files, an object file that can be linked with other object files and libraries by ln68k to produce an executable file, and optionally a list file.

Object file

The object file is in ELF format, optionally including DWARF debugging information if --debug (or -g) is specified.

It contains:

  • A symbol table

  • Relocatable sections for code and data

  • Relocations, allowing linker to modify address values after section placement

  • DWARF-formatted source-level debugging information (if --debug was specified)

  • Vendor-specific data, including runtime attributes and additional the Calypsi C compiler tool chain-specific information not covered by ELF/DWARF, used by the linker and debugger, with section types 0x8000000a and 0x8000000b.

Note

DWARF version 5 is used. The implementation covers the needs of the Calypsi C compiler tool chain and includes vendor extensions.

Note

DWARF debug information from the assembler includes source line information. The object file also contains a symbol table.

List file

The list file is a text file meant to be shown with a fixed width font. It contains a header that shows assembler, version, time when it was created and the command line used. The assembly source is shown with corresponding hex machine code. It also shows macro expansions and includes a summary of code and data sizes.

The following example is the setjmp source file from the C runtime library:

/****************************************************************************
 *
 * Copyright Håkan Thörngren
 *
 * This file is part of the Calypsi C library.
 * Permission to use with the Calypsi tool chain is hereby granted.
 *
 ****************************************************************************/

              .rtmodel version, "1"
              .rtmodel cpu, "*"

              .public setjmp
#ifdef __CALYPSI_CODE_MODEL_SMALL__
              .section nearcode
#else
              .section code
#endif
              .align  2
setjmp:       move.l  sp,(a0)+
              move.l  a5,(a0)+
              move.l  (sp),(a0)+
              moveq.l #0,d0
              rts

#ifdef __CALYPSI_CODE_MODEL_SMALL__
              .section nearcode
#else
              .section code
#endif
              .public longjmp
              .align  2
longjmp:      move.l  (a0)+,sp
              move.l  (a0)+,a5
              move.l  (a0)+,(sp)
              rts

Compiling with the -l option produces a list file:

###############################################################################
#                                                                             #
# Calypsi assembler for Motorola 68000                           version 5.16 #
#                                                       14/Apr/2026  16:42:00 #
# Command line: setjmp.s -l                                                   #
#                                                                             #
###############################################################################

0001                    /****************************************************************************
0002                     *
0003                     * Copyright Håkan Thörngren
0004                     *
0005                     * This file is part of the Calypsi C library.
0006                     * Permission to use with the Calypsi tool chain is hereby granted.
0007                     *
0008                     ****************************************************************************/
0009
0010                                  .rtmodel version, "1"
0011                                  .rtmodel cpu, "*"
0012
0013                                  .public setjmp
0014                    #ifdef __CALYPSI_CODE_MODEL_SMALL__
0015                                  .section nearcode
0016                    #else
0017                                  .section code
0018                    #endif
0019                                  .align  2
0020  00000000 20cf     setjmp:       move.l  sp,(a0)+
0021  00000002 20cd                   move.l  a5,(a0)+
0022  00000004 20d7                   move.l  (sp),(a0)+
0023  00000006 7000                   moveq.l #0,d0
0024  00000008 4e75                   rts
0025
0026                    #ifdef __CALYPSI_CODE_MODEL_SMALL__
0027                                  .section nearcode
0028                    #else
0029                                  .section code
0030                    #endif
0031                                  .public longjmp
0032                                  .align  2
0033  00000000 2e58     longjmp:      move.l  (a0)+,sp
0034  00000002 2a58                   move.l  (a0)+,a5
0035  00000004 2e98                   move.l  (a0)+,(sp)
0036  00000006 4e75                   rts

##########################
#                        #
# Memory sizes (decimal) #
#                        #
##########################

Executable  (Text): 18 bytes

22.4. Command line options

This section covers the as68k command-line options in detail.

Options overview

Running the assembler from the command line without arguments results in a missing input file error, followed by a short help message:

$ as68k
Missing: FILE

Usage: as68k [--version] [-o|--output-file OUTPUT-FILE] [-l]
             [--list-file LIST-FILE] [-I DIRECTORY] [-D IDENTIFIER]
             [-U IDENTIFIER] [-g|--debug] [--rtattr NAME=VALUE] [--weak-symbols]
             [--core CORE] [--target TARGET] [--code-model NAME]
             [--data-model NAME] FILE
  use 'as68k --help' for detailed help

For more detailed help, use the --help option:

$ as68k --help
Calypsi assembler for Motorola 68000 version 5.16

Usage: as68k [--version] [-o|--output-file OUTPUT-FILE] [-l]
             [--list-file LIST-FILE] [-I DIRECTORY] [-D IDENTIFIER]
             [-U IDENTIFIER] [-g|--debug] [--rtattr NAME=VALUE] [--weak-symbols]
             [--core CORE] [--target TARGET] [--code-model NAME]
             [--data-model NAME] FILE
  use 'as68k --help' for detailed help

Available options:
  --version                Display version number
  -o,--output-file OUTPUT-FILE
                           Name of output file
  -l                       Generate a list file, named by appending '.lst' to
                           input file
  --list-file LIST-FILE    Generate list file, using given name
  -I DIRECTORY             Include directory
  -D IDENTIFIER            Predefine a macro
  -U IDENTIFIER            #undef a predefined macro
  -g,--debug               Produce debugging information
  --rtattr NAME=VALUE      Define a runtime attribute (identifier or quoted
                           string value accepted)
  --weak-symbols           Make all public symbols entries weak
  --core CORE              Core, one of '68000', '68010', '68020', '68030',
                           '68040', '68060' or '68080' (defaults to '68000')
  --target TARGET          Target system, one of 'Amiga', 'A2560U', 'A2560K' or
                           'TOS' (defaults to embedded/ROM use, if omitted)
  --code-model NAME        Code model, one of 'small' or 'large' (defaults to
                           'large')
  --data-model NAME        Data model, one of 'small', 'large' or 'far-only'
                           (defaults to 'small')
  -h,--help                Show this help text

Options in detail

--version

Displays the name and version of the assembler.

--output-file, -o

Specify the output object file name. If omitted, the output file is derived from the input file name (excluding path) with a .o extension, written to the current directory by default.

This option can also alter the output file name and provide a directory path. The specified directory must already exist.

-l

Generate a list file. The name used is the name of the input file (ignoring any directory path) with a .lst file extension. See also --list-file.

--list-file

Generate a list file. The name of the list file is given as argument to this option. See also -l to generate a list file based on the source filename.

-I

Add a directory to the current include search path. This option can be used multiple times on a command line. The order in which they appear specifies the search order between the directories.

The system include directory is always added last to the search order list.

--include-system

Add a directory to the current system include search path before the provided system include directories. This option can be used multiple times on a command line. The order in which they appear specifies the search order between the directories.

--include-system-after

Add a directory to the current system include search path after the provided system include directories. This option can be used multiple times on a command line. The order in which they appear specifies the search order between the directories.

-D

Define a macro. This takes an argument with the symbol name and optionally an assignment value -Dsymbol[=value]. If no value is given, the macro is given the value 1.

-U

Undefine a macro. This takes an argument with the symbol name to be undefined.

--debug

Generate DWARF symbolic debugging information. In order to get debugging information all the way to the debugger, the linker must also be given this option.

When debugging information is enabled the __CALYPSI_DEBUG__ macro is also defined and set to 1.

-g

Synonym for --debug.

--rtattr NAME=VALUE

This defines a runtime attribute, written to the object file, that the linker can use for object file consistency checks.

--weak-symbols

Make all public symbols in the object file weak. This is normally not needed, but can provide a default library function implementation that is used if no replacement is provided.

In the assembler you can also specify symbols to be exported weak individually using the .pubweak directive.

--core

This selects which 68000 core to use. This can either be 68000, 68010, 68020, 68030, 68040, 68060 or 68080. If not specified it defaults to 68000.

--target

This option is available for symmetry with the compiler. It has the effect of setting the corresponding target preprocessor macro.

--code-model

This option is available for symmetry with the compiler. It has the effect of setting the corresponding code model preprocessor macro.

--data-model

This option is available for symmetry with the compiler. It has the effect of setting the corresponding data model preprocessor macro.