The z80masm program, installed as part of this module, calls the z80asm_file() function to assemble an input source file, generates an output binary file, and produce an assembly listing on standard output.

The program identifiers must start with a letter or underscore, and consist solely of letters, underscores and numbers. There is a special case $ identifier that represents the current location counter.

Identifiers are returned with case preserved, i.e. the assembler is case-sensitive for labels and case-insensitive for assembly reserved words.

Numbers are converted to decimal base from one of the following formats:

Decimal numbers are sequences of the digits 0..9, e.g. 159.

Hexadecimal number are sequences of the digits 0..9 and letters A..F, prefixed by one of 0x, $ or #; or prefixed by a zero digit, if the number starts by a letter, and suffixed by a H character, e.g. 0xFA21, 0FA21H, 10H, $FA21, #FA21.

Binary numbers are sequences of the digits 0..1, prefixed by one of 0b or %; or suffixed by B, e.g. 0b10, 10B, %10.

The DJNZ and JR instructions take an address as their destination, not an offset. If you need to use an offset, do sums on $. Note that $ is the address of the *current* instruction. The offset needs to be calculated from the address of the *next* instruction, which for these instructions is always $ + 2.

A relative jump instruction can always be used. The assembler automatically replaces it with an absolute jump if the distance is too far, or if the given flag is not available, e.g. jr po,NN. A djnz NN instruction is converted to dec b:jp nz,NN if the distance is too far.

Labels are created having the value of the address they are created at.

Alternatively labels may be assigned expressions by using equ or =. The expressions use the Perl operators and can refer to other labels by name, even if they are defined further on the file. The $ can be used in the expression to represent the current location counter.

Tell the assembler to start building the code at this address. If it is not the first instruction of the assembly, the gap to the previous location counter is filled with $CPU::Z80::Assembler::fill_byte. If absent, defaults to 0x0000.

This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively.