]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/doc/c-z80.texi
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / gas / doc / c-z80.texi
index 1b24f4ab8376a41b2db99cb584306489ba0c20a0..7f974a0fe06e529e28a71ff8f98b3fe15ea2312d 100644 (file)
@@ -1,4 +1,4 @@
-@c Copyright (C) 2011-2016 Free Software Foundation, Inc.
+@c Copyright (C) 2011-2021 Free Software Foundation, Inc.
 @c This is part of the GAS manual.
 @c For copying conditions, see the file as.texinfo.
 
 @end menu
 
 @node Z80 Options
-@section Options
+@section Command-line Options
 @cindex Z80 options
 @cindex options for Z80
-The Zilog Z80 and Ascii R800 version of @code{@value{AS}} have a few machine
-dependent options.
+@c man begin OPTIONS
+@table @gcctabopt
+
+@cindex @code{-march=} command-line option, Z80
+@item -march=@var{CPU}[-@var{EXT}@dots{}][+@var{EXT}@dots{}]
+This option specifies the target processor. The assembler will issue
+an error message if an attempt is made to assemble an instruction which
+will not execute on the target processor. The following processor names
+are recognized:
+@code{z80},
+@code{z180},
+@code{ez80},
+@code{gbz80},
+@code{z80n},
+@code{r800}.
+In addition to the basic instruction set, the assembler can be told to
+accept some extention mnemonics. For example,
+@code{-march=z180+sli+infc} extends @var{z180} with @var{SLI} instructions and
+@var{IN F,(C)}. The following extentions are currently supported:
+@code{full} (all known instructions),
+@code{adl} (ADL CPU mode by default, eZ80 only),
+@code{sli} (instruction known as @var{SLI}, @var{SLL} or @var{SL1}),
+@code{xyhl} (instructions with halves of index registers: @var{IXL}, @var{IXH},
+@var{IYL}, @var{IYH}),
+@code{xdcb} (instructions like @var{RotOp (II+d),R} and @var{BitOp n,(II+d),R}),
+@code{infc} (instruction @var{IN F,(C)} or @var{IN (C)}),
+@code{outc0} (instruction @var{OUT (C),0}).
+Note that rather than extending a basic instruction set, the extention
+mnemonics starting with @code{-} revoke the respective functionality:
+@code{-march=z80-full+xyhl} first removes all default extentions and adds
+support for index registers halves only.
+
+If this option is not specified then @code{-march=z80+xyhl+infc} is assumed.
+
+@cindex @code{-local-prefix} command-line option, Z80
+@item  -local-prefix=@var{prefix}
+Mark all labels with specified prefix as local. But such label can be
+marked global explicitly in the code. This option do not change default
+local label prefix @code{.L}, it is just adds new one.
+
+@cindex @code{-colonless} command-line option, Z80
+@item  -colonless
+Accept colonless labels. All symbols at line begin are treated as labels.
+
+@cindex @code{-sdcc} command-line option, Z80
+@item  -sdcc
+Accept assembler code produced by SDCC.
+
+@cindex @code{-fp-s} command-line option, Z80
+@item -fp-s=@var{FORMAT}
+Single precision floating point numbers format. Default: ieee754 (32 bit).
+
+@cindex @code{-fp-d} command-line option, Z80
+@item -fp-d=@var{FORMAT}
+Double precision floating point numbers format. Default: ieee754 (64 bit).
+@end table
+@c man end
+
+Floating point numbers formats.
 @table @option
-@cindex @code{-z80} command line option, Z80
-@item -z80
-Produce code for the Z80 processor. There are additional options to
-request warnings and error messages for undocumented instructions.
-@item  -ignore-undocumented-instructions
-@itemx -Wnud
-Silently assemble undocumented Z80-instructions that have been adopted
-as documented R800-instructions.
-@item  -ignore-unportable-instructions
-@itemx -Wnup
-Silently assemble all undocumented Z80-instructions.
-@item  -warn-undocumented-instructions
-@itemx -Wud
-Issue warnings for undocumented Z80-instructions that work on R800, do
-not assemble other undocumented instructions without warning.
-@item  -warn-unportable-instructions
-@itemx -Wup
-Issue warnings for other undocumented Z80-instructions, do not treat any
-undocumented instructions as errors.
-@item  -forbid-undocumented-instructions
-@itemx -Fud
-Treat all undocumented z80-instructions as errors.
-@item  -forbid-unportable-instructions
-@itemx -Fup
-Treat undocumented z80-instructions that do not work on R800 as errors.
-
-@cindex @code{-r800} command line option, Z80
-@item -r800
-Produce code for the R800 processor. The assembler does not support
-undocumented instructions for the R800.
-In line with common practice, @code{@value{AS}} uses Z80 instruction names
-for the R800 processor, as far as they exist.
+@item @code{ieee754}
+Single or double precision IEEE754 compatible format.
+
+@item @code{half}
+Half precision IEEE754 compatible format (16 bits).
+
+@item @code{single}
+Single precision IEEE754 compatible format (32 bits).
+
+@item @code{double}
+Double precision IEEE754 compatible format (64 bits).
+
+@item @code{zeda32}
+32 bit floating point format from z80float library by Zeda.
+
+@item @code{math48}
+48 bit floating point format from Math48 package by Anders Hejlsberg.
 @end table
 
 @cindex Z80 Syntax
@@ -83,6 +125,7 @@ The suffix @samp{b} denotes a backreference to local label.
 * Z80-Chars::                Special Characters
 * Z80-Regs::                 Register Names
 * Z80-Case::                 Case Sensitivity
+* Z80-Labels::               Labels
 @end menu
 
 @node Z80-Chars
