
PR 25224 bfd * Makefile.am: Add z80-elf target support. * configure.ac: Likewise. * targets.c: Likewise. * config.bfd: Add z80-elf target support and new arches: ez80 and z180. * elf32-z80.c: New file. * archures.c: Add new z80 architectures: eZ80 and Z180. * coffcode.h: Likewise. * cpu-z80.c: Likewise. * bfd-in2.h: Likewise plus additional Z80 relocations. * coff-z80.c: Add new relocations for Z80 target and local label check. gas * config/tc-z80.c: Add new architectures: Z180 and eZ80. Add support for assembler code generated by SDCC. Add new relocation types. Add z80-elf target support. * config/tc-z80.h: Add z80-elf target support. Enable dollar local labels. Local labels starts from ".L". * testsuite/gas/all/fwdexp.d: Fix failure due to symbol conflict. * testsuite/gas/all/fwdexp.s: Likewise. * testsuite/gas/z80/suffix.d: Fix failure on ELF target. * testsuite/gas/z80/z80.exp: Add new tests * testsuite/gas/z80/dollar.d: New file. * testsuite/gas/z80/dollar.s: New file. * testsuite/gas/z80/ez80_adl_all.d: New file. * testsuite/gas/z80/ez80_adl_all.s: New file. * testsuite/gas/z80/ez80_adl_suf.d: New file. * testsuite/gas/z80/ez80_isuf.s: New file. * testsuite/gas/z80/ez80_z80_all.d: New file. * testsuite/gas/z80/ez80_z80_all.s: New file. * testsuite/gas/z80/ez80_z80_suf.d: New file. * testsuite/gas/z80/r800_extra.d: New file. * testsuite/gas/z80/r800_extra.s: New file. * testsuite/gas/z80/r800_ii8.d: New file. * testsuite/gas/z80/r800_z80_doc.d: New file. * testsuite/gas/z80/z180.d: New file. * testsuite/gas/z80/z180.s: New file. * testsuite/gas/z80/z180_z80_doc.d: New file. * testsuite/gas/z80/z80_doc.d: New file. * testsuite/gas/z80/z80_doc.s: New file. * testsuite/gas/z80/z80_ii8.d: New file. * testsuite/gas/z80/z80_ii8.s: New file. * testsuite/gas/z80/z80_in_f_c.d: New file. * testsuite/gas/z80/z80_in_f_c.s: New file. * testsuite/gas/z80/z80_op_ii_ld.d: New file. * testsuite/gas/z80/z80_op_ii_ld.s: New file. * testsuite/gas/z80/z80_out_c_0.d: New file. * testsuite/gas/z80/z80_out_c_0.s: New file. * testsuite/gas/z80/z80_reloc.d: New file. * testsuite/gas/z80/z80_reloc.s: New file. * testsuite/gas/z80/z80_sli.d: New file. * testsuite/gas/z80/z80_sli.s: New file. ld * Makefile.am: Add new target z80-elf * configure.tgt: Likewise. * emultempl/z80.em: Add support for eZ80 and Z180 architectures. * emulparams/elf32z80.sh: New file. * emultempl/z80elf.em: Likewise. * testsuite/ld-z80/arch_ez80_adl.d: Likewise. * testsuite/ld-z80/arch_ez80_z80.d: Likewise. * testsuite/ld-z80/arch_r800.d: Likewise. * testsuite/ld-z80/arch_z180.d: Likewise. * testsuite/ld-z80/arch_z80.d: Likewise. * testsuite/ld-z80/comb_arch_ez80_z80.d: Likewise. * testsuite/ld-z80/comb_arch_z180.d: Likewise. * testsuite/ld-z80/labels.s: Likewise. * testsuite/ld-z80/relocs.s: Likewise. * testsuite/ld-z80/relocs_b_ez80.d: Likewise. * testsuite/ld-z80/relocs_b_z80.d: Likewise. * testsuite/ld-z80/relocs_f_z80.d: Likewise. * testsuite/ld-z80/z80.exp: Likewise. opcodes * z80-dis.c: Add support for eZ80 and Z80 instructions.
323 lines
10 KiB
Text
323 lines
10 KiB
Text
@c Copyright (C) 2011-2020 Free Software Foundation, Inc.
|
|
@c This is part of the GAS manual.
|
|
@c For copying conditions, see the file as.texinfo.
|
|
|
|
@ifset GENERIC
|
|
@page
|
|
@node Z80-Dependent
|
|
@chapter Z80 Dependent Features
|
|
@end ifset
|
|
|
|
|
|
@ifclear GENERIC
|
|
@node Machine Dependencies
|
|
@chapter Z80 Dependent Features
|
|
@end ifclear
|
|
|
|
@cindex Z80 support
|
|
@menu
|
|
* Z80 Options:: Options
|
|
* Z80 Syntax:: Syntax
|
|
* Z80 Floating Point:: Floating Point
|
|
* Z80 Directives:: Z80 Machine Directives
|
|
* Z80 Opcodes:: Opcodes
|
|
@end menu
|
|
|
|
@node Z80 Options
|
|
@section Options
|
|
@cindex Z80 options
|
|
@cindex options for Z80
|
|
@table @option
|
|
@cindex @code{-z80} command-line option, Z80
|
|
@item -z80
|
|
Produce code for the Z80 processor. By default accepted undocumented
|
|
operations with halves of index registers (IXL, IXH, IYL, IYH) and
|
|
instuction IN F,(C). Other useful undocumented instructions produces
|
|
warnings. Undocumented instructions may not work on some CPUs, use
|
|
them on your own risk.
|
|
|
|
@cindex @code{-r800} command-line option, R800
|
|
@item -r800
|
|
Produce code for the R800 processor.
|
|
|
|
@cindex @code{-z180} command-line option, Z180
|
|
@item -z180
|
|
Produce code for the Z180 processor.
|
|
|
|
@cindex @code{-ez80} command-line option, eZ80
|
|
@item -ez80
|
|
Produce code for the eZ80 processor in Z80 memory mode by default.
|
|
|
|
@cindex @code{-ez80-adl} command-line option, eZ80
|
|
@item -ez80-adl
|
|
Produce code for the eZ80 processor in ADL memory mode by default.
|
|
|
|
@cindex Compatibility options
|
|
@item @code{-colonless}
|
|
Accept colonless labels. All names at line begin are treated as labels.
|
|
|
|
@item @code{-sdcc}
|
|
Accept assembler code produces by SDCC.
|
|
|
|
@cindex Undocumented instruction control
|
|
@item @code{-strict}
|
|
Accept documented instructions only.
|
|
|
|
@item @code{-full}
|
|
Accept all known Z80 instructions.
|
|
|
|
@item @code{-with-inst=INST[,...]}
|
|
@itemx @code{-Wnins INST[,...]}
|
|
Enable specified undocumented instruction(s).
|
|
|
|
@item @code{-without-inst=INST[,...]}
|
|
@itemx @code{-Fins INST[,...]}
|
|
Disable specified undocumented instruction(s).
|
|
|
|
@cindex Obsolete options
|
|
@item @code{-ignore-undocumented-instructions}
|
|
@itemx @code{-Wnud}
|
|
Silently assemble undocumented Z80-instructions that have been adopted
|
|
as documented R800-instructions .
|
|
@item @code{-ignore-unportable-instructions}
|
|
@itemx @code{-Wnup}
|
|
Silently assemble all undocumented Z80-instructions.
|
|
@item @code{-warn-undocumented-instructions}
|
|
@itemx @code{-Wud}
|
|
Issue warnings for undocumented Z80-instructions that work on R800, do
|
|
not assemble other undocumented instructions without warning.
|
|
@item @code{-warn-unportable-instructions}
|
|
@itemx @code{-Wup}
|
|
Issue warnings for other undocumented Z80-instructions, do not treat any
|
|
undocumented instructions as errors.
|
|
@item @code{-forbid-undocumented-instructions}
|
|
@itemx @code{-Fud}
|
|
Treat all undocumented z80-instructions as errors.
|
|
@item -forbid-unportable-instructions
|
|
@itemx @code{-Fup}
|
|
Treat undocumented z80-instructions that do not work on R800 as errors.
|
|
@end table
|
|
|
|
Known undocumented instructions.
|
|
@table @option
|
|
@cindex Known undocumented instructions
|
|
@item @code{idx-reg-halves}
|
|
All operations with halves of index registers (IXL, IXH, IYL, IYH).
|
|
@item @code{sli}
|
|
SLI or SLL instruction. Same as @code{SLA r; INC r}.
|
|
@item @code{op-ii-ld}
|
|
Istructions like @code{<op> (<ii>+<d>),<r>}. For example: @code{RL (IX+5),C}
|
|
@item @code{in-f-c}
|
|
Instruction @code{IN F,(C)}.
|
|
@item @code{out-c-0}
|
|
Instruction @code{OUT (C),0}
|
|
@end table
|
|
|
|
@cindex Z80 Syntax
|
|
@node Z80 Syntax
|
|
@section Syntax
|
|
The assembler syntax closely follows the 'Z80 family CPU User Manual' by
|
|
Zilog.
|
|
In expressions a single @samp{=} may be used as ``is equal to''
|
|
comparison operator.
|
|
|
|
Suffices can be used to indicate the radix of integer constants;
|
|
@samp{H} or @samp{h} for hexadecimal, @samp{D} or @samp{d} for decimal,
|
|
@samp{Q}, @samp{O}, @samp{q} or @samp{o} for octal, and @samp{B} for
|
|
binary.
|
|
|
|
The suffix @samp{b} denotes a backreference to local label.
|
|
|
|
@menu
|
|
* Z80-Chars:: Special Characters
|
|
* Z80-Regs:: Register Names
|
|
* Z80-Case:: Case Sensitivity
|
|
@end menu
|
|
|
|
@node Z80-Chars
|
|
@subsection Special Characters
|
|
|
|
@cindex line comment character, Z80
|
|
@cindex Z80 line comment character
|
|
The semicolon @samp{;} is the line comment character;
|
|
|
|
If a @samp{#} appears as the first character of a line then the whole
|
|
line is treated as a comment, but in this case the line could also be
|
|
a logical line number directive (@pxref{Comments}) or a preprocessor
|
|
control command (@pxref{Preprocessing}).
|
|
|
|
@cindex line separator, Z80
|
|
@cindex statement separator, Z80
|
|
@cindex Z80 line separator
|
|
The Z80 assembler does not support a line separator character.
|
|
|
|
@cindex location counter, Z80
|
|
@cindex hexadecimal prefix, Z80
|
|
@cindex Z80 $
|
|
The dollar sign @samp{$} can be used as a prefix for hexadecimal numbers
|
|
and as a symbol denoting the current location counter.
|
|
|
|
@cindex character escapes, Z80
|
|
@cindex Z80, \
|
|
A backslash @samp{\} is an ordinary character for the Z80 assembler.
|
|
|
|
@cindex character constant, Z80
|
|
@cindex single quote, Z80
|
|
@cindex Z80 '
|
|
The single quote @samp{'} must be followed by a closing quote. If there
|
|
is one character in between, it is a character constant, otherwise it is
|
|
a string constant.
|
|
|
|
@node Z80-Regs
|
|
@subsection Register Names
|
|
@cindex Z80 registers
|
|
@cindex register names, Z80
|
|
|
|
The registers are referred to with the letters assigned to them by
|
|
Zilog. In addition @command{@value{AS}} recognizes @samp{ixl} and
|
|
@samp{ixh} as the least and most significant octet in @samp{ix}, and
|
|
similarly @samp{iyl} and @samp{iyh} as parts of @samp{iy}.
|
|
|
|
@c The @samp{'} in @samp{ex af,af'} may be omitted.
|
|
|
|
@node Z80-Case
|
|
@subsection Case Sensitivity
|
|
@cindex Z80, case sensitivity
|
|
@cindex case sensitivity, Z80
|
|
|
|
Upper and lower case are equivalent in register names, opcodes,
|
|
condition codes and assembler directives.
|
|
The case of letters is significant in labels and symbol names. The case
|
|
is also important to distinguish the suffix @samp{b} for a backward reference
|
|
to a local label from the suffix @samp{B} for a number in binary notation.
|
|
|
|
@node Z80 Floating Point
|
|
@section Floating Point
|
|
@cindex floating point, Z80
|
|
@cindex Z80 floating point
|
|
Floating-point numbers are not supported.
|
|
|
|
@node Z80 Directives
|
|
@section Z80 Assembler Directives
|
|
|
|
@command{@value{AS}} for the Z80 supports some additional directives for
|
|
compatibility with other assemblers.
|
|
|
|
@cindex Z80-only directives
|
|
These are the additional directives in @code{@value{AS}} for the Z80:
|
|
|
|
@table @code
|
|
@item assume @var{ADL}@samp{=}@var{expression}
|
|
Set ADL status for eZ80. Non-null value enable compilation ADL mode else
|
|
used Z80 mode. ADL and Z80 mode produces incompatible object code. Mixing
|
|
both of them within one binary may lead problems with disassembler.
|
|
|
|
@item db @var{expression}|@var{string}[,@var{expression}|@var{string}...]
|
|
@itemx defb @var{expression}|@var{string}[,@var{expression}|@var{string}...]
|
|
For each @var{string} the characters are copied to the object file, for
|
|
each other @var{expression} the value is stored in one byte.
|
|
A warning is issued in case of an overflow.
|
|
|
|
@item dw @var{expression}[,@var{expression}...]
|
|
@itemx defw @var{expression}[,@var{expression}...]
|
|
For each @var{expression} the value is stored in two bytes, ignoring
|
|
overflow.
|
|
|
|
@item d24 @var{expression}[,@var{expression}...]
|
|
@itemx def24 @var{expression}[,@var{expression}...]
|
|
For each @var{expression} the value is stored in three bytes, ignoring
|
|
overflow.
|
|
|
|
@item d32 @var{expression}[,@var{expression}...]
|
|
@itemx def32 @var{expression}[,@var{expression}...]
|
|
For each @var{expression} the value is stored in four bytes, ignoring
|
|
overflow.
|
|
|
|
@item ds @var{count}[, @var{value}]
|
|
@itemx defs @var{count}[, @var{value}]
|
|
@c Synonyms for @code{ds.b},
|
|
@c which should have been described elsewhere
|
|
Fill @var{count} bytes in the object file with @var{value}, if
|
|
@var{value} is omitted it defaults to zero.
|
|
|
|
@item @var{symbol} equ @var{expression}
|
|
@itemx @var{symbol} defl @var{expression}
|
|
These directives set the value of @var{symbol} to @var{expression}. If
|
|
@code{equ} is used, it is an error if @var{symbol} is already defined.
|
|
Symbols defined with @code{equ} are not protected from redefinition.
|
|
|
|
@item psect @var{name}
|
|
A synonym for @xref{Section}, no second argument should be given.
|
|
@ignore
|
|
|
|
The following attributes will possibly be recognized in the future
|
|
@table @code
|
|
@item abs
|
|
The section is to be absolute. @code{@value{AS}} will issue an error
|
|
message because it can not produce an absolute section.
|
|
@item global
|
|
The section is to be concatenated with other sections of the same name
|
|
by the linker, this is the default.
|
|
@item local
|
|
The section is not global. @code{@value{AS}} will issue a warning if
|
|
object file format is not soff.
|
|
@item ovrld
|
|
The section is to be overlapped with other sections of the same name by
|
|
the linker. @code{@value{AS}} will issue an error message
|
|
because it can not mark a section as such.
|
|
@item pure
|
|
The section is marked as read only.
|
|
@end table
|
|
@end ignore
|
|
|
|
@end table
|
|
|
|
@node Z80 Opcodes
|
|
@section Opcodes
|
|
In line with common practice, Z80 mnemonics are used for the Z80,
|
|
the Z180, eZ80 and the R800.
|
|
|
|
In many instructions it is possible to use one of the half index
|
|
registers (@samp{ixl},@samp{ixh},@samp{iyl},@samp{iyh}) in stead of an
|
|
8-bit general purpose register. This yields instructions that are
|
|
documented on the eZ80 and the R800, undocumented on the Z80 and
|
|
unsupported on the Z180.
|
|
Similarly @code{in f,(c)} is documented on the R800, undocumented on
|
|
the Z80 and unsupported on the Z180 and the eZ80.
|
|
|
|
The assembler also supports the following undocumented Z80-instructions,
|
|
that have not been adopted in any other instruction set:
|
|
@table @code
|
|
@item out (c),0
|
|
Sends zero to the port pointed to by register c.
|
|
|
|
@item sli @var{m}
|
|
Equivalent to @code{@var{m} = (@var{m}<<1)+1}, the operand @var{m} can
|
|
be any operand that is valid for @samp{sla}. One can use @samp{sll} as a
|
|
synonym for @samp{sli}.
|
|
|
|
@item @var{op} (ix+@var{d}), @var{r}
|
|
This is equivalent to
|
|
|
|
@example
|
|
ld @var{r}, (ix+@var{d})
|
|
@var{opc} @var{r}
|
|
ld (ix+@var{d}), @var{r}
|
|
@end example
|
|
|
|
The operation @samp{@var{opc}} may be any of @samp{res @var{b},},
|
|
@samp{set @var{b},}, @samp{rl}, @samp{rlc}, @samp{rr}, @samp{rrc},
|
|
@samp{sla}, @samp{sli}, @samp{sra} and @samp{srl}, and the register
|
|
@samp{@var{r}} may be any of @samp{a}, @samp{b}, @samp{c}, @samp{d},
|
|
@samp{e}, @samp{h} and @samp{l}.
|
|
|
|
@item @var{opc} (iy+@var{d}), @var{r}
|
|
As above, but with @samp{iy} instead of @samp{ix}.
|
|
@end table
|
|
|
|
The web site at @uref{http://www.z80.info} is a good starting place to
|
|
find more information on programming the Z80.
|
|
|
|
You may enable or disable any of these instructions for any target CPU
|
|
even this instruction is not supported by any real CPU of this type.
|
|
Useful for custom CPU cores.
|