SuperH SH64 Dependent Features
******************************

Options
=======

-isa=sh4 | sh4a
     Specify the sh4 or sh4a instruction set.

-isa=dsp
     Enable sh-dsp insns, and disable sh3e / sh4 insns.

-isa=fp
     Enable sh2e, sh3e, sh4, and sh4a insn sets.

-isa=all
     Enable sh1, sh2, sh2e, sh3, sh3e, sh4, sh4a, and sh-dsp insn sets.

-isa=shmedia | -isa=shcompact
     Specify the default instruction set.  SHmedia specifies the 32-bit opcodes, and SHcompact specifies the 16-bit opcodes compatible with previous SH families.  The default depends on the ABI selected; the default for the 64-bit ABI is SHmedia, and the default for the 32-bit ABI is SHcompact.  If neither the ABI nor the ISA is specified, the default is 32-bit SHcompact.

     Note that the .mode pseudo-op is not permitted if the ISA is not specified on the command line.

-abi=32 | -abi=64
     Specify the default ABI.  If the ISA is specified and the ABI is not, the default ABI depends on the ISA, with SHmedia defaulting to 64-bit and SHcompact defaulting to 32-bit.

     Note that the .abi pseudo-op is not permitted if the ABI is not specified on the command line.  When the ABI is specified on the command line, any .abi pseudo-ops in the source must match it.

-shcompact-const-crange
     Emit code-range descriptors for constants in SHcompact code sections.

-no-mix
     Disallow SHmedia code in the same section as constants and SHcompact code.

-no-expand
     Do not expand MOVI, PT, PTA or PTB instructions.

-expand-pt32
     With -abi=64, expand PT, PTA and PTB instructions to 32 bits only.

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

Syntax
======

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

! is the line comment character.

You can use ; instead of a newline to separate statements.

Since $ has no special meaning, you may use it in symbol names.

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

You can use the predefined symbols r0 through r63 to refer to the SH64 general registers, cr0 through cr63 for control registers, tr0 through tr7 for target address registers, fr0 through fr63 for single-precision floating point registers, dr0 through dr62 (even numbered registers only) for double-precision floating point registers, fv0 through fv60 (multiples of four only) for single-precision floating point vectors, fp0 through fp62 (even numbered registers only) for single-precision floating point pairs, mtrx0 through mtrx48 (multiples of 16 only) for 4x4 matrices of single-precision floating point registers, pc for the program counter, and fpscr for the floating point status and control register.

You can also refer to the control registers by the mnemonics sr, ssr, pssr, intevt, expevt, pexpevt, tra, spc, pspc, resvec, vbr, tea, dcr, kcr0, kcr1, ctc, and usr.

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

SH64 operands consist of either a register or immediate value.  The immediate value can be a constant or label reference (or portion of a label reference), as in this example:

     	movi	4,r2
     	pt	function, tr4
     	movi	(function >> 16) & 65535,r0
     	shori	function & 65535, r0
     	ld.l	r0,4,r0

Instruction label references can reference labels in either SHmedia or SHcompact.  To differentiate between the two, labels in SHmedia sections will always have the least significant bit set (i.e. they will be odd), which SHcompact labels will have the least significant bit reset (i.e. they will be even).  If you need to reference the actual address of a label, you can use the datalabel modifier, as in this example:

     	.long	function
     	.long	datalabel function

In that example, the first longword may or may not have the least significant bit set depending on whether the label is an SHmedia label or an SHcompact label.  The second longword will be the actual address of the label, regardless of what type of label it is.

SH64 Machine Directives
=======================

In addition to the SH directives, the SH64 provides the following directives:

.mode [shmedia|shcompact]
.isa [shmedia|shcompact]
     Specify the ISA for the following instructions (the two directives are equivalent).  Note that programs such as objdump rely on symbolic labels to determine when such mode switches occur (by checking the least significant bit of the label's address), so such mode/isa changes should always be followed by a label (in practice, this is true anyway).  Note that you cannot use these directives if you didn't specify an ISA on the command line.

.abi [32|64]
     Specify the ABI for the following instructions.  Note that you cannot use this directive unless you specified an ABI on the command line, and the ABIs specified must match.

.uaquad
     Like .uaword and .ualong, this allows you to specify an intentionally unaligned quadword (64 bit word).

Opcodes
=======

For detailed information on the SH64 machine instruction set, see SuperH 64 bit RISC Series Architecture Manual (SuperH, Inc.).

AS implements all the standard SH64 opcodes.  In addition, the following pseudo-opcodes may be expanded into one or more alternate opcodes:

movi
     If the value doesn't fit into a standard movi opcode, AS will replace the movi with a sequence of movi and shori opcodes.

pt
     This expands to a sequence of movi and shori opcode, followed by a ptrel opcode, or to a pta or ptb opcode, depending on the label referenced.