vasm

A portable and retargetable assembler.
About vasm
Last release source
Daily source snapshot
Tagged source archives
Last release binaries
Daily snapshot binaries
Compilation notes
A small tutorial
vasm docs (html)
vasm docs (pdf)
Volker's vasm page
vbcc/Amiga home page

vasm is a portable and retargetable assembler to create linkable objects in various formats or absolute code. Multiple CPU-, syntax and output-modules can be selected.

Many common directives/pseudo-opcodes are supported (depending on the syntax module) as well as CPU-specific extensions.

The assembler supports optimizations (e.g. choosing the shortest possible branch instruction or addressing mode) and relaxations (e.g. converting a branch to an absolute jump when necessary).

Most syntax modules support macros, include directives, repetitions, conditional assembly and local symbols.

Currently the following CPUs are officially supported by vasm:
  • 6502 family (including 65C02, 65CE02, DTV, 45GS02, HU6280, 65802, 65816)
  • 6800 family (6800, 6801, 6803, 68HC11)
  • 6809 family (6809, 6309 and 68HC12)
  • 80x86 family (IA32 8/16/32 bit, using AT&T-syntax)
  • ARM (architecture ARMv1 to ARMv4, including THUMB mode)
  • C16x/ST10
  • ColdFire family (all models of V2, V3, V4, V4e)
  • HANS project (32-bit FPGA CPU)
  • Jaguar RISC (GPU and DSP instruction sets)
  • M680x0 family (including M6888x, M68851, CPU32 and Apollo 68080)
  • PDP-11 architecture (includes EIS, FIS)
  • PowerPC family (POWER, 40x, 440, 460, 6xx, 7xx, 7xxx, 860, Book-E, e300 and e500)
  • QNICE (elegant 16-bit FPGA CPU)
  • Raspberry-Pi VideoCore IV
  • SunPlus μnSP CPU (ISA V1.0 and V1.1)
  • TR3200 (virtual CPU from 0x10c)
  • Z80 family (Z80, 8080, 8085, GBZ80, 64180, RCM2/3/4k)
These syntax flavours are supported:
  • Standard (GNU-as style) syntax
  • Motorola/Freescale 68k syntax (Devpac compatible)
  • Atari MadMac syntax (6502, 68k, Jaguar)
  • Old 8-bit style syntax
Supported output file formats:
  • a.out (M68k, i386 and JRISC)
  • Amiga hunk format (M68k)
  • Apple DOS, Atari COM, Commodore PRG, Oric TAP binary formats (6502)
  • Atari TOS executable format (M68k)
  • Atari DRI object file format (M68k)
  • C #define output format (all)
  • C256 Foenix PGX and PGZ binary formats (65816)
  • EHF extended hunk format (PowerPC)
  • ELF (M68k, PowerPC, i386, ARM and JRISC)
  • GST object file format
  • HANS project output format
  • Intel-Hex format (all)
  • MOS Paper Tape format (all)
  • Motorola Srecord format (all)
  • o65 relocatable format (6502, 65816)
  • Raw, binary output (all)
  • Sharp X68000 Xfile (and Zfile) format (M68k)
  • Tandy Color Computer and Dragon DOS binaries (6809)
  • Test, debugging output (all, default)
  • VOBJ proprietary versatile object format (all)
  • Wozmon monitor format (6502)


