@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
@end ifset
@node H8/300-Dependent
@chapter H8/300 Dependent Features
@cindex H8/300 support
@menu
* H8/300 Options:: Options
* H8/300 Syntax:: Syntax
* H8/300 Floating Point:: Floating Point
* H8/300 Directives:: H8/300 Machine Directives
* H8/300 Opcodes:: Opcodes
@end menu
@node H8/300 Options
@section Options
@cindex H8/300 options
@cindex options, H8/300
The Renesas H8/300 version of @code{@value{AS}} has one
machine-dependent option:
@c man begin OPTIONS
@table @gcctabopt
@item -h-tick-hex
Support H'00 style hex constants in addition to 0x00 style.
@item -mach=@var{name}
Sets the H8300 machine variant. The following machine names
are recognised:
@code{h8300h},
@code{h8300hn},
@code{h8300s},
@code{h8300sn},
@code{h8300sx} and
@code{h8300sxn}.
@end table
@c man end
@node H8/300 Syntax
@section Syntax
@menu
* H8/300-Chars:: Special Characters
* H8/300-Regs:: Register Names
* H8/300-Addressing:: Addressing Modes
@end menu
@node H8/300-Chars
@subsection Special Characters
@cindex line comment character, H8/300
@cindex H8/300 line comment character
@samp{;} is the line comment character.
@cindex line separator, H8/300
@cindex statement separator, H8/300
@cindex H8/300 line separator
@samp{$} can be used instead of a newline to separate statements.
Therefore @emph{you may not use @samp{$} in symbol names} on the H8/300.
@node H8/300-Regs
@subsection Register Names
@cindex H8/300 registers
@cindex register names, H8/300
You can use predefined symbols of the form @samp{r@var{n}h} and
@samp{r@var{n}l} to refer to the H8/300 registers as sixteen 8-bit
general-purpose registers. @var{n} is a digit from @samp{0} to
@samp{7}); for instance, both @samp{r0h} and @samp{r7l} are valid
register names.
You can also use the eight predefined symbols @samp{r@var{n}} to refer
to the H8/300 registers as 16-bit registers (you must use this form for
addressing).
On the H8/300H, you can also use the eight predefined symbols
@samp{er@var{n}} (@samp{er0} @dots{} @samp{er7}) to refer to the 32-bit
general purpose registers.
The two control registers are called @code{pc} (program counter; a
16-bit register, except on the H8/300H where it is 24 bits) and
@code{ccr} (condition code register; an 8-bit register). @code{r7} is
used as the stack pointer, and can also be called @code{sp}.
@cindex addressing modes, H8/300
@cindex H8/300 addressing modes
@value{AS} understands the following addressing modes for the H8/300:
@table @code
@item r@var{n}
Register direct
@item @@r@var{n}
Register indirect
@need 1200
@item @@(@var{d}, r@var{n})
@itemx @@(@var{d}:16, r@var{n})
@itemx @@(@var{d}:24, r@var{n})
Register indirect: 16-bit or 24-bit displacement @var{d} from register
@var{n}. (24-bit displacements are only meaningful on the H8/300H.)
@item @@r@var{n}+
Register indirect with post-increment
@item @@-r@var{n}
Register indirect with pre-decrement
@item @code{@@}@var{aa}
@itemx @code{@@}@var{aa}:8
@itemx @code{@@}@var{aa}:16
@itemx @code{@@}@var{aa}:24
Absolute address @code{aa}. (The address size @samp{:24} only makes
sense on the H8/300H.)
@item #@var{xx}
@itemx #@var{xx}:8
@itemx #@var{xx}:16
@itemx #@var{xx}:32
Immediate data @var{xx}. You may specify the @samp{:8}, @samp{:16}, or
@samp{:32} for clarity, if you wish; but @code{@value{AS}} neither
requires this nor uses it---the data size required is taken from
context.
@item @code{@@}@code{@@}@var{aa}
@itemx @code{@@}@code{@@}@var{aa}:8
Memory indirect. You may specify the @samp{:8} for clarity, if you
wish; but @code{@value{AS}} neither requires this nor uses it.
@end table
@node H8/300 Floating Point
@section Floating Point
@cindex floating point, H8/300 (@sc{ieee})
@cindex H8/300 floating point (@sc{ieee})
The H8/300 family has no hardware floating point, but the @code{.float}
directive generates @sc{ieee} floating-point numbers for compatibility
with other development tools.
@cindex H8/300 machine directives (none)
@cindex machine directives, H8/300 (none)
@cindex @code{word} directive, H8/300
@cindex @code{int} directive, H8/300
@code{@value{AS}} has the following machine-dependent directives for
the H8/300:
@table @code
@cindex H8/300H, assembling for
@item .h8300h
Recognize and emit additional instructions for the H8/300H variant, and
also make @code{.int} emit 32-bit numbers rather than the usual (16-bit)
for the H8/300 family.
@item .h8300s
Recognize and emit additional instructions for the H8S variant, and
also make @code{.int} emit 32-bit numbers rather than the usual (16-bit)
for the H8/300 family.
@item .h8300hn
Recognize and emit additional instructions for the H8/300H variant in
normal mode, and also make @code{.int} emit 32-bit numbers rather than
the usual (16-bit) for the H8/300 family.
@item .h8300sn
Recognize and emit additional instructions for the H8S variant in
normal mode, and also make @code{.int} emit 32-bit numbers rather than
the usual (16-bit) for the H8/300 family.
@end table
On the H8/300 family (including the H8/300H) @samp{.word} directives
generate 16-bit numbers.
@node H8/300 Opcodes
@section Opcodes
@cindex H8/300 opcode summary
@cindex opcode summary, H8/300
@cindex mnemonics, H8/300
@cindex instruction summary, H8/300
For detailed information on the H8/300 machine instruction set, see
@cite{H8/300 Series Programming Manual}. For information specific to
the H8/300H, see @cite{H8/300H Series Programming Manual} (Renesas).
@code{@value{AS}} implements all the standard H8/300 opcodes. No additional
pseudo-instructions are needed on this family.
@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 H8/300 opcodes, and their arguments.
Entries marked @samp{*} are opcodes used only on the H8/300H.
@smallexample
@c Using @group seems to use the normal baselineskip, not the smallexample
@c baselineskip; looks approx doublespaced.
@i{Legend:}
Rs @r{source register}
Rd @r{destination register}
abs @r{absolute address}
imm @r{immediate data}
disp:N @r{N-bit displacement from a register}
pcrel:N @r{N-bit displacement relative to program counter}
@cindex size suffixes, H8/300
@cindex H8/300 size suffixes
Four H8/300 instructions (@code{add}, @code{cmp}, @code{mov},
@code{sub}) are defined with variants using the suffixes @samp{.b},
@samp{.w}, and @samp{.l} to specify the size of a memory operand.
@code{@value{AS}} supports these suffixes, but does not require them;
since one of the operands is always a register, @code{@value{AS}} can
deduce the correct size.
For example, since @code{r0} refers to a 16-bit register,
@example
mov r0,@@foo
@exdent is equivalent to
mov.w r0,@@foo
@end example
If you use the size suffixes, @code{@value{AS}} issues a warning when
the suffix and the register size do not match.