When using this document, keep the following in mind:
1. This document may, wholly or partially, be subject to change without notice.
2. All rights are reserved: No one is permitted to reproduce or duplicate, in any form, the
whole or part of this document without Hitachi’s permission.
3. Hitachi will not be held responsible for any damage to the user that may result from
accidents or any other reasons during operation of the user’s unit according to this document.
4. Circuitry and other examples described herein are meant merely to indicate the
characteristics and performance of Hitachi’s semiconductor products. Hitachi assumes no
responsibility for any intellectual property claims or other problems that may result from
applications based on the examples described herein.
5. No license is granted by implication or otherwise under any patents or other rights of any
third party or Hitachi, Ltd.
6. MEDICAL APPLICATIONS: Hitachi’s products are not authorized for use in MEDICAL
APPLICATIONS without the written consent of the appropriate officer of Hitachi’s sales
company. Such use includes, but is not limited to, use in life support systems. Buyers of
Hitachi’s products are requested to notify the relevant Hitachi sales offices when planning to
use the products in MEDICAL APPLICATIONS.
4.2 On-chip Peripheral Modules and External Devices...........................................................152
iii
iv
Preface
The H8/300L Series of single-chip microcomputers is built around the high-speed H8/300L
CPU, with an architecture featuring eight 16-bit (or sixteen 8-bit) general registers and a concise,
optimized instruction set.
This manual gives detailed descriptions of the H8/300L instructions. The descriptions apply to
all chips in the H8/300L Series. Assembly-language programmers should also read the separate
H8/300 Series Cross Assembler User's Manual.
For hardware details, refer to the hardware manual of the specific chip.
1
2
Section 1. CPU
1.1Overview
The H8/300L CPU at the heart of the H8/300L Series features 16 general registers of 8 bits each
(or 8 registers of 16-bits each), and a concise, optimized instruction set geared to high-speed
operation.
1.1.1Features
The H8/300L CPU has the following features.
• General register configuration
16 8-bit registers (can be used as 8 16-bit registers)
• 55 basic instructions
Multiply and divide instructions
Powerful bit manipulation instructions
• Low-power operation
Transition to power-down state using SLEEP instruction
3
1.1.2Data Structure
The H8/300L CPU can process 1-bit data, 4-bit (packed BCD) data, 8-bit (byte) data, and 1 6-bit
(word) data.
• Bit manipulation instructions operate on 1-bit data specified as bit n (n = 0, 1, 2, ..., 7) in a
byte operand.
• All operational instructions except ADDS and SUBS can operate on byte data.
• The MOV.W, ADD.W, SUB.W, CMP.W, ADDS, SUBS, MULXU (8 bits × 8 bits), andDIVXU (16 bits ÷ 8 bits) instructions operate on word data.
• The DAA and DAS instruction perform decimal arithmetic adjustments on byte data in
packed BCD form. Each 4-bit of the byte is treated as a decimal digit.
Data Structure in General Registers: Data of all the sizes above can be stored in general
registers as shown in figure 1-1.
Data typeRegister No.Data format
1-Bit dataRnH
1-Bit dataRnL
Don't - care
07
Don't - care76543210
67452301
07
Byte dataRnH
Byte dataRnL
Word dataRn
4-Bit BCD dataRnH
07
M
S
B
L
S
B
Don't - care
70
Don't - care
M
S
B
L
S
B
150
M
S
B
L
S
B
70
UpperLower
Don't - care
4
Data Structure in Memory: Figure 1-2 shows the structure of data in memory. The H8/300L
CPU is able to access word data in memory (MOV.W instruction), but only if the word data
starts from an even-numbered address. If an odd address is designated, no address error occurs,
but the access is performed starting from the previous even address, with the least significant bit
of the address regarded as 0.* The same applies to instruction codes.
*Note that the LSIs in the H8/300L Series also contain on-chip peripheral modules for
which access in word size is not possible. Details are given in the applicable hardware
manual.
Data Type Data FormatAddress
07
1-Bit dataAddress n
765 43210
Word data
Byte data (CCR) on stack
Word data on stack
Address nByte data
Even address
Odd address
Even address
Odd address
Even address
Odd address
M
S
B
L
S
B
Upper 8 bits
Lower 8 bits
CCR
CCR*
5
1.1.3Address Space
The H8/300L CPU supports a 64-Kbyte address space (program code + data). The memory map
differs depending on the particular chip in the H8/300L Series and its operating mode. See the
applicable hardware manual for details.
1.1.4Register Configuration
Figure 1-3 shows the register configuration of the H8/300L CPU. There are 16 8-bit general
registers (R0H, R0L, ..., R7H, R7L), which can also be accessed as eight 16-bit registers (R0 to
R7). There are two control registers: the 16-bit program counter (PC) and the 8-bit condition
code register (CCR).
General Registers (Rn)
Control Registers (CR)
7
R0HR0L
R4H
150
700
R1LR1H
R2LR2H
R3LR3H
R4L
R5LR5H
R6LR6H
R7LR7H(SP)
PC
47561230
CCR
I
UH U N
ZVC
SP: Stack Pointer
Program Counter
Condition Code Register
Carry flag
Overflow flag
Zero flag
Negative flag
Half-carry flag
Interrupt mask bit
User bit
Figure 1-3. CPU Registers
6
1.2Registers
1.2.1General Registers
All the general registers can be used as both data registers and address registers. When used as
address registers, the general registers are accessed as 16-bit registers (R0 to R7). When used as
data registers, they can be accessed as 16-bit registers (R0 to R7), or the high (R0H to R7H) and
low (R0L to R7L) bytes can be accessed separately as 8-bit registers. The register length is
determined by the instruction.
R7 also functions as the stack pointer, used implicitly by hardware in processing interrupts and
subroutine calls. In assembly language, the letters SP can be coded as a synonym for R7. As
indicated in figure 1-4, R7 (SP) points to the top of the stack.
Unused area
SP (R7)
Stack area
Figure 1-4. Stack Pointer
1.2.2Control Registers
The CPU has a 16-bit program counter (PC) and an 8-bit condition code register (CCR).
(1) Program Counter (PC):
CPU will execute. Instructions are fetched by 16-bit (word) access, so the least significant bit
of the PC is ignored (always regarded as 0).
(2) Condition Code Register (CCR):
with an interrupt mask (I) bit and five flag bits: half-carry (H), negative (N), zero (Z),
overflow (V), and carry (C) flags. The two unused bits are available to the user. The bit
configuration of the condition code register is shown below.
This 16-bit register indicates the address of the next instruction the
This 8-bit register indicates the internal status of the CPU
7
Bit
76543210
I UHUNZVC
Initial value
Read/Write
Not fixed
*
1
R/W
*
R/W R/WR/WR/WR/WR/WR/W
*
****
*
Bit 7--Interrupt Mask Bit (I): When this bit is set to 1, all interrupts except NMI are masked.
This bit is set to I automatically at the start of interrupt handling.
Bits 6 and 4--User Bits (U): These bits can be written and read by software for its own purposes
using LDC, STC, ANDC, ORC, and XORC instructions.
Bit 5--Half-Carry (H): This bit is used by add, subtract, and compare instructions to indicate a
borrow or carry out of bit 3 or bit 11. It is referenced by the decimal adjust instructions.
Bit 3--Negative (N): This bit indicates the value of the most significant bit (sign bit) of the
result of an instruction.
Bit 2--Zero (Z): This bit is set to 1 to indicate a zero result and cleared to 0 to indicate a
nonzero result.
Bit 1--Overflow (V): This bit is set to 1 when an arithmetic overflow occurs, and cleared to 0 at
other times.
Bit 0--Carry (C): This bit is used by:
• Add, subtract, and compare instructions, to indicate a carry or borrow at the most significant
bit
•
8
1.3Instructions
Features:
• The H8/300L CPU has a concise set of 55 instructions.
• A general-register architecture is adopted.
• All instructions are 2 or 4 bytes long.
• Fast multiply/divide instructions and extensive bit manipulation instructions are supported.
• Eight addressing modes are supported.
1.3.1Types of Instructions
Table 1-1 classifies the H8/300L instructions by type. Section 2, Instruction Set, gives detailed
descriptions.
Table 1-1.Instruction Classification
FunctionInstructionsTypes
Data transferMOV, POP*, PUSH*1
Arithmetic
operations
Logic operationsAND, OR, XOR, NOT4
ShiftSHAL, SHAR, SHLL, SHLR, ROTL, ROTR, ROTXL,
Bit manipulationBSET, BCLR, BNOT, BTST, BAND, BIAND, BOR
BranchBcc**, JMP, BSR, JSR, RTS5
System controlRTE, SLEEP, LDC, STC, ANDC, ORC, XORC, NOP8
Block data transferEEPMOV1
*POP Rn is equivalent to MOV.W @SP+, Rn.
PUSH Rn is equivalent to MOV.W Rn, @-SP.
**Bcc is a conditional branch instruction in which cc represents a condition.
Tables 1-2 to 1-9 give brief descriptions of the instructions in each functional group. The
following notation is used.
9
Notation
RdGeneral register (destination)
RsGeneral register (source)
RnGeneral register
(EAd)Destination operand
(EAs)Source operand
CCRCondition code register
NN (negative) bit of CCR
ZZ (zero) bit of CCR
VV (overflow) bit of CCR
CC (carry) bit of CCR
PCProgram counter
SPStack pointer (R7)
#ImmImmediate data
opOperation field
dispDisplacement
+Addition
Moves data between two general registers or between a general register
and memory, or moves immediate data to a general register.
The Rn, @Rn, @(d:16, Rn), @aa:16, #xx:8 or #xx:16, @-Rn, and @Rn+
addressing modes are available for byte or word data. The @aa:8
addressing mode is available for byte data only.
The @-R7 and @R7+ modes require word operands. Do not specify byte
size for these two modes.
POPW@SP+ → Rn
Pops a 16-bit general register from the stack.
Equivalent to MOV.W @SP+, Rn.
PUSHWRn → @-SP
Pushes a 16-bit general register onto the stack.
Equivalent to MOV.W Rn, @-SP.
*Size: Operand size
B: Byte
W: Word
11
Table 1-3.Arithmetic Instructions
InstructionSize*Function
ADD
SUB
ADDX
SUBX
INC
DEC
ADDS
SUBS
DAA
DAS
MULXUBRd × Rs → Rd
DIVXUBRd ÷ Rs → Rd
CMPB/WRd - Rs, Rd-#Imm
NEGB0 - Rd → Rd
*Size: Operand size
B: Byte
W: Word
B/WRd ± Rs → Rd, Rd + #Imm → Rd
Performs addition or subtraction on data in two general registers, or
addition on immediate data and data in a general register.
Immediate data cannot be subtracted from data in a general
register.
Word data can be added or subtracted only when both words are in
general registers.
BRd ± Rs ± C → Rd, Rd ± #Imm ± C → Rd
Performs addition or subtraction with carry or borrow on byte data
in two general registers, or addition or subtraction on immediate
data and data in a general register.
BRd ± 1 → Rd
Increments or decrements a general register.
WRd ± 1 → Rd, Rd ± 2 → Rd
Adds or subtracts immediate data to or from data in a general
register. The immediate data must be 1 or 2.
BRd decimal adjust → Rd
Decimal-adjusts (adjusts to packed BCD) an addition or subtraction
result in a general register by referring to the condition code
register.
Performs 8-bit × 8-bit unsigned multiplication on data in two general
registers, providing a 16-bit result.
Performs 16-bit ÷ 8-bit unsigned division on data in two general
registers, providing an 8-bit quotient and 8-bit remainder.
Compares data in a general register with data in another general
register or with immediate data. Word data can be compared only
between two general registers.
Obtains the two's complement (arithmetic complement) of data in a
general register.
12
Table 1-4.Logic operation Instructions
InstructionSize*Function
ANDBRd ∧ Rs → Rd, Rd ∧ #Imm → Rd
Performs a logical AND operation on a general register and another
general register or immediate data.
ORBRd ∨ Rs → Rd, Rd ∨ #Imm → Rd
Performs a logical OR operation on a general register and another
general register or immediate data.
XORBRd ⊕ Rs → Rd, Rd ⊕ #Imm → Rd
Performs a logical exclusive OR operation on a general register and
another general register or immediate data.
NOTB¬ Rd → Rd
Obtains the one's complement (logical complement) of general register
contents.
*Size: Operand size
B: Byte
Table 1-5.Shift Instructions
InstructionSize*Function
SHAL
SHAR
SHLL
SHLR
ROTL
ROTR
ROTXL
ROTXR
*Size: Operand size
BRd shift → Rd
Performs an arithmetic shift operation on general register contents.
BRd shift → Rd
Performs a logical shift operation on general register contents.
BRd rotate → Rd
Rotates general register contents.
BRd rotate through carry → Rd
Rotates general register contents through the C (carry) bit.
B: Byte
13
Table 1-6.Bit Manipulation Instructions
InstructionSize*Function
BSETB1 → (<bit-No.> of <EAd>)
BCLRB0 → (<bit-No.> of <EAd>)
BNOTB¬ (<bit-No.> of <EAd>) → (<bit-No.> of <EAd>)
BTSTB¬ (<bit-No.> of <EAd>) → Z
BAND
BIAND
BOR
BIOR
BXOR
BIXOR
BLD
BILD
BST
BIST
B
B
B
B
B
B
B
B
B
B
*Size: Operand size
B: Byte
Sets a specified bit in a general register or memory to 1. The bit is specified by a bit
number, given in 3-bit immediate data or the lower three bits of a general register.
Clears a specified bit in a general register or memory to 0. The bit is specified by a
bit number, given in 3-bit immediate data or the lower three bits of a general
register.
Inverts a specified bit in a general register or memory. The bit is specified by a bit
number, given in 3-bit immediate data or the lower three bits of a general register.
Tests a specified bit in a general register or memory and sets or clears the Z flag
accordingly. The bit is specified by a bit number, given in 3-bit immediate data or the
lower three bits of a general register.
C ∧ (<bit-No.> of <EAd>) → C
ANDs the C flag with a specified bit in a general register or memory.
C ∧ [¬ (<bit-No.> of <EAd>)] → C
ANDs the C flag with the inverse of a specified bit in a general register or memory.
The bit number is specified by 3-bit immediate data.
C ∨ (<bit-No.> of <EAd>) → C
ORs the C flag with a specified bit in a general register or memory.
C ∨ [¬(<bit-No.> of <EAd>)] → C
ORs the C flag with the inverse of a specified bit in a general register or memory.
The bit number is specified by 3-bit immediate data.
C ⊕ (<bit-No.> of <EAd>) → C
Exclusive-ORs the C flag with a specified bit in a general register or memory.
C ⊕ [¬(<bit-No.> of <EAd>)] → C
Exclusive-ORs the C flag with the inverse of a specified bit in a general register or
memory.
The bit number is specified by 3-bit immediate data.
(<bit-No.> of <EAd>) → C
Copies a specified bit in a general register or memory to the C flag.
¬(<bit-No.> of <EAd>) → C
Copies the inverse of a specified bit in a general register or memory to the C flag.
The bit number is specified by 3-bit immediate data.
C → (<bit-No.> of <EAd>)
Copies the C flag to a specified bit in a general register or memory.
¬C → (<bit-No.> of <EAd>)
Copies the inverse of the C flag to a specified bit in a general register or memory.
The bit number is specified by 3-bit immediate data.
14
Table 1-7.Branching Instructions
InstructionSizeFunction
Bcc--Branches if condition cc is true. The branching conditions are as follows.
MnemonicDescriptionCondition
BRA (BT)Always (True)Always
BRN (BF)Never (False)Never
BHIHighC ∨ Z = 0
BLSLow or SameC ∨ Z = 1
BCC (BHS)Carry Clear (High
or Same)
BCS (BLO)Carry Set (Low)C = 1
BNENot EqualZ = 0
BEQEqualZ = 1
BVCOverflow ClearV = 0
BVSOverflow SetV = 1
BPLPlusN = 0
BMIMinusN = 1
BGEGreater or EqualN ⊕ V = 0
BLTLess ThanN ⊕ V = 1
BGTGreater ThanZ ∨ (N ⊕ V) = 0
BLELess or EqualZ ∨ (N ⊕ V) = 1
JMP--Branches unconditionally to a specified address.
BSR--Branches to a subroutine at a specified displacement from the current
address.
JSR--Branches to a subroutine at a specified address.
RTS--Returns from a subroutine.
C = 0
15
Table 1-8.System Control Instructions
InstructionSize*Function
RTE--Returns from an exception handling routine.
SLEEP--Causes a transition to power-down state.
LDCBRs → CCR, #Imm → CCR
Moves immediate data or general register contents to the condition code
register.
STCBCCR → Rd
Copies the condition code register to a specified general register.
ANDCBCCR ∧ #Imm → CCR
Logically ANDs the condition code register with immediate data.
ORCBCCR ∨ #Imm → CCR
Logically ORs the condition code register with immediate data.
XORCBCCR ⊕ #Imm → CCR
Logically exclusive-ORs the condition code register with immediate data.
NOP--PC + 2 → PC
Only increments the program counter.
*Size: Operand size
B: Byte
Table 1-9.Block Data Transfer Instruction
InstructionSizeFunction
EEPMOV--if R4L ≠ 0 then
repeat @RS+ → @R6+
R4L - 1 → R4L
until R4L = 0
else next;
Moves a data block according to parameters set in general registers
R4L, R5, and R6.
R4L: size of block (bytes)
R5: starting source address
R6: starting destination address
Execution of the next instruction starts as soon as the block transfer is completed.
This instruction is for writing to the large-capacity EEPROM provided on chip with some
models in the H8/300L Series. For details see the applicable hardware manual.
16
Notes on Bit Manipulation Instructions: BSET, BCLR, BNOT, BST, and BIST are readmodify-write instructions. They read a byte of data, modify one bit in the byte, then write the
byte back. Care is required when these instructions are applied to registers with write-only bits
and to the I/O port registers.
SequenceOperation
1 ReadRead one data byte at the specified address
2 ModifyModify one bit in the data byte
3 WriteWrite the modified data byte back to the specified address
Example 1: BCLR is executed to clear bit 0 in port control register 4 (PCR4) under the
following conditions.
P47:Input pin, Low
P46:Input pin, High
P45 - P40:Output pins, Low
The intended purpose of this BCLR instruction is to switch P40 from output to input.
Explanation: To execute the BCLR instruction, the CPU begins by reading PCR4. Since PCR4
is a write-only register, it is read as H'FF, even though its true value is H'3F.
Next the CPU clears bit 0 of the read data, changing the value to H'FE.
Finally, the CPU writes this value (H'FE) back to PCR4 to complete the BCLR instruction.
As a result, bit 0 in PCR4 is cleared to 0, making P40 an input pin. In addition, bits 7 and 6 in
PCR4 are set to 1, making P47 and P46 output pins.
Example 2: BSET is executed to set bit 0 in the port 4 port data register (PDR4) under the
following conditions.
P47:Input pin, Low
P46:Input pin, High
P45 P40:Output pins, Low
The intended purpose of this BSET instruction is to switch the output level at P40 from Low to
High.
Explanation: To execute the BSET instruction, the CPU begins by reading port 4. Since P47
and P46 are input pins, the CPU reads the level of these pins directly, not the value in the port
data register. It reads P47 as Low (0) and P46 as High (1).
Since P45 to P40 are output pins, for these pins the CPU reads the value in PDR4. The CPU
therefore reads the value of port 4 as H'40, although the actual value in PDR4 is H'80.
Next the CPU sets bit 0 of the read data to 1, changing the value to H'41.
Finally, the CPU writes this value (H'41) back to PDR4 to complete the BSET instruction.
As a result, bit 0 in PDR4 is set to 0, switching pin P40 to High output. However, bits 7 and 6 in
PDR4 change their values.
19
1.3.3Basic Instruction Formats
(1) Format of Data Transfer Instructions
Figure 1-5 shows the format used for data transfer instructions.
15 870
op
15 780
15 780
op
15
op
15
r
n
15
15
r
n
15
op
r
m
r
mn
r
mn
disp.
78
r
mn
7op8
7op80
abs.
78
78
IMM
r
n
r
r
r
abs.
r
n
IMMopRn# xx:8
r
n
MOV
Rn
Rm
Rn @Rm, or @Rm Rn op
@(d:16,Rm) Rn, or
Rn @(d:16,Rm)
0
@ Rm+ Rn, or Rn @-Rm
0
@ aa :8 Rn, or Rn @ aa :8
@ aa :16 Rn, or
Rn @ aa :16
0
0
# xx:16Rn
20
15
op
780
Notation
op : Operation field
r , r : Register field