13-Oct-2024: vasm 2.0.
  • Support for architectures which have bytes with more than 8 bits.
  • Output formats bin, ihex, srec, test and vobj currently support >8-bit bytes.
  • New options -obe and -ole to define the endianess of target-bytes in binary output.
  • New options -ibe and -ile to define the endianess of target-bytes in binary includes (incbin).
  • New option -underscore adds a leading underscore to all imported and exported symbol names.
  • New option -relpath to treat all include paths as relative first, even when starting with '/' or '\'.
  • Reworked relocations and added the option to define their signedness.
  • New CPU backend for unSP (micro-nSP), having 16-bit bytes. Contributed by Adrien Destugues.
  • New CPU backend for the FPGA-CPU HANS, using 32-bit bytes. Contributed by Yannick Stamm.
  • New output module "pap", which outputs MOS Paper Tape files, as documented in the KIM-1 User's Manual. Contributed by Dimitri Theulings.
  • When printing error messages in macros, also print the source text line calling the macro.
  • A macro redefinition prints a warning with the previous definition. The old macro is correctly replaced.
  • Also warn about initialized space atoms (.space, etc.) in BSS sections.
  • Workaround for a Windows bug, when reading a source text from stdin directly via the terminal.
  • Fixed output of 64-bit symbol values in vobjdump.
  • Directives to suppress listing file output (like NOLIST) will no longer appear in the listing file.
  • Fixed string constants (in immediate addressing modes) with non-ASCII characters.
  • Fixed potential buffer overflow when generating a section name for ORG directives (since V1.9f).
  • Output modules now show the source line for unknown relocation errors.
  • m68k: Most out of range errors have now become warnings.
  • m68k: Out of range 8-bit immediate constants write to all 16 bits of the extension word, with a warning (to be able to simulate the behaviour of some old, faulty assemblers).
  • m68k: Improved -opt-size optimization for move.l->moveq/lsl, which now optimizes all values below 0x8000 where the highest and lowest bit set does not span more than 7 bits (suggested by Erik Hemming).
  • m68k: Float-constant optimization (OPT of, enabled by default) now also supports integer constant optimization to 16-bit.
  • m68k: Command line options of the form -opt-<option> execute a Devpac-style option in the same way as an OPT directive at the top of the source text.
  • m68k: New options -warnabs16 and -warnabs32 to show a warning when accessing absolute 16- oder 32-bit addresses.
  • m68k: Fixed assigning another register list symbol with REG/EQURL, which was broken since V1.9a.
  • m68k: REG/EQURL directives optionally allow to specify register lists as a register mask constant (BAsm compatibility).
  • m68k: Add Apollo E-register banking for negx, swap, movex, sCC, addiw.l, cmpiw.l, rol, ror, roxl, roxr, and perm.
  • m68k: Apollo instructions pabsb, pabsw are gone (opcode space will be reused in future).
  • m68k: Apollo fmove.{b/w/l/s/d} En,Em is replaced by floadi and fstorei to make clear whether the Em target is an integer or floating point register.
  • m68k: New Apollo instructions: fmoverz, fmoveurz, moveiw, mov3q, movs, movz, move2 (updated), clr.q.
  • m68k: Do not allow Bcc.B with branch distance -130 for Apollo, as it would encode as $6xff (opcode for 32-bit branch).
  • 6502: Added al/as/xl/xs as aliases for a16/a8/x16/x8 directives. Added longa/longi as WDC-style aliases for theses directives (65816).
  • 6502: Absolute 16-bit addressing modes ignore the bank by default for 65816.
  • 6502: Optionally allow alternative syntax with immediate operands for MVN, MVP and PEA (65816).
  • 6502: Out of range errors turned into warnings.
  • 6502: CPU directive, to define the cpu model.
  • 6502: Byte-selector operators are gone and turned into operand prefixes, according to the official WDC syntax.
  • 6502: New option -am to mask all immediate and data values to their specified size.
  • 6502: Hu6280 uses SETDP $2000 to move the zero page for automatic code optimizations.
  • 6502: New option -dpo to generate offset-relocs for zero- or direct-page accesses.
  • x86: Default to 16-bit addressing when -m selects a CPU below 386. Default to 64-bit addressing with -m64.
  • x86: Let the mnemonic's suffix always decide about the operation size, even when the operand is a label (gas seems to do the same).
  • x86: Mask all immediate operand relocations according to their size (to allow something like movb $label,dest or movw $label,dest).
  • x86: Fix macros with size-suffixes (b,w,l,s,q,x). Size qualifiers are no longer allowed in x86-macros.
  • x86: Allow multiple alternating .codeNN directives in the source.
  • x86: Add missing prefix when using 32-bit registers in 16-bit mode.
  • x86: Fixed relative calls with size suffix (callw, calll) in 16/32-bit mode.
  • mot-syntax: Fixed non-zero offset in CNOP, which was broken since V1.7c.
  • mot-syntax: TTL sets the listing file page title and not the unit name.
  • oldstyle-syntax: MACRO (written in upper case) didn't work with arguments.
  • oldstyle-syntax: New ifblank and ifnblank directives may be used to check whether a macro argument was given.
  • oldstyle-syntax: New directive exitmacro to exit recursive macro invocations.
  • oldstyle-syntax: New directive da as an alias for addr.
  • oldstyle-syntax: New directive bss to reserve space, like ds or reserve.
  • oldstyle-syntax: New directives blkl and dsl for defining space with a 32-bit pattern.
  • oldstyle-syntax: Section attributes 'f' and 'z' may be used to designate a section for far- or near-addressing (e.g. direct/zero-page).
  • oldstyle-syntax: Fixed FCC for single characters (no expressions allowed).
  • oldstyle-syntax: The closing quote-character (' or ") in single-character expressions is now optional (compatibility with old Motorola sources).
  • oldstyle-syntax: Broken hex-constants with the minus-operator following the '$' are supported for compatibility reasons.
  • oldstyle-syntax: Allow optional colon after a label for macro, equ and set directives.
  • std-syntax: The "true" result of logical operations should be 1 not -1.
  • std-syntax: Allow XY' (alternate) registers with Z80.
  • std-syntax: The .org directive always defines the absolute address for subsequent code, as long as no relocatable section was defined (or -gas).
  • std-syntax: .ifc and .ifnc directives for comparing strings.
  • hunk-output: New option -noabspath to refrain from creating absolute paths for source line debugging (LINE debug format).
  • hunk-output: Automatic source line debugging output (-linedebug) also includes BSS sections now, unless Devpac-compatibility was specified (-devpac).
  • hunk-output: New options -dbg-local and -dbg-globloc to include local labels into the debug symbol hunk (HUNK_SYMBOL).
  • hunk-output: Warn about odd relocation offsets, which might crash the AmigaOS loader on 68000 and 68010 systems (suggested by Erik Hemming).
  • o65-output: Support low-word relocs in 65816 mode.
  • bin-output: Fixed overlapping misdetection with empty org-sections.
  • bin-output: Foenix PGX format supports 65C02 and PGZ format supports 32-bit.
  • bin-output: New option -coalesced to output org-blocks without padding.
  • cdef-output: Do not output internal symbols.
  • elf-output: Fixed advancing by more than 63 lines in the DWARF output (patch by arcanist/EAB).
  • tos-output: Fixed alignment problem with DRI object file relocs.
  • tos-output: New option -zfile to output Sharp X68000 Z-file executables.
  • xfile-output: New option -exec to define the execution label.
  • xfile-output: New option -loadhigh to load the executable into high memory.


10-Nov-2023: vasm 1.9f.
  • Fix relative section offset directives, which must be unsigned to work correctly over the whole target's address space.
  • Fixed a few issues with named macro arguments.
  • Do not warn about missing references to Common or Weak symbols.
  • Binary output modules allow addresses outside of the backend's address space.
  • m68k: MOVEM (An),An/Am must not be optimized into two MOVE instructions. This was a new bug in V1.9e.
  • std-syntax: Fixed binary constant 0b...., which was erroneously mistaken for a one-digit temporary label destination since V1.9a.


30-Sep-2023: vasm 1.9e.
  • Exit before reading the source (from stdin) when there were errors already.
  • Make sure the relocated blocks within all sections are closed after parsing. Otherwise the first pass may find the section in a wrong state.
  • Output modules may define the default section, when no SECTION or ORG directive was given. "bin", "ihex" and "srec" now default to "ORG 0".
  • New output module "woz", which outputs sections as "wozmon" monitor commands, suitable for ASCII transfer via a serial connection. Contributed by anomie-p.
  • m68k: Improved -opt-movem (OPT om+) optimizations, for MOVEM with two registers.
  • m68k: Fixed Apollo ADD/SUB->ADDQ/SUBQ optimization with AMMX registers.
  • m68k: Enabled Apollo FPU instructions using 64-bit data registers: Fxxx.D Dn,ea, FMOVE.D Fn,Dm, etc.
  • m68k: Added missing PC-relative destination addressing modes for Apollo shift instructions and FMOVE, FMOVEM.
  • m68k: Apollo bchg/bclr/bset/btst Dn,An must not be allowed (conflicts with MOVEP).
  • m68k: New Apollo instructions FDBcc.L, DBcc En,lab; EXTUB.L and EXTUW.L.
  • 6809: Fixed typo in the opcode for the 6309 LDMD instruction.
  • mot-syntax: Allow multiple consecutive relocated blocks within a section.
  • mot-syntax: New directives LOCAL and RSEVEN for compatibility.
  • mot-syntax: Allow any type of expression for RSSET, SETSO, SETFO.
  • madmac-syntax: Allow multiple consecutive relocated blocks within a section.
  • oldstyle-syntax: The label defining the size of a STRUCT block may have been moved into the previous section, or caused a segfault at ENDSTRUCT, since V1.9b.
  • tos-output: Also write absolute symbols (equates) into executables.
  • tos-output: New option -szbx to enable unlimited symbol names using the SozobonX extension.
  • bin-output: New option -start to define the start address for the default org-section.


23-Apr-2023: vasm 1.9d.
  • m68k: Using MOVEQ.L instead of MOVEQ must only disable the warning for values between 128 and 255, but not allow any value without error.
  • mot-syntax: XREF allows no definition and XDEF requires a definition.
  • std-syntax: Fixed potential problem with "scratch at end of line" warnings after a section attribute string.
  • oldstyle-syntax: Fixed potential problem with "scratch at end of line" warnings after a section attribute string.
  • tos-output: Reloc-output in executables was broken since V1.9b! Restrict to 32-bit absolute relocations again.


29-Mar-2023: vasm 1.9c.
  • Reverted a last-minute change in V1.9b, which broke the O65 output module, used with 6502 and 65816.


26-Mar-2023: vasm 1.9b.
  • Fixed a rare expression evalulation bug. Previous versions may erroneously evaluate "label - equate" as constant, when the equate is something like "currentPCsymbol - label".
  • Allow a label definition on the same line as a section directive and warn about it.
  • Macro arguments were lost at the second repeat-level inside a macro.
  • Syntax modules warn about garbage characters in the operand field, when the mnemonic doesn't take any operand.
  • No longer cut symbol names in a wide-format listing file after 31 chars.
  • Error messages on macros and repetitions now always include the real source file name and line number in parentheses.
  • Directives for printing expressions into the console (printv, echo, etc.) now print undefined symbols as "<undefined>+offset".
  • New output module "gst" for GST object files (Atari, GST-assembler, Devpac).
  • New output file format "dri" for Atari M68k DRI object files.
  • m68k: Experimental Apollo TEX instruction, using a simplified syntax after a proposal of John H.
  • m68k: Apollo extended/compressed Bcc.B displacements in the range of -256 to 254.
  • m68k: MOVEQ.L suppresses any warning about an out of range operand.
  • m68k: Allow any size-extension for MOVEQ in Devpac-compatibility mode.
  • m68k: Fixed a string-buffer conflict introduced in V1.9a, which occurs when using local symbols in the label field and operand field together with some cpu-specific directives, like EQUR, REG, etc.
  • m68k: Optimize small data label in 020 base displacement to a 16-bit offset, or even to (d16,An) when the index is suppressed, provided that options -sd and -extsd have been given.
  • 6502: Some mnemonics could be misdetected as implied addressing mode when option -i was given: asl, asr, lsr, rol, ror. 45GS02: aslq, asrq, deq, inq, lsrq, rolq, rorq. WDC02: dec, inc.
  • mot-syntax: Do not allow a section with the same name and same type, but with different memory attributes.
  • mot-syntax: New option -nolocpfx to disable local symbols by label- prefix (usually '.').
  • mot-syntax: ELIF directive implements a real else-if.
  • mot-syntax: Export equate symbols with double-colon in vasm-native mode.
  • std-syntax: Fixed an issue caused by the introduction of one-digit temporary labels in V1.9a. Labels beginning with _f or _b were misdetected as forward/backward references to such labels.
  • std-syntax: Added missing .elseif directive.
  • oldstyle-syntax: All byte-directives (byt, byte, dfb, etc.) increment the pc by one without any operand. All word-directives (wor, wrd, word, etc.) increment the pc by two without any operand. Similar to a "declare storage" directive.
  • oldstyle-syntax: Whitespace between a label and its colon are allowed again.
  • hunk-output: Warn about inability of Kickstart 1.x to initialize BSS sections greater than 256k.
  • bin-output: ORIC file names in the tape header are limited to 15 characters and a ".tap" extension is removed automatically.
  • bin-output: Added support for the PGX and PGZ format, used by 65816- based C256 Foenix computers.
  • tos-output: Support DRI-format object files. New option: -Fdri.

$Id: index.php,v 1.16 2023/09/30 11:49:53 frank Exp $