H8/300 Dependent Features
*************************

Options
=======

The Renesas H8/300 version of AS has one machine-dependent option:

-h-tick-hex
     Support H'00 style hex constants in addition to 0x00 style.

-mach=NAME
     Sets the H8300 machine variant.  The following machine names are recognised: h8300h, h8300hn, h8300s, h8300sn, h8300sx and h8300sxn.

Syntax
======

Special Characters
------------------

; is the line comment character.

$ can be used instead of a newline to separate statements. Therefore you may not use $ in symbol names on the H8/300.

Register Names
--------------

You can use predefined symbols of the form rNh and rNl to refer to the H8/300 registers as sixteen 8-bit general-purpose registers.  N is a digit from 0 to 7); for instance, both r0h and r7l are valid register names.

You can also use the eight predefined symbols rN 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 erN (er0 ... er7) to refer to the 32-bit general purpose registers.

The two control registers are called pc (program counter; a 16-bit register, except on the H8/300H where it is 24 bits) and ccr (condition code register; an 8-bit register).  r7 is used as the stack pointer, and can also be called sp.

Addressing Modes
----------------

AS understands the following addressing modes for the H8/300:

rN
     Register direct

@rN
     Register indirect

@(D, rN)
@(D:16, rN)
@(D:24, rN)
     Register indirect: 16-bit or 24-bit displacement D from register N.  (24-bit displacements are only meaningful on the H8/300H.)

@rN+
     Register indirect with post-increment

@-rN
     Register indirect with pre-decrement

@AA
@AA:8
@AA:16
@AA:24
     Absolute address aa.  (The address size :24 only makes sense on the H8/300H.)

#XX
#XX:8
#XX:16
#XX:32
     Immediate data XX.  You may specify the :8, :16, or :32 for clarity, if you wish; but AS neither requires this nor uses it---the data size required is taken from context.

@@AA
@@AA:8
     Memory indirect.  You may specify the :8 for clarity, if you wish; but AS neither requires this nor uses it.

Floating Point
==============

The H8/300 family has no hardware floating point, but the .float directive generates IEEE floating-point numbers for compatibility with other development tools.

H8/300 Machine Directives
=========================

AS has the following machine-dependent directives for the H8/300:

.h8300h
     Recognize and emit additional instructions for the H8/300H variant, and also make .int emit 32-bit numbers rather than the usual (16-bit) for the H8/300 family.

.h8300s
     Recognize and emit additional instructions for the H8S variant, and also make .int emit 32-bit numbers rather than the usual (16-bit) for the H8/300 family.

.h8300hn
     Recognize and emit additional instructions for the H8/300H variant in normal mode, and also make .int emit 32-bit numbers rather than the usual (16-bit) for the H8/300 family.

.h8300sn
     Recognize and emit additional instructions for the H8S variant in normal mode, and also make .int emit 32-bit numbers rather than the usual (16-bit) for the H8/300 family.

On the H8/300 family (including the H8/300H) .word directives generate 16-bit numbers.

Opcodes
=======

For detailed information on the H8/300 machine instruction set, see H8/300 Series Programming Manual.  For information specific to the H8/300H, see H8/300H Series Programming Manual (Renesas).

AS implements all the standard H8/300 opcodes.  No additional pseudo-instructions are needed on this family.

Four H8/300 instructions (add, cmp, mov, sub) are defined with variants using the suffixes .b, .w, and .l to specify the size of a memory operand. AS supports these suffixes, but does not require them; since one of the operands is always a register, AS can deduce the correct size.

For example, since r0 refers to a 16-bit register,

     mov    r0,@foo
     is equivalent to
     mov.w  r0,@foo

If you use the size suffixes, AS issues a warning when the suffix and the register size do not match.