VASM - A Multiplatform, multi-Target-CPU assembler!

<- Back to the Main Contents & Basic Z80 Assembly Lessons

Vasm is an open source, multi platform assembler, which can compile to the Z80, GBZ80 (gameboy CPU), 6502, 68000 and more!
Learn more about VASM

Download my Windows builds of VASM

Vasm also supports multiple syntax options, and the 'OldStyle' option is most compatible with the WinAPE code we've looked at in these tutorials, unfortunately there are some compatibility issues, but it's relatively trivial to fix them

VASM Command Line
Let's take a look at a typical VASM command line!

We need to use a different EXE build of vasm, depending on our ASM source, and destination CPU

these tutorials use OldStyle for Z80 and 6502, and MOT for 68000 (68k)

There are various other commands switches you may want to use (In order of importance)

Source FileName - This is the ASM file we want to compile
Output file - Winape can specify a destination in the ASM code, but VASM cannot, you must specify it here on the command line and type -FBin means 'binary output'
Listing - this is a TXT output of the processing of the ASM file, it's useful to debug what went wrong if you end up with a corrupt binary, or one that's much bigger than you expected
nocase - Disable case sensitivity
chklabels - make sure no ASM commands are in the label area

Special options for special CPU's:

m68000 - Specify a 680xx CPU type
gbz80 - Build for the Gameboy CPU
c02 - Build for 65C02 / HUC6270 cpu

68000 only:

ELF link - if we want to use Vlink to create an Amiga or AtariST binary, we need to set the output to -Felf, and use vlink to build to our destination
Link format - binary format vlink should output to

Stuff I use, but you don't need to:

vasm definition - This will set vasm to 1... this does the same as 'vasm equ 1' in the code, and allows us to fix things that vasm needs doing differently to WinApe in the ASM file
Build definition - the same as 'BuildZXS equ 1' in the code - I use a different batch file for each destination

Differences between VASM and WinAPE
Winape Version Corrected Vasm Ver
WinApe doesn't mind commands being at the far left, but in VASM only Labels and EQU symbol definitions can be at the left,
We need to move the ORG and RET  statement to the right
Hint: use -chklabels to warn if any commands are in label area!
Winape uses MEND or ENDM for the end of a macro, but VASM can only use ENDM
I've been putting labels for self-modifying values on the right in WinAPE, but VASM requires them to be on the next line, at the far left
in VASM Macros need to have a comma , between the macro name and the first parameter,
also parameters need a \ before them in the macro definiton,

Unfortunately WinAPE will not like this, but if you need to compile both, you can use an 'ifdef vasm' option, and have a version for winape, and one for vasm
this 'nolist' statement is being mistaken for a label, what's worse, because it's before the ORG statement, it will be considered the first data in the output, and 32k of zeros will appear at the start of your output file!
there is no such command as ex hl,de... the correct one is ex de,hl
WinAPE would let us get away with it, but VASM says no!
in WinAPE, align is done by the byte boundary... VASM works differently, you specify the bit number you want aligned, so Align 256 becomes Align 8
If you want to compile on both, you'll have to have alternate versions for WinAPE and VASM
RST's in WinAPE can be specified by address or number, but in VASM they can only be specified by address... just multiply the RST number by 8!
Vasm is Case sensitive, so we need to ensure the case matches!

*** use the -nocase option to disable case sensitivity!

Useful Macros
If you want to compile with VASM and WinAPE , you may wish to use macro's to help you

For example, when you want zeros in your output file until a certain address, in WinAPE you need a local label and defs ... but in VASM you can just use ORG

READ (including another ASM file) is INCLUDE in VASM
PRINT,WRITE,SAVE and CLOSE have no equivalent in VASM... we specify the save file on the command line, and we'll just have to do without PRINT!

As previously mentioned ALIGN does not work the same, but we can define compatible macros to compile to both.

Visit to get my games and their source code! | Support me on patreon