vasm

A portable and retargetable assembler.
Valid HTML 4.01!
About vasm
Last release source
Daily source snapshot
Binary releases
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:
  • M680x0 family (including M6888x, M68851 and CPU32)
  • ColdFire family (all models of V2, V3, V4, V4e)
  • 80x86 family (IA32 8/16/32 bit, using MIT-syntax)
  • PowerPC (all models)
  • ARM (most models, including THUMB mode)
  • Z80 family (Z80, 8080, GBZ80, 64180, RCM2/3/4k)
  • C16x/ST10
  • 6502
These syntax flavours are supported:
  • Standard MIT (GNU-as style) syntax
  • Motorola/Freescale 68k syntax (Devpac compatible)
  • Old 8-bit style syntax
Supported output file formats:
  • ELF (M68k, PowerPC, i386 and ARM)
  • a.out (M68k and i386)
  • Amiga hunk format (M68k)
  • TOS executable format (M68k)
  • EHF extended hunk format (PowerPC)
  • Raw, binary output (all)
  • VOBJ proprietary versatile object format (all)
  • Test, debugging output (all)


10-Dec-2011: vasm 1.5c.
  • Define a __VASM symbol to identify the assembler.
  • Reworked sources to use typedefs from stdint.h where appropriate.
  • Fixed vobjdump to regard all information from an object as unsigned, except symbol values and reloc addends and masks.
  • m68k: Assign the current cpu/fpu/mmu type to the __VASM symbol.
  • m68k: Define the __G2 symbol in Devpac compatibility mode.
  • ARM: Fixed U-bit handling and sign in load/store addressing modes dealing with labels (which are translated into PC-relative).
  • ARM: The I-bit in halfword transfers must be flipped.
  • z80: Fixed error message when 8-bit data is out of range (-128 .. 255).
  • z80: Allow the offset to be an external symbol in ld (ix+offset).
  • z80: Accept JP HL besides JP (HL), as most (?) assemblers do for convenience.
  • std-syntax: Section ".text","acrwx" is default when no .section or .org directive is present.
  • oldstyle-syntax: Section ".text","acrwx" is default when no SECTION or ORG directive is present.
  • oldstyle-syntax: A section directive without attribute defaults to "acrwx".
  • oldstyle-syntax: New option -autoexp to automatically export all non-local symbols.


05-Aug-2011: vasm 1.5b.
  • m68k: Fixed -no-opt option.
  • m68k: Fixed the (hopefully) last possibility for oscillating branch optimizations. Example: bra lab; bra lab; lab:
  • x86: Enabled experimental 64-bit support. The new option -m64 allows the usage of 64-bit instructions. New directive .code64.
  • 6502: Fixed ASL, ROR and ROL with addressing mode ABS,X (by Mauricio M. Lucero).
  • 6502,z80: Support /256 %256 and &255 operations with labels and generate the appropriate relocations (Dominic Morris).
  • z80: Bad relocations are now flagged by the correct error message.
  • elf-output: Support for ELF64 and x86_64 relocations.


01-Apr-2011: vasm 1.5a.
  • Fixed -nocase option to make it no longer modify external symbol names, which then broke linking.
  • Made IfDef and IfNotDef directives work with local symbols.
  • Additionally to the standard \@ to insert a unique ID within a macro the symbols \@! and \@@ are supported to put the current ID onto the stack or pull the last ID from the stack.
  • PPC: Fixed detection of missing and extra operands.
  • m68k: FPU register names may be used for symbols, as long as no FPU code generation was enabled.
  • m68k: Fixed a branch optimization bug, which occurs when the effect of all translations is nullified, so that no label changes its address in one pass.
  • oldstyle-syntax: Fixed pc-symbol ('*') assignments. "* = <addr>" didn't work in the first column.
  • mot-syntax: Do not crash on PRINTT without operand, but just print a newline.
  • mot-syntax: Dots ('.') are allowed everywhere in the label, not only at the beginning, when either the -devpac option or the new -ldots option was specified.
  • mot-syntax: Any local symbol in the source can be referenced using the global_name\local_name syntax, as in PhxAss.
  • mot-syntax: When OUTPUT is used with ".name" then it is not only appended to the output name, but it also replaces a possible extension in it (Devpac compatibility).
  • mot-syntax: Option -localu makes local symbols start with an underscore instead of a dot (from Devpac).
  • output-vobj: A file without sections no longer causes an internal error.


01-Dec-2010: vasm 1.5.
  • A "\\" inside a macro has to be replaced by "\" when the assembler is in a mode without escape-code handling (e.g. Devpac-compatibility).
  • When the syntax module supports CARG, then \., \+ and \- are accepted to select a macro parameter with the index of the CARG-symbol. \+ will post-increment CARG and \- post-decrement it (PhxAss compatibility).
  • Space objects are allowed to use a relocation as fill pattern. Enhanced all output modules to support space-relocations.
  • Immediately close input files, after reading them in. So they are available for modification before the first assembler pass starts.
  • In case of an error or warning the respective source text line is now printed below the message.
  • Print a short report about sections and their size, when successfully finishing assembly in verbose mode.
  • m68k: Fixed a crash when using the ColdFire SATS instruction with optimization enabled.
  • m68k: Define symbols __CPU, __FPU and __MMU in PhxAss-compatibility mode, according to the current cpu setting.
  • m68k: Support Devpac optimizations OPT o3 - o12. Generic vasm optimizations are no longer active in Devpac-compatibility mode. They can be controlled with the new "OPT og" directive.
  • m68k: Support optimizations which result in multiple instructions in a clean way. Fixed the "LEA (d32,An),Am" and "Bcc out of range" hacks to make use of it.
  • m68k: New optimization: <op>.L #x,An is optimized to <op>.W #x,An when x fits into a word. This mainly affects CMP instructions, as MOVE, ADD and SUB were already handled in previous versions.
  • m68k: New optimization: LEA (d,An),An is optimized to ADDQ/SUBQ #d,An.
  • m68k: New optimization: ASL #1 is optimized to ADD and ASL #2 (byte/word only) into two ADDs. LSL will also be optimized, when the new option -opt-lsl is given.
  • m68k: New optimization: MULU/MULS.L #x,Dn can be optimized into LSL/ASL when x is a power of 2 and between 0 and 256. Negative values are handled by appending a NEG.L. MULU.W is supported for ColdFire ISA_B/C by MVZ.W. MULS.W by using EXT.L first. The new option is called -opt-mul.
  • m68k: New optimization: MOVEM with two registers is translated into two separate MOVE instructions. Requires -opt-movem option, as long as not only address registers are loaded.
  • m68k: New optimization under -opt-fconst: FDIV #m,FPn is optimized to FMUL #1/m,FPn when m is a power of 2 (i.e. the mantissa is zero).
  • m68k: New optimization: LINK An,#0 is optimized to PEA (An) and MOVE.L A7,An.
  • m68k: New ColdFire optimization: MVZ/MVS #x,Dn to MOVEQ #x,Dn.
  • m68k: The new optimization flag -opt-speed makes vasm optimize for speed, even if this would increase the code size (Example: asl.l #2,Dn -> add Dn,Dn + add Dn,Dn for 68000-68040).
  • m68k: Bugfix: MOVEM #list,<ea> and MOVEM <ea>,#list were never optimized.
  • m68k: MOVE SR/CCR instructions were not recognized for ColdFire.
  • m68k: ColdFire ISA_B allows #<xxx>,(d16,An) for MOVE.B and MOVE.W.
  • m68k: MOVEC should not warn about a correct .L operation size.
  • m68k: MOV3Q is only available for ColdFire ISA_B and ISA_C. Also don't optimize to MOV3Q for ISA_A.
  • m68k: The OPT directive supports vasm-specific extensions for optimizations not known to Devpac (-opt-movem/clr/pea/st/lsl/mul/fconst/brajmp/speed).
  • m68k: OPT p=<type> has to support multiple types, separated by a '/'.
  • m68k: New directive INITNEAR (from PhxAss). For simplicity it will always generate a reference to _LinkerDB.
  • m68k: Fixed the CPU directives to recognize ColdFire v2, v3, v4, v4e and made it case-insensitive.
  • m68k: Made -opt-fconst work with FMOVE.D #0,FPn.
  • m68k: PC-relative optimization didn't work for "TST label" and cpu>=68020.
  • m68k: New option -showcrit. Similar to -showopt, but only shows optimizations which may have side effects (refer to the documentation).
  • m68k: Bad extension warning (2006) has become an error.
  • z80: Implemented a lo/hi-byte operator similar to 6502.
  • z80: Relative jumps over a distance of more than 128 bytes must cause an error message.
  • mot-syntax: Supports CARG.
  • mot-syntax: IF directives support the current-pc symbol (*).
  • mot-syntax: Support REM and EREM from AsmOne, to skip everything between those two directives.
  • mot-syntax: Up to 36 macro arguments in PhxAss-compatibility mode.
  • mot-syntax: Support CODE_C, DATA_C, BSS_C (and the *_F-variants).
  • oldstyle-syntax: EQU and SET should be case-insensitive, like the rest of the directives.
  • oldstyle-syntax: Fixed ORG for the case when '$' is used as a hex-prefix and the current-pc-symbol at the same time (Z80).
  • oldstyle-syntax: Also support local symbols starting with a '.'.
  • hunk-output: Fixed -databss option, which didn't recognize DCB/BLK directives with a non-zero fill pattern.


02-Aug-2010: vasm 1.4f.
  • The parser accepts "\n", "\r\n", "\n\r" and a single "\r" as line-endings.
  • Avoid infinite loop when a source line is too long.
  • Constant block directives (e.g. DCB in mot-syntax) allow any kind of expression for the fill-value now.
  • Fixed constant block directives with a size > 8 bytes (e.g. DCB.X).
  • Quit with an error when a section needs too many passes to resolve. This happens when the user does something stupid like start: .space end-start end:
  • Ignore rest of the line after an end-macro or end-repetition directive.
  • Support for the Seka/AsmOne ~ binary-operator, which is a synonym for ^ (exclusive-or).
  • m68k: Also accept ([An,bd]...) instead of ([bd,An]...) for Devpac/AsmOne compatibility.
  • m68k: Recognize linea, line_a, linef and line_f mnemonics.
  • m68k: Make BASEREG directive only take effect when a program label was referenced together with a register (i.e. not with (4,A5)).
  • mot-syntax: Allow up to 35 macro parameters in Devpac compatibility mode.
  • mot-syntax: Accept macro-names starting with a dot. But even then they are still of global scope.
  • mot-syntax: RORG directive.
  • mot-syntax: Support for PRINTT and PRINTV from AsmOne and ECHO from PhxAss.
  • mot-syntax: DR directive from AsmOne to build PC-relative data tables.
  • mot-syntax: New directives: ODD, PAGE, NOPAGE, IMAGE (same as INCBIN).
  • mot-syntax: Directives ENTRY, EXTRN and GLOBAL are recognized and are identical to XDEF.
  • mot-syntax: Some directives without any function just for compatbility: JUMPERR, MASK2, LLEN, SPC.


09-Jun-2010: vasm 1.4e.
  • m68k: Fixed some problems with fmovem when using register list symbols.
  • m68k: fsmove and fdmove were missing the coprocessor ID 1 in their opcodes.
  • m68k: fsmove/fsmove FPn,FPm addressing mode was missing.
  • m68k: Fixed moves <ea>,Rn.
  • std-syntax: n$ is recognized as local symbol.
Aktion UBERWACH!

$Id: index.php,v 1.10 2011/02/07 12:49:28 frank Exp $