---------------------------------------------------------------------------------- Z80-ASM(1) Z80 Assembler Z80-ASM(1) NAME z80-asm - command-line Z80 CPU assember for Unix and DO$ SYNOPSIS z80-asm [-wh] inputfile startaddress[:length]:outputfile [startad­ dress[:length]:outputfile ...] DESCRIPTION z80-asm is a double pass compiler of the Z80 CPU assembly language. It's first argument is name of an input (source) file. Then follows at least one couple (or trinity): start address, (length, )filename. This cou­ ple/trinity tells compiler to save code to file filename from address start address and with len length. Format of the file is described in z80-file(5). If length is ommited, compiler saves code from start address to furthest byte stored to memory (inclusive). All addresses are in range from 0 to 65535. For assembler syntax see section z80-asm(5). OPTIONS Compiler called with no options or -h option prints usage. Option -w turns on warning messages, when overwriting code in memory. AUTHORS Z80-ASM was written by Brainsoft . COPYING Copying of this software must be under terms of the GNU General Public License. There's absolutely no warranty on this software. For more details see file doc/COPY (c) 1999-2000 Brainsoft ---------------------------------------------------------------------------------- Z80-ASM(5) Assembly language description Z80-ASM(5) NAME description of the z80-asm assembly language DESCRIPTION Source code compounds of lines. Each line contains max. one instruc­ tion. Line can be divided into three parts: label, instruction and arguments. These parts are separated with whitespace (whitespace one or more tab, space or comma), arguments are separated with whitespace too. Excepting strings whole line is case insensitive. INSTRUCTIONS Assembler accepts usual Z80 instructions: adc, add, and, bit, call, ccf, cp, cpd, cpdr, cpi, cpir, cpl, daa, dec, di, djnz, ei, ex, exx, halt, im, in, inc, ind, ini, indr, inir, jp, jr, ld, ldd, ldi, lddr, ldir, neg, nop, or, otdr, otir, out, outd, outi, pop, push, res, ret, reti, retn, rl, rla, rlc, rlca, rld, rr, rra, rrc, rrca, rrd, rst, sbc, scf, set, sla, sra, sub, xor and special (not Z80) instructions: * org - org accepts one adderss argument; it tells the compiler to write following code to memory from mentioned address; if there's no org instruction at the start of the source, assembler stores code from address 0 * defb - defb means 8-bit data; after defb instruction follow discretionary number of 8-bit numbers (or character constants); * defw - defw is simmilar to defb; it means 16-bit data; this instruction takes 16-bit numbers as arguments * defs - defs is only instruction accepting string arguments; it accepts arbitrary number of strings; strings are stored in memory character after character as they're written in string Instruction argument can be on of following: * number or character constant * register * flag * string * label * indirect (number, label or index registers) NUMBERS Assembler accepts integer numbers in binary, decimal, hexadecimal scale. Binary number is prefaced with % (per cent character), decimal num­ bers are without prefix and hexadecimal numbers are prefaced with 0x prefix. Number can be also a character constant. Character constants are quoted in ' apostrophes ' apostrophes there's exactly one letter. Character constants are considered as an unsigned eight-bit number. Numbers (except for character constants) can also be negative. Nega­ tive numbers can be created with writing - (minus) symbol in front of the number (binary, decimal or hexadecimal). For example: -0x29a, -%10011011, -1234 STRINGS Strings are written in quotes. Inside quotes are allowed all charac­ ters 32-255 excepting quote character. Strings are allowed only with defs instruction. String example: "hello world" FLAGS Assembler uses standard Z80 flags: C, NC, Z, NZ, P, M, PE, PO. Mean­ ing is in sequence carry, non carry, zero, non zero, plus, minus, parity even and parity odd. REGISTERS Standard Z80 registers are allowed: 8-bit registers: A, F, B, C, D, E, H, L, I, R 16-bit registers: AF, AF', BC, DE, HL, IX, IY, SP LABELS Label is declared with writing it at the beginning of a line, no character (nor whitespace) can precede. Label is a string containing no whitespaces, it must be different from any numbers, registers and flags. Label is separated from instruction with whitespace. There's no colon needed behind label. If you want to use label as an instruction argument, you simply write the label string. Labels can be usedas arguments before they're declared. Label example: cycle djnz cycle test1 sub 10 cp 42 jr z,ok COMMENTS A comment start with a ; (semicolon) character and end at the end of a line. Comments are ignored, they're only for programmer's use. SEE ALSO z80-asm(1), z80-dis(1), z80-file(5) ---------------------------------------------------------------------------------- Z80-ASM(5) File format Z80-ASM(5) NAME description of file format used by z80-asm DESCRIPTION The file conpounds of header, address and data. HEADER Header is 8 bytes long. It contains string Z80ASM (6 bytes - without trailing zero) followed by 0x1a character and newline character ( 0x0a ). The 0x1a character is to persuade DO$ viewers to stop viewing the file. The newline character terminates the header. ADDRESS Address follows the header. It's 16-bit address of the program start. The less significant byte comes first, most significant byte follows. DATA Data come after address. Data are raw compiled program. Length of data can be simply calculated: length of file-10 bytes. SEE ALSO z80-asm(1), z80-dis(1), z80-asm(5)