<--  back   Last regenerated: 2022-04-20 17:31:36 kio

zasm - Z80 Assembler – Version 4.4

Quick Overview

Features

zasm is an assembler for the Command Line Options: --z80
Pseudo instructions: .z80, .z180 and .8080
Targets: #target Z80
Z80 CPU
.
It can also assemble code for the extended instruction Pseudo instructions: defl, set and '='
Labels: SET
set of the Command Line Options: --z180
Pseudo instructions: .z80, .z180 and .8080
Z180 / Hitachi HD64180, as well as code limited to the Intel 8080 e.g. for CP/M.
zasm can also assemble native 8080 assembler source.
By the help of sdcc zasm can include c source files. A trimmed version of sdcc is available from the download page.
zasm can create binary, Intel Hex or Motorola S19 files and various special files for Sinclair and Jupiter Ace emulators:

ZX Spectrum: .sna .Command Line Options: --z80
Pseudo instructions: .z80, .z180 and .8080
Targets: #target Z80
z80 .tap
Jupiter Ace: .ace .Command Line Options: --z80
Pseudo instructions: .z80, .z180 and .8080
Targets: #target Z80
z80¹ .tap
ZX80: .o / .80 .Command Line Options: --z80
Pseudo instructions: .z80, .z180 and .8080
Targets: #target Z80
z80¹
ZX81: .p / .81 / .p81 .Command Line Options: --z80
Pseudo instructions: .z80, .z180 and .8080
Targets: #target Z80
z80¹

zasm can translate the character Pseudo instructions: defl, set and '='
Labels: SET
set for the target system, e.g. for the ZX80 and ZX81.
The list file can include accumulated cpu cycles.
Various historically used syntax variants and the syntax emitted by sdcc are supported.
Multiple code and data segments can be defined, nested conditional assembly and nested Assembler directives: #local, #endlocal, .local and .endlocal
Pseudo instructions: #local, #endlocal, .local and .endlocal
Including C Source Files: #local, #endlocal, .local and .endlocal
local scopes are available.
Last not least, zasm supports Pseudo instructions: macro, .macro, endm and .endm
8080 pseudo instructions: MACRO
macros
.

¹) eventually only supported by zxsp.

Typical invocation

Compile the file "emuf_rom.asm" and store a plain list file without generated opcodes and the output file in the same folder. The source file may include other files, either binary, assembler sources or c files:

zasm emuf_rom.asm

Include generated opcodes, accumulated cpu cycles and a labels listing in the list file:

zasm -uwy emuf_rom.asm

Assemble source for the Intel 8080 assembler:

zasm --asm8080 emuf8080_rom.asm

Source file examples

The source file must be either 7-bit ascii or utf-8 encoded. Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
If you still use a legacy encoding for your text files then this is OK Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
if non-ascii characters occure only in comments. You just won't be able to put non-ascii characters in strings or character literals.

Line breaks in the source file may use any well known format, but the text files generated by zasm will use newline (character 0x0A) only.

Basic source file which does not set a target. Instruction 'org' is required:
; my little EMUF
 
; define some Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels: anton Pseudo instructions: equ
Types of labels: Named values
Labels: EQU
equ 66 berta Pseudo instructions: equ
Types of labels: Named values
Labels: EQU
equ 88   ; define code: org 0 reset: di jp _init   org 8 printc: jp _printc   ...   ; pad file to eprom size: Pseudo instructions: defs, ds, .ds, .block, .blkb and data
8080 pseudo instructions: DS
ds 0x2000 - $
Basic source file which sets a target and uses code and data segments:
; my little EMUF
 
#target rom
 
; define a data segment in ram and therein some variables:
 
Assembler directives: #data
Including C Source Files: #data
#data _SYSVARS,0x4000   anton data 2 berta data 4 caesar data 1   ; define a code segment for an eprom:   Assembler directives: #code
Including C Source Files: #code
#code _EPROM,0,0x4000   reset: di jp _init   org 8 printc: jp _printc   ...

Differences from v3 to v4

Command line options

The command line options have changed: start zasm with no options to see a summary.

See chapter 'Differences from v3 to v4: Command line options
Command Line Options
Command Line Options: Command line options
Command line options' for details.

Include C sources

zasm 4.0 can include c source files, with the help of sdcc. A trimmed version of sdcc for OSX can be found on the zasm download page.

C source files are #included just like assembler source files. They are compiled using sdcc and the output file is #included into the total source.

After the last included files you can use '#include: #include library
#include: #include library
#include library' to resolve undefined Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels from the system library or any other library directory.

See chapter 'Including C source files' for details.

Assemble 8080 assembler source

zasm 4.0 can assemble native 8080 assembler source files Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
if it is invoced with Differences from v3 to v4: Command line options
Command Line Options
Command Line Options: Command line options
command line option '--asm8080'.

See chapter '8080 Assembler' for details.

#code and #data

The syntax for Assembler directives: #code
Including C Source Files: #code
#code
and Assembler directives: #data
Including C Source Files: #data
#data
has changed. To support the c compiler an additional first argument, the segment name, is now required and multiple code and data segments are allowed. E.g.:

Assembler directives: #code
Including C Source Files: #code
#code _NAME, _start, _size

It is possible to switch to any defined segment at any time using Assembler directives: #code
Including C Source Files: #code
#code, Assembler directives: #data
Including C Source Files: #data
#data or .area with the name as a single argument.

Pseudo instructions
8080 Assembler: 8080 pseudo instructions
Pseudo instruction 'data' is still available but must only be used after the source explicitely switched to a data segment.

For simple projects it is still possible to use the traditional style with just defining an org at the start of the source file, which was possible with recent versions of v3, but v4 no longer complains about it.

See chapter Assembler directives: #target
Including C Source Files: #target
#target, #code and #data for details.

New handling of 'org'

Instead of using Assembler directives: #target
Including C Source Files: #target
#target and Assembler directives: #code
Including C Source Files: #code
#code, you can use org in the traditional way to Pseudo instructions: defl, set and '='
Labels: SET
set the origin of your code. This is done by the first 'org' instruction in your source which must preceed any code generating instruction. (As it was also possible with recent versions of v3.)

The behavior of org inside code has changed: in v4 it does insert space up to the requested new address. For the old behavior to just Pseudo instructions: defl, set and '='
Labels: SET
set a new logical code origin use the new Pseudo instructions
8080 Assembler: 8080 pseudo instructions
pseudo instructions .phase and .dephase.

See chapter 'org' for details.

Source layout for various targets

The required layout of Assembler directives: #code
Including C Source Files: #code
#code segments for some targets has changed and some targets are supported in v4 for the first time.

Supported targets in v4:

BIN, ROM, SNA, Command Line Options: --z80
Pseudo instructions: .z80, .z180 and .8080
Targets: #target Z80
Z80, TAP (ZX Spectrum and Jupiter Ace), O/80, P/81/P81, ACE, TZX

See chapter 'Targets' for details.

Macros and rept

Pseudo instructions: macro, .macro, endm and .endm
8080 pseudo instructions: MACRO
Macros
and Pseudo instructions: rept, .rept, endm and .endm
8080 pseudo instructions: REPT
rept
are now supported. zasm also supports 'defl' and 'Pseudo instructions: defl, set and '='
Labels: SET
set' for redefinable Pseudo instructions: Label definition
Numeric expressions: Labels
8080 Assembler: Labels
labels and conditional code ranges in Pseudo instructions: macro, .macro, endm and .endm
8080 pseudo instructions: MACRO
macros with 'Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
if' and 'Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
endif'. Arguments which break normal syntax rules can be passed with '<' … '>'.

See chapter 'Pseudo instructions: macro, .macro, endm and .endm
8080 pseudo instructions: MACRO
macro' for details.

Misc. other features

The list file can include accumulated cpu cycles: see Differences from v3 to v4: Command line options
Command Line Options
Command Line Options: Command line options
command line option --cycles.

Assembler directives: #local, #endlocal, .local and .endlocal
Pseudo instructions: #local, #endlocal, .local and .endlocal
Including C Source Files: #local, #endlocal, .local and .endlocal
#localAssembler directives: #local, #endlocal, .local and .endlocal
Pseudo instructions: #local, #endlocal, .local and .endlocal
Including C Source Files: #local, #endlocal, .local and .endlocal
#endlocal for nested Assembler directives: #local, #endlocal, .local and .endlocal
Pseudo instructions: #local, #endlocal, .local and .endlocal
Including C Source Files: #local, #endlocal, .local and .endlocal
local scopes.

#charset for automatic conversion of strings and character literals into the target's character Pseudo instructions: defl, set and '='
Labels: SET
set.

Limit instructions and registers to the 8080 with Differences from v3 to v4: Command line options
Command Line Options
Command Line Options: Command line options
command line option --8080.

Enable additional instructions of the Command Line Options: --z180
Pseudo instructions: .z80, .z180 and .8080
Z180 / HD64180.

Pseudo instructions
8080 Assembler: 8080 pseudo instructions
Pseudo instructions can be written in many variants for compiling old sources without modifications.

Many convenience 'compound' opcodes like "ld a,(hl++)" or "ld bc,de"

Function 'opcode(opcodename)' to get the major byte of an opcode.

Multiple opcodes per line separated with '\'.

Valid HTML   Valid CSS