@c Copyright (C) 1991-2024 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 Z8000-Dependent
@chapter Z8000 Dependent Features
@end ifset
@ifclear GENERIC
@node Machine Dependencies
@chapter Z8000 Dependent Features
@end ifclear
@cindex Z8000 support
The Z8000 @value{AS} supports both members of the Z8000 family: the
unsegmented Z8002, with 16 bit addresses, and the segmented Z8001 with
24 bit addresses.
When the assembler is in unsegmented mode (specified with the
@code{unsegm} directive), an address takes up one word (16 bit)
sized register. When the assembler is in segmented mode (specified with
the @code{segm} directive), a 24-bit address takes up a long (32 bit)
register. @xref{Z8000 Directives,,Assembler Directives for the Z8000},
for a list of other Z8000 specific assembler directives.
@menu
* Z8000 Options:: Command-line options for the Z8000
* Z8000 Syntax:: Assembler syntax for the Z8000
* Z8000 Directives:: Special directives for the Z8000
* Z8000 Opcodes:: Opcodes
@end menu
@node Z8000 Syntax
@section Syntax
@menu
* Z8000-Chars:: Special Characters
* Z8000-Regs:: Register Names
* Z8000-Addressing:: Addressing Modes
@end menu
@node Z8000-Chars
@subsection Special Characters
@cindex line comment character, Z8000
@cindex Z8000 line comment character
@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, Z8000
@cindex statement separator, Z8000
@cindex Z8000 line separator
You can use @samp{;} instead of a newline to separate statements.
@node Z8000-Regs
@subsection Register Names
@cindex Z8000 registers
@cindex registers, Z8000
The Z8000 has sixteen 16 bit registers, numbered 0 to 15. You can refer
to different sized groups of registers by register number, with the
prefix @samp{r} for 16 bit registers, @samp{rr} for 32 bit registers and
@samp{rq} for 64 bit registers. You can also refer to the contents of
the first eight (of the sixteen 16 bit registers) by bytes. They are
named @samp{rl@var{n}} and @samp{rh@var{n}}.
@item @@r@var{n}
@itemx @@rr@var{n}
Indirect register: @@rr@var{n} in segmented mode, @@r@var{n} in unsegmented
mode.
@item @var{addr}
Direct: the 16 bit or 24 bit address (depending on whether the assembler
is in segmented or unsegmented mode) of the operand is in the instruction.
@item address(r@var{n})
Indexed: the 16 or 24 bit address is added to the 16 bit register to produce
the final address in memory of the operand.
@item r@var{n}(#@var{imm})
@itemx rr@var{n}(#@var{imm})
Base Address: the 16 or 24 bit register is added to the 16 bit sign
extended immediate displacement to produce the final address in memory
of the operand.
@item r@var{n}(r@var{m})
@itemx rr@var{n}(r@var{m})
Base Index: the 16 or 24 bit register r@var{n} or rr@var{n} is added to
the sign extended 16 bit index register r@var{m} to produce the final
address in memory of the operand.
@item #@var{xx}
Immediate data @var{xx}.
@end table
@node Z8000 Directives
@section Assembler Directives for the Z8000
@cindex Z8000 directives
@cindex directives, Z8000
The Z8000 port of @value{AS} includes additional assembler directives,
for compatibility with other Z8000 assemblers. These do not begin with
@samp{.} (unlike the ordinary @value{AS} directives).
@table @code
@kindex segm
@item segm
@kindex .z8001
@itemx .z8001
Generate code for the segmented Z8001.
@kindex unsegm
@item unsegm
@kindex .z8002
@itemx .z8002
Generate code for the unsegmented Z8002.
@kindex name
@item name
Synonym for @code{.file}
@kindex global
@item global
Synonym for @code{.global}
@kindex wval
@item wval
Synonym for @code{.word}
@kindex lval
@item lval
Synonym for @code{.long}
@kindex bval
@item bval
Synonym for @code{.byte}
@kindex sval
@item sval
Assemble a string. @code{sval} expects one string literal, delimited by
single quotes. It assembles each byte of the string into consecutive
addresses. You can use the escape sequence @samp{%@var{xx}} (where
@var{xx} represents a two-digit hexadecimal number) to represent the
character whose @sc{ascii} value is @var{xx}. Use this feature to
describe single quote and other characters that may not appear in string
literals as themselves. For example, the C statement @w{@samp{char *a =
"he said \"it's 50% off\"";}} is represented in Z8000 assembly language
(shown with the assembler output in hex at the left) as
@kindex rsect
@item rsect
synonym for @code{.section}
@kindex block
@item block
synonym for @code{.space}
@kindex even
@item even
special case of @code{.align}; aligns output to even byte boundary.
@end table
@node Z8000 Opcodes
@section Opcodes
@cindex Z8000 opcode summary
@cindex opcode summary, Z8000
@cindex mnemonics, Z8000
@cindex instruction summary, Z8000
For detailed information on the Z8000 machine instruction set, see
@cite{Z8000 Technical Manual}.
@ifset SMALL
@c this table, due to the multi-col faking and hardcoded order, looks silly
@c except in smallbook. See comments below "@set SMALL" near top of this file.
The following table summarizes the opcodes and their arguments:
@iftex
@begingroup
@let@nonarrowing=@comment
@end iftex
@smallexample
rs @r{16 bit source register}
rd @r{16 bit destination register}
rbs @r{8 bit source register}
rbd @r{8 bit destination register}
rrs @r{32 bit source register}
rrd @r{32 bit destination register}
rqs @r{64 bit source register}
rqd @r{64 bit destination register}
addr @r{16/24 bit address}
imm @r{immediate data}