h1 Quick Overview overview // ––––––––––––––––––––––––––––––––––––––––––––––––– h3 Features p zasm is an assembler for the Z80 CPU. It can also assemble code for the extended instruction set of the 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: p ZX Spectrum: .sna .z80 .tap Jupiter Ace: .ace .z80¹ .tap ZX80: .o / .80 .z80¹ ZX81: .p / .81 / .p81 .z80¹ p zasm can translate the character 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 local scopes are available. Last not least, zasm supports macros. p.small ¹) eventually only supported by zxsp. // ––––––––––––––––––––––––––––––––––––––––––––––––– h3 Typical invocation p 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: pre zasm emuf_rom.asm p Include generated opcodes, accumulated cpu cycles and a labels listing in the list file: pre zasm -uwy emuf_rom.asm p Assemble source for the Intel 8080 assembler: pre zasm --asm8080 emuf8080_rom.asm // ––––––––––––––––––––––––––––––––––––––––––––––––– h3 Source file examples p The source file must be either 7-bit ascii or utf-8 encoded. If you still use a legacy encoding for your text files then this is OK if non-ascii characters occure only in comments. You just won't be able to put non-ascii characters in strings or character literals. p 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. h5 Basic source file which does not set a target. Instruction 'org' is required: pre ; my little EMUF   ; define some labels: anton equ 66 berta equ 88   ; define code: org 0 reset: di jp _init   org 8 printc: jp _printc   ...   ; pad file to eprom size: ds 0x2000 - $ h5 Basic source file which sets a target and uses code and data segments: pre ; my little EMUF   #target rom   ; define a data segment in ram and therein some variables:   #data _SYSVARS,0x4000   anton data 2 berta data 4 caesar data 1   ; define a code segment for an eprom:   #code _EPROM,0,0x4000   reset: di jp _init   org 8 printc: jp _printc   ... // ––––––––––––––––––––––––––––––––––––––––––––––––– H3 Differences from v3 to v4 h5 Command line options p The command line options have changed: start zasm with no options to see a summary. p See chapter 'Command line options' for details. h5 Include C sources p 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. p 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. p After the last included files you can use '#include library' to resolve undefined labels from the system library or any other library directory. p See chapter 'Including C source files' for details. h5 Assemble 8080 assembler source p zasm 4.0 can assemble native 8080 assembler source files if it is invoced with command line option '--asm8080'. p See chapter '8080 Assembler' for details. h5 #code and #data p The syntax for #code and #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.: pre #code _NAME, _start, _size p It is possible to switch to any defined segment at any time using #code, #data or .area with the name as a single argument. p Pseudo instruction 'data' is still available but must only be used after the source explicitely switched to a data segment. p.i 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. p See chapter #target, #code and #data for details. h5 New handling of 'org' p Instead of using #target and #code, you can use org in the traditional way to 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.) p 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 set a new logical code origin use the new pseudo instructions .phase and .dephase. p See chapter 'org' for details. h5 Source layout for various targets p The required layout of #code segments for some targets has changed and some targets are supported in v4 for the first time. p Supported targets in v4: pre.center BIN, ROM, SNA, Z80, TAP (ZX Spectrum and Jupiter Ace), O/80, P/81/P81, ACE, TZX p See chapter 'Targets' for details. h5 Macros and rept p Macros and rept are now supported. zasm also supports 'defl' and 'set' for redefinable labels and conditional code ranges in macros with 'if' and 'endif'. Arguments which break normal syntax rules can be passed with '<' … '>'. p See chapter 'macro' for details. h5 Misc. other features p The list file can include accumulated cpu cycles: see command line option --cycles. p #local … #endlocal for nested local scopes. p #charset for automatic conversion of strings and character literals into the target's character set. p Limit instructions and registers to the 8080 with command line option --8080. p Enable additional instructions of the Z180 / HD64180. p Pseudo instructions can be written in many variants for compiling old sources without modifications. p Many convenience 'compound' opcodes like "ld a,(hl++)" or "ld bc,de" p Function 'opcode(opcodename)' to get the major byte of an opcode. p Multiple opcodes per line separated with '\'.