binutils-gdb/gas/doc/c-z80.texi

269 lines
8.8 KiB
Plaintext
Raw Normal View History

PR gas/12390 * doc/all.texi: Add NS32K * doc/as.texinfo: Remove target specific details of which characters act as comment initiators and statement separators into individual target specific files. * doc/c-alpha.texi (Alpha-Chars): Document special behaviour of the hash character at the start of a line. * doc/c-arm.texi (ARM-Chars): Likewise. * doc/c-avr.texi (AVR-Chars): Likewise. * doc/c-d10v.texi (D10V-Chars): Likewise. * doc/c-d30v.texi (D30V-Chars): Likewise. * doc/c-mmix.texi (MMIX-Chars): Likewise. * doc/c-s390.texi (s390 characters): Likewise. * doc/c-sh.texi (SH-Chars): Likewise. * doc/c-sh64.texi (SH64-Chars): Likewise. * doc/c-sparc.texi (SPARC-Chars): Likewise. * doc/c-tic6x.texi (TIC6X Syntax): Likewise. * doc/c-xtensa.texi (Xtensa Syntax): Likewise. * doc/c-z80.texi (Z80-Chars): Likewise. * doc/c-z8k.texi (Z8000-Chars): Likewise. * doc/c-pdp11.texi (PDP11-Syntax): Document line separator character. * doc/c-arc.texi (ARC-Chars): Fill in this subsection. * doc/c-bfin.texi (Blackfin Syntax): Document line comment and line separator characters. * doc/c-cr16.texi (CR16 Syntax): Likewise. * doc/c-i386.texi (i386-Chars): Likewise. * doc/c-i860.texi (i860-Chars): Likewise. * doc/c-i960.texi (i960-Chars): Likewise. * doc/c-ip2k.texi (IP2K-Chars): Likewise. * doc/c-lm32.texi (LM32-Chars): likewise. * doc/c-m32c.texi (M32C-Chars): Likewise. * doc/c-m68hc11.texi (M68HC11-syntax): Likewise. * doc/c-m68k.texi (M68K-Chars): Likewise. * doc/c-microblaze.texi (MicroBlaze-Chars): Likewise. * doc/c-msp430.texi (MSP430-Chars): Likewise. * doc/c-mt.texi (MT-Chars): Likewise. * doc/c-ns32k.texi (NS32K-Chars): Likewise. * doc/c-pj.texi (PJ-Chars): Likewise. * doc/c-ppc.texi (PowerPC-Chars): Likewise. * doc/c-rx.texi (RX-Chars): Likewise. * doc/c-score.texi (SCORE-Chars): Likewise. * doc/c-tic54x.texi (TIC54X-Chars): Likewise. * doc/c-v850.texi (V850-Chars): Likewise. * doc/c-vax.texi (VAX-Chars): Likewise. * doc/c-xc16x.texi (xc16x-Chars): Likewise.
2011-01-18 14:37:39 +01:00
@c Copyright 2011 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
The Zilog Z80 and Ascii R800 version of @code{@value{AS}} have a few machine
dependent options.
@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.
2006-07-24 15:49:50 +02:00
In line with common practice, @code{@value{AS}} uses Z80 instruction names
for the R800 processor, as far as they exist.
@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''
2013-01-10 20:51:55 +01:00
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.
2013-01-10 20:51:55 +01:00
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
2013-01-10 20:51:55 +01:00
The semicolon @samp{;} is the line comment character;
PR gas/12390 * doc/all.texi: Add NS32K * doc/as.texinfo: Remove target specific details of which characters act as comment initiators and statement separators into individual target specific files. * doc/c-alpha.texi (Alpha-Chars): Document special behaviour of the hash character at the start of a line. * doc/c-arm.texi (ARM-Chars): Likewise. * doc/c-avr.texi (AVR-Chars): Likewise. * doc/c-d10v.texi (D10V-Chars): Likewise. * doc/c-d30v.texi (D30V-Chars): Likewise. * doc/c-mmix.texi (MMIX-Chars): Likewise. * doc/c-s390.texi (s390 characters): Likewise. * doc/c-sh.texi (SH-Chars): Likewise. * doc/c-sh64.texi (SH64-Chars): Likewise. * doc/c-sparc.texi (SPARC-Chars): Likewise. * doc/c-tic6x.texi (TIC6X Syntax): Likewise. * doc/c-xtensa.texi (Xtensa Syntax): Likewise. * doc/c-z80.texi (Z80-Chars): Likewise. * doc/c-z8k.texi (Z8000-Chars): Likewise. * doc/c-pdp11.texi (PDP11-Syntax): Document line separator character. * doc/c-arc.texi (ARC-Chars): Fill in this subsection. * doc/c-bfin.texi (Blackfin Syntax): Document line comment and line separator characters. * doc/c-cr16.texi (CR16 Syntax): Likewise. * doc/c-i386.texi (i386-Chars): Likewise. * doc/c-i860.texi (i860-Chars): Likewise. * doc/c-i960.texi (i960-Chars): Likewise. * doc/c-ip2k.texi (IP2K-Chars): Likewise. * doc/c-lm32.texi (LM32-Chars): likewise. * doc/c-m32c.texi (M32C-Chars): Likewise. * doc/c-m68hc11.texi (M68HC11-syntax): Likewise. * doc/c-m68k.texi (M68K-Chars): Likewise. * doc/c-microblaze.texi (MicroBlaze-Chars): Likewise. * doc/c-msp430.texi (MSP430-Chars): Likewise. * doc/c-mt.texi (MT-Chars): Likewise. * doc/c-ns32k.texi (NS32K-Chars): Likewise. * doc/c-pj.texi (PJ-Chars): Likewise. * doc/c-ppc.texi (PowerPC-Chars): Likewise. * doc/c-rx.texi (RX-Chars): Likewise. * doc/c-score.texi (SCORE-Chars): Likewise. * doc/c-tic54x.texi (TIC54X-Chars): Likewise. * doc/c-v850.texi (V850-Chars): Likewise. * doc/c-vax.texi (VAX-Chars): Likewise. * doc/c-xc16x.texi (xc16x-Chars): Likewise.
2011-01-18 14:37:39 +01:00
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.
2013-01-10 20:51:55 +01:00
@cindex character constant, Z80
@cindex single quote, Z80
@cindex Z80 '
The single quote @samp{'} must be followed by a closing quote. If there
2006-07-24 15:49:50 +02:00
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
2013-01-10 20:51:55 +01:00
Zilog. In addition @command{@value{AS}} recognizes @samp{ixl} and
@samp{ixh} as the least and most significant octet in @samp{ix}, and
2013-01-10 20:51:55 +01:00
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,
2013-01-10 20:51:55 +01:00
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
2013-01-10 20:51:55 +01:00
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}...]
For each @var{string} the characters are copied to the object file, for
2013-01-10 20:51:55 +01:00
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
2013-01-10 20:51:55 +01:00
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
2013-01-10 20:51:55 +01:00
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
2013-01-10 20:51:55 +01:00
overflow.
@item ds @var{count}[, @var{value}]
@itemx defs @var{count}[, @var{value}]
2013-01-10 20:51:55 +01:00
@c Synonyms for @code{ds.b},
2006-07-24 15:49:50 +02:00
@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}
gas/ acinclude.m4 aclocal.m4 app.c app.o as.c as.h as.h.cvs asintl.h as-new as.o atof-generic.c atof-generic.o atof-ieee.o autom4te.cache bignum.h bit_fix.h cgen.c cgen.h ChangeLog ChangeLog-0001 ChangeLog-0203 ChangeLog.~1.2755.~ ChangeLog-9295 ChangeLog-9697 ChangeLog-9899 cond.c cond.o config config.cache config.h config.in config.log config.status configure configure.in configure.tgt CONTRIBUTORS COPYING CVS debug.c DEP2 DEPDIR depend.c depend.o dep-in.sed DEPOBJ dep.sed DEPTC doc dw2gencfi.c dw2gencfi.h dw2gencfi.o dwarf2dbg.c dwarf2dbg.h dwarf2dbg.o ecoff.c ecoff.h ecoff.o ehopt.c ehopt.o emul.h emul-target.h expr.c expr.c.cvs expr.h expr.o flonum-copy.c flonum-copy.o flonum.h flonum-konst.c flonum-konst.o flonum-mult.c flonum-mult.o frags.c frags.h frags.o gdbinit.in hash.c hash.h hash.o input-file.c input-file.h input-file.o input-scrub.c input-scrub.o itbl-cpu.h itbl-lex.h itbl-lex.l itbl-ops.c itbl-ops.h itbl-parse.y libtool listing.c listing.h listing.o literal.c literal.o long.s macro.c macro.c.bak macro.h macro.o MAINTAINERS Makefile Makefile.am Makefile.in messages.c messages.o NEWS obj-coff.o obj-format.h obj.h output-file.c output-file.h output-file.o po read.c read.h README read.o sb.c sb.h sb.o site.bak site.exp stabs.c stabs.o stamp-h1 stamp-h.in struc-symbol.h subsegs.c subsegs.h subsegs.o symbols.c symbols.h symbols.o targ-cpu.h targ-env.h tc.h tc-z80.o testsuite write.c write.h write.o config/tc-z80.c (z80_start_line_hook): issue an error when redefining a symbol with equ acinclude.m4 aclocal.m4 app.c app.o as.c as.h as.h.cvs asintl.h as-new as.o atof-generic.c atof-generic.o atof-ieee.o autom4te.cache bignum.h bit_fix.h cgen.c cgen.h ChangeLog ChangeLog-0001 ChangeLog-0203 ChangeLog.~1.2755.~ ChangeLog-9295 ChangeLog-9697 ChangeLog-9899 cond.c cond.o config config.cache config.h config.in config.log config.status configure configure.in configure.tgt CONTRIBUTORS COPYING CVS debug.c DEP2 DEPDIR depend.c depend.o dep-in.sed DEPOBJ dep.sed DEPTC doc dw2gencfi.c dw2gencfi.h dw2gencfi.o dwarf2dbg.c dwarf2dbg.h dwarf2dbg.o ecoff.c ecoff.h ecoff.o ehopt.c ehopt.o emul.h emul-target.h expr.c expr.c.cvs expr.h expr.o flonum-copy.c flonum-copy.o flonum.h flonum-konst.c flonum-konst.o flonum-mult.c flonum-mult.o frags.c frags.h frags.o gdbinit.in hash.c hash.h hash.o input-file.c input-file.h input-file.o input-scrub.c input-scrub.o itbl-cpu.h itbl-lex.h itbl-lex.l itbl-ops.c itbl-ops.h itbl-parse.y libtool listing.c listing.h listing.o literal.c literal.o long.s macro.c macro.c.bak macro.h macro.o MAINTAINERS Makefile Makefile.am Makefile.in messages.c messages.o NEWS obj-coff.o obj-format.h obj.h output-file.c output-file.h output-file.o po read.c read.h README read.o sb.c sb.h sb.o site.bak site.exp stabs.c stabs.o stamp-h1 stamp-h.in struc-symbol.h subsegs.c subsegs.h subsegs.o symbols.c symbols.h symbols.o targ-cpu.h targ-env.h tc.h tc-z80.o testsuite write.c write.h write.o doc/as.texinfo(equ<z80>): mention difference with .equiv acinclude.m4 aclocal.m4 app.c app.o as.c as.h as.h.cvs asintl.h as-new as.o atof-generic.c atof-generic.o atof-ieee.o autom4te.cache bignum.h bit_fix.h cgen.c cgen.h ChangeLog ChangeLog-0001 ChangeLog-0203 ChangeLog.~1.2755.~ ChangeLog-9295 ChangeLog-9697 ChangeLog-9899 cond.c cond.o config config.cache config.h config.in config.log config.status configure configure.in configure.tgt CONTRIBUTORS COPYING CVS debug.c DEP2 DEPDIR depend.c depend.o dep-in.sed DEPOBJ dep.sed DEPTC doc dw2gencfi.c dw2gencfi.h dw2gencfi.o dwarf2dbg.c dwarf2dbg.h dwarf2dbg.o ecoff.c ecoff.h ecoff.o ehopt.c ehopt.o emul.h emul-target.h expr.c expr.c.cvs expr.h expr.o flonum-copy.c flonum-copy.o flonum.h flonum-konst.c flonum-konst.o flonum-mult.c flonum-mult.o frags.c frags.h frags.o gdbinit.in hash.c hash.h hash.o input-file.c input-file.h input-file.o input-scrub.c input-scrub.o itbl-cpu.h itbl-lex.h itbl-lex.l itbl-ops.c itbl-ops.h itbl-parse.y libtool listing.c listing.h listing.o literal.c literal.o long.s macro.c macro.c.bak macro.h macro.o MAINTAINERS Makefile Makefile.am Makefile.in messages.c messages.o NEWS obj-coff.o obj-format.h obj.h output-file.c output-file.h output-file.o po read.c read.h README read.o sb.c sb.h sb.o site.bak site.exp stabs.c stabs.o stamp-h1 stamp-h.in struc-symbol.h subsegs.c subsegs.h subsegs.o symbols.c symbols.h symbols.o targ-cpu.h targ-env.h tc.h tc-z80.o testsuite write.c write.h write.o doc/as.texinfo(err): fix typo acinclude.m4 aclocal.m4 app.c app.o as.c as.h as.h.cvs asintl.h as-new as.o atof-generic.c atof-generic.o atof-ieee.o autom4te.cache bignum.h bit_fix.h cgen.c cgen.h ChangeLog ChangeLog-0001 ChangeLog-0203 ChangeLog.~1.2755.~ ChangeLog-9295 ChangeLog-9697 ChangeLog-9899 cond.c cond.o config config.cache config.h config.in config.log config.status configure configure.in configure.tgt CONTRIBUTORS COPYING CVS debug.c DEP2 DEPDIR depend.c depend.o dep-in.sed DEPOBJ dep.sed DEPTC doc dw2gencfi.c dw2gencfi.h dw2gencfi.o dwarf2dbg.c dwarf2dbg.h dwarf2dbg.o ecoff.c ecoff.h ecoff.o ehopt.c ehopt.o emul.h emul-target.h expr.c expr.c.cvs expr.h expr.o flonum-copy.c flonum-copy.o flonum.h flonum-konst.c flonum-konst.o flonum-mult.c flonum-mult.o frags.c frags.h frags.o gdbinit.in hash.c hash.h hash.o input-file.c input-file.h input-file.o input-scrub.c input-scrub.o itbl-cpu.h itbl-lex.h itbl-lex.l itbl-ops.c itbl-ops.h itbl-parse.y libtool listing.c listing.h listing.o literal.c literal.o long.s macro.c macro.c.bak macro.h macro.o MAINTAINERS Makefile Makefile.am Makefile.in messages.c messages.o NEWS obj-coff.o obj-format.h obj.h output-file.c output-file.h output-file.o po read.c read.h README read.o sb.c sb.h sb.o site.bak site.exp stabs.c stabs.o stamp-h1 stamp-h.in struc-symbol.h subsegs.c subsegs.h subsegs.o symbols.c symbols.h symbols.o targ-cpu.h targ-env.h tc.h tc-z80.o testsuite write.c write.h write.o doc/c-z80.texi(equ): redefining a symbol with equ is no longer allowed
2005-11-26 21:03:53 +01:00
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
2013-01-10 20:51:55 +01:00
This is a normal instruction on Z80, and not an assembler directive.
@item psect @var{name}
2013-01-10 20:51:55 +01:00
A synonym for @xref{Section}, no second argument should be given.
@ignore
2006-07-24 15:49:50 +02:00
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
2006-07-24 15:49:50 +02:00
In line with common practice, Z80 mnemonics are used for both the Z80 and
2013-01-10 20:51:55 +01:00
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 R800 and undocumented on the Z80.
Similarly @code{in f,(c)} is documented on the R800 and undocumented on
the Z80.
The assembler also supports the following undocumented Z80-instructions,
that have not been adopted in the R800 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}
2013-01-10 20:51:55 +01:00
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.