@@ -142,61 +185,122 @@ 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-Labels
+@subsection Labels
+
+@cindex labels, Z80
+@cindex Z80 labels
+Labels started by @code{.L} acts as local labels. You may specify custom local
+label prefix by @code{-local-prefix} command-line option.
+Dollar, forward and backward local labels are supported. By default, all labels
+are followed by colon.
+Legacy code with colonless labels can be built with @code{-colonless}
+command-line option specified. In this case all tokens at line begin are treated
+as labels.
+
 @node Z80 Floating Point
 @section Floating Point
 @cindex floating point, Z80
 @cindex Z80 floating point
-Floating-point numbers are not supported.
+Floating-point numbers of following types are supported:
+
+@table @option
+@item @code{ieee754}
+Supported half, single and double precision IEEE754 compatible numbers.
+
+@item @code{zeda32}
+32 bit floating point numbers from z80float library by Zeda.
+
+@item @code{math48}
+48 bit floating point numbers from Math48 package by Anders Hejlsberg.
+@end table
 
 @node Z80 Directives
 @section Z80 Assembler Directives
+@cindex Z80-only 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 db @var{expression}|@var{string}[,@var{expression}|@var{string}...]
-@itemx defb @var{expression}|@var{string}[,@var{expression}|@var{string}...]
+@item @code{.assume ADL = @var{expression}}
+@cindex @code{.assume} directive, Z80
+Set ADL status for eZ80. Non-zero value enable compilation in 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 @code{db @var{expression}|@var{string}[,@var{expression}|@var{string}...]}
+@cindex @code{db} directive, Z80
+@itemx @code{defb @var{expression}|@var{string}[,@var{expression}|@var{string}...]}
+@cindex @code{defb} directive, Z80
+@itemx @code{defm @var{string}[,@var{string}...]}
+@cindex @code{defm} directive, Z80
 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.
+Backslash symbol in the strings is generic symbol, it cannot be used as
+escape character.  @xref{Ascii,,@code{.ascii}}.
 
-@item dw @var{expression}[,@var{expression}...]
-@itemx defw @var{expression}[,@var{expression}...]
+@item @code{dw @var{expression}[,@var{expression}...]}
+@cindex @code{dw} directive, Z80
+@itemx @code{defw @var{expression}[,@var{expression}...]}
+@cindex @code{defw} directive, Z80
 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}...]
+@item @code{d24 @var{expression}[,@var{expression}...]}
+@cindex @code{d24} directive, Z80
+@itemx @code{def24 @var{expression}[,@var{expression}...]}
+@cindex @code{def24} directive, Z80
 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}...]
+@item @code{d32 @var{expression}[,@var{expression}...]}
+@cindex @code{d32} directive, Z80
+@itemx @code{def32 @var{expression}[,@var{expression}...]}
+@cindex @code{def32} directive, Z80
 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}]
+@item @code{ds @var{count}[, @var{value}]}
+@cindex @code{ds} directive, Z80
+@itemx @code{defs @var{count}[, @var{value}]}
+@cindex @code{defs} directive, Z80
 @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 set
-This is a normal instruction on Z80, and not an assembler directive.
-
-@item psect @var{name}
-A synonym for @xref{Section}, no second argument should be given.
+@item @code{@var{symbol} defl @var{expression}}
+@cindex @code{defl} directive, Z80
+The @code{defl} directive is like @code{.set} but with different
+syntax.  @xref{Set,,@code{.set}}.
+It set the value of @var{symbol} to @var{expression}. Symbols defined
+with @code{defl} are not protected from redefinition.
+
+@item @code{@var{symbol} equ @var{expression}}
+@cindex @code{equ} directive, Z80
+The @code{equ} directive is like @code{.equiv} but with different
+syntax.  @xref{Equiv, ,@code{.equiv}}.
+It set the value of @var{symbol} to @var{expression}. It is an error
+if @var{symbol} is already defined. Symbols defined with @code{equ}
+are not protected from redefinition.
+
+@item @code{psect @var{name}}
+@cindex @code{psect} directive, Z80
+A synonym for @code{.section}, no second argument should be given.
+@xref{Section,,@code{.section}}.
+
+@item @code{xdef @var{symbol}}
+@cindex @code{xdef} directive, Z80
+A synonym for @code{.global}, make @var{symbol} is visible to linker.
+@xref{Global,,@code{.global}}.
+
+@item @code{xref @var{name}}
+@cindex @code{xref} directive, Z80
+A synonym for @code{.extern} (@ref{Extern,,@code{.extern}}).
 @ignore
 
 The following attributes will possibly be recognized in the future
@@ -223,21 +327,22 @@ The section is marked as read only.
 
 @node Z80 Opcodes
 @section Opcodes
-In line with common practice, Z80 mnemonics are used for both the Z80 and
-the R800.
+In line with common practice, Z80 mnemonics are used for the Z80,
+Z80N, Z180, eZ80, Ascii R800 and the GameBoy Z80.
 
 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 R800 and undocumented on the Z80.
-Similarly @code{in f,(c)} is documented on the R800 and undocumented on
-the Z80.
+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 the R800 instruction set:
+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.
+Sends zero to the port pointed to by register @code{C}.
 
 @item sli @var{m}
 Equivalent to @code{@var{m} = (@var{m}<<1)+1}, the operand @var{m} can
@@ -249,20 +354,23 @@ This is equivalent to
 
 @example
 ld @var{r}, (ix+@var{d})
-@var{opc} @var{r}
+@var{op} @var{r}
 ld (ix+@var{d}), @var{r}
 @end example
 
-The operation @samp{@var{opc}} may be any of @samp{res @var{b},},
+The operation @samp{@var{op}} 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}
+@item @var{op} (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.