The revision list can be viewed directly by
clicking the title page.
The revision list summarizes the locations of
revisions and additions. Details should always
be checked by referring to the relevant text.
32
H8SX/1527 R5F61527
H8SX/1525 R5F61525
H8SX/1520Group
Hardware Manual
Renesas 32-Bit CISC Microcomputer
H8SX Family H8SX/1500 Series
Rev.3.00
Revision Date: Mar. 14, 2006
Rev. 3.00 Mar. 14, 2006 Page ii of xxxviii
Keep safety first in your circuit designs!
1. Renesas Technology Corp. puts the maximum effort into making semiconductor products better and
more reliable, but there is always the possibility that trouble may occur with them. Trouble with
semiconductors may lead to personal injury, fire or property damage.
Remember to give due consideration to safety when making your circuit designs, with appropriate
measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of nonflammable material or
(iii) prevention against any malfunction or mishap.
Notes regarding these materials
1. These materials are intended as a reference to assist our customers in the selection of the Renesas
Technology Corp. product best suited to the customer's application; they do not convey any license
under any intellectual property rights, or any other rights, belonging to Renesas Technology Corp. or
a third party.
2. Renesas Technology Corp. assumes no responsibility for any damage, or infringement of any thirdparty's rights, originating in the use of any product data, diagrams, charts, programs, algorithms, or
circuit application examples contained in these materials.
3. All information contained in these materials, including product data, diagrams, charts, programs and
algorithms represents information on products at the time of publication of these materials, and are
subject to change by Renesas Technology Corp. without notice due to product improvements or
other reasons. It is therefore recommended that customers contact Renesas Technology Corp. or
an authorized Renesas Technology Corp. product distributor for the latest product information
before purchasing a product listed herein.
The information described here may contain technical inaccuracies or typographical errors.
Renesas Technology Corp. assumes no responsibility for any damage, liability, or other loss rising
from these inaccuracies or errors.
Please also pay attention to information published by Renesas Technology Corp. by various means,
including the Renesas Technology Corp. Semiconductor home page (http://www.renesas.com).
4. When using any or all of the information contained in these materials, including product data,
diagrams, charts, programs, and algorithms, please be sure to evaluate all information as a total
system before making a final decision on the applicability of the information and products. Renesas
Technology Corp. assumes no responsibility for any damage, liability or other loss resulting from the
information contained herein.
5. Renesas Technology Corp. semiconductors are not designed or manufactured for use in a device or
system that is used under circumstances in which human life is potentially at stake. Please contact
Renesas Technology Corp. or an authorized Renesas Technology Corp. product distributor when
considering the use of a product contained herein for any specific purposes, such as apparatus or
systems for transportation, vehicular, medical, aerospace, nuclear, or undersea repeater use.
6. The prior written approval of Renesas Technology Corp. is necessary to reprint or reproduce in
whole or in part these materials.
7. If these products or technologies are subject to the Japanese export control restrictions, they must
be exported under a license from the Japanese government and cannot be imported into a country
other than the approved destination.
Any diversion or reexport contrary to the export control laws and regulations of Japan and/or the
country of destination is prohibited.
8. Please contact Renesas Technology Corp. for further details on these materials or the products
contained therein.
Rev. 3.00 Mar. 14, 2006 Page iii of xxxviii
General Precautions on Handling of Product
1. Treatment of NC Pins
Note: Do not connect anything to the NC pins.
The NC (not connected) pins are either not connected to any of the internal circuitry or are
used as test pins or to reduce noise. If something is connected to the NC pins, the
operation of the LSI is not guaranteed.
2. Treatment of Unused Input Pins
Note: Fix all unused input pins to high or low level.
Generally, the input pins of CMOS products are hi g h-impedance input pins. If unused pins
are in their open states, intermediate levels are induced by noise in the vicinity, a passthrough current flows internally, and a malfunction may occur.
3. Processing before Initialization
Note: When power is first supplied, the product's state is undefined.
The states of internal circuits are undefined until full power is supplied throughout the
chip and a low level is input on the reset pin. During the period where the states are
undefined, the register settings and the output state of each pin are also undefined. Design
your system so that it does not malfunction because of processing while it is in this
undefined state. For those products which have a reset function, reset the LSI immediately
after the power supply has been turned on.
4. Prohibition of Access to Undefined or Rese r ved Ad dresses
Note: Access to undefined or reserved addresses is prohibited.
The undefined or reserved addresses may be used to expand functions, or test registers
may have been be allocated to these addresses. Do not access these registers; the system's
operation is not guaranteed if they are accessed.
Rev. 3.00 Mar. 14, 2006 Page iv of xxxviii
Configuration of This Manual
This manual comprises the following items:
1. General Precautions on Handling of Product
2. Configuration of This Manual
3. Preface
4. Contents
5. Overview
6. Description of Functional Modules
• CPU and System-Control Modules
• On-Chip Peripheral Modules
The configuration of the functional description of each module differs according to the
module. However, the generic style includes the following items:
When designing an application system that includes this LSI, take notes into account. Each section
includes notes in relation to the descriptions given, and usage notes are given, as required, as the
final part of each section.
7. List of Registers
8. Electrical Characteristics
9. Appendix
10. Main Revisions and Additions in this Edition (only for revised versions)
The list of revisions is a summary of points that have been revised or added to earlier versions.
This does not include all of the revised contents. For details, see the actual locations in this
manual.
11. Index
Rev. 3.00 Mar. 14, 2006 Page v of xxxviii
Preface
The H8SX/1520 Group is a single-chip microcomputer made up of the high-speed internal 32-bit
H8SX CPU as its core, and the peripheral functions required to configure a system. The H8SX
CPU is upward compatible with the H8/300, H8/300H, and H8S CPUs.
Target Users: This manual was written for users who will be using the H8SX/1520 Group in the
design of application systems. Target users are expected to understand the
fundamentals of electrical circuits, logical circuits, and microcomputers.
Objective: This manual was written to explain the hardware functions and electrical
characteristics of the H8SX/1520 Group to the target users.
Refer to the H8SX Family Software Manual for a detailed description of the
instruction set.
Notes on reading this manual:
In order to understand the overall functions of the chip
Read the manual according to the contents. This manual can be roughl y categorized into parts
on the CPU, system control functions, and peripheral functions.
In order to understand the details of the CPU's functions
Read the H8SX Family Software Manual.
In order to understand the details of a register when its name is known
Read the index that is the final part of the manual to find the page number of the entry on the
register. The addresses, bits, and initial values of the registers are summarized in section 20,
List of Registers.
Examples: Register name: The following notation is used for cases when the same or a
similar function, e.g. 16-bit timer pulse unit or serial
communication interface, is implemented on more than one
channel:
XXX_N (XXX is the register name and N is the channel
number)
Bit order: The MSB is on the left and the LSB is on the right.
Number notation: Binary is B'xxxx, hexadecimal is H'xxxx, decimal is xxxx.
Signal notation: An overbar is added to a low-active signal: xxxx
Related Manuals: The latest versions of all related manuals are available from our w eb site.
Please ensure you have the latest versions of all documents you require.
http://www.renesas.com/
Figure 4.1 Reset Sequence (On-Chip ROM Enabled Advanced Mode)....................................... 77
Figure 4.2 Stack Status after Exception Handling........................................................................ 85
Figure 4.3 Operation when SP Value Is Odd................................................................................ 86
Section 5 Interrupt Controller
Figure 5.1 Block Diagram of Interrupt Controller........................................................................ 88
Figure 5.2 Block Diagram of Interrupts IRQn............................................................................ 104
Figure 5.3 Flowchart of Procedure Up to Interrupt Acceptance in Interrupt Control Mode 0... 113
Figure 5.4 Flowchart of Procedure Up to Interrupt Acceptance in Interrupt Control Mode 2... 115
Absolute Maximum Ratings .................................................................................761
Appendix
Table A.1
Port States in Each Pin State................................................................................. 779
Rev. 3.00 Mar. 14, 2006 Page xxxvii of xxxviii
Rev. 3.00 Mar. 14, 2006 Page xxxviii of xxxviii
Section 1 Overview
Section 1 Overview
1.1 Features
• 32-bit high-speed H8SX CPU
Upward compatible with the H8/300 CPU, H8/300H CPU, and H8S CPU
Sixteen 16-bit general registers
87 basic instructions
• Extensive peripheral functions
DMA controller (DMAC)
16-bit timer pulse unit (TPU)
Programmable pulse generator (PPG)*
Watch dog timer (WDT)
Serial communication interface (SCI) can be used in asynchronous and clocked synchronous
mode
Controller area network (HCAN)
Synchronous serial communication unit (SSU)
10-bit A/D converter
Clock pulse generator
Note: * Supported only by the H8SX/1527.
• On-chip memory
Product Classification Product Model ROM RAM
Flash memory version H8SX/1527 R5F61527 256 kbytes 12 kbytes
H8SX/1525 R5F61525 256 kbytes 12 kbytes
• General I/O port
65 input/output ports
17 input ports
• Supports power-down modes
• Small package
Package Code Body Size Pin Pitch
QFP-100 PRQP0100KB-A
(FP-100M)
14.0 × 14.0 mm 0.50 mm
Rev. 3.00 Mar. 14, 2006 Page 1 of 804
REJ09B0104-0300
Section 1 Overview
1.2 Block Diagram
RAM
ROM
H8SX
CPU
Clock pulse
generator
Internal bus
Interrupt
controller
BSC
DMAC
× 4 channels
WDT
TPU (unit 0)
× 6 channels
TPU (unit 1)
× 6 channels
PPG
SCI × 2 channels
HCAN
Peripheral bus
SSU × 3 channels
A/D (unit 0)
× 8 channels
A/D (unit 1)
× 8 channels
On-chip debugging
function for E10A
Por t 1
Por t 2
Por t 3
Por t 4
Por t 5
Por t 6
Por t A
Por t D
Por t H
Por t J
[Legend]
CPU: Central processing unit
DMAC: DMA controller
BSC: Bus controller
WDT: Watchdog timer
TPU: 16-bit timer pulse unit
PPG: Programmable pulse generator
SCI: Serial communication interface
HCAN: Controller area network
SSU: Synchronous communication unit
Figure 1.1 Block Diagram of H8SX/1527
Rev. 3.00 Mar. 14, 2006 Page 2 of 804
REJ09B0104-0300
Por t K
Section 1 Overview
RAM
ROM
H8SX
CPU
Clock pulse
generator
Internal bus
Interrupt
controller
BSC
DMAC
x 4 channels
Peripheral bus
A/D (unit 0) x 8 channels
A/D (unit 1) x 8 channels
WDT
TPU (unit 1)
x 6 channels
SCI x 2 channels
HCAN
SSU x 3 channels
On-chip debugging
function for E10A
Por t 1
Por t 2
Por t 3
Por t 4
Por t 5
Por t 6
Por t A
Por t D
Por t H
Por t J
Por t K
[Legend]
CPU: Central processing unit
DMAC: DMA controller
BSC: Bus controller
WDT: Watchdog timer
TPU: 16-bit timer pulse unit
SCI: Serial communication interface
HCAN: Controller area network
SSU: Synchronous communication unit
Note: * The EMLE (emulator enable) pin enables/disables the on-chip debugging functions. When the EMLE
pin is driven high, the TDO, TDI, TCK, TMS, and TRST pins are used specific for the E10A. In this
case, other pin functions are disabled.
Note: * The EMLE (emulator enable) pin enables/disables the on-chip debugging functions. When the EMLE
pin is driven high, the TDO, TDI, TCK, TMS, and TRST pins are used specific for the E10A. In this
case, other pin functions are disabled.
Figure 1.4 Pin Assignments of H8SX/1525
Rev. 3.00 Mar. 14, 2006 Page 5 of 804
REJ09B0104-0300
Section 1 Overview
1.3.2 Pin Configuration in Each Operating Mode
Table 1.1 Pin Configuration in Each Operating Mode
Pin No. Abbreviation in Mode 1, Mode 2, and Mode 3
Pin No. Abbreviation in Mode 1, Mode 2, and Mode 3
91 P53/AN3
92 P54/AN4
93 P55/AN5
94 P56/AN6
95 P57/AN7
96 MD0
97 PD0/SSO0
98 PD1/SSI0
99 PD2/SSCK0
100 PD3/SCS0
Notes: 1. Not supported by the H8SX/1525.
2. The EMLE (emulator enable) pin enables/disables the on-chip debugging functions.
When the EMLE pin is driven high, the TDO, TDI, TCK, TMS, and TRST pins are used
specific for the E10A. In this case, other pin functions are disabled.
The H8SX CPU is a high-speed CPU with an internal 32-bit architecture that is upwardcompatible with the H8/300, H8/300H, and H8S CPUs.
The H8SX CPU has sixteen 16-bit general registers, can handle a 4-Gbyte linear address space,
and is ideal for a realtime control system.
2.1 Features
• Upward-compatible with H8/300, H8/300 H, and H8S CPUs
Can execute H8/300, H8/300H, and H8S/2000 object programs
• Sixteen 16-bit general registers
Also usable as sixteen 8-bit registers or eight 32-bit registers
• 87 basic instructions
8/16/32-bit arithmetic and logic instructions
Multiply and divide instructions
Bit field transfer instructions
Powerful bit-manipulation instructions
Bit condition branch instructions
Multiply-and-accumulate instruction
• Eleven addressing modes
Register direct [Rn]
Register indirect [@ERn]
R egi st er in di rect with displacement [@(d:2,ERn) , @ ( d: 1 6, E R n) , or @( d:32,ERn)]
Index register indirect with displacement [@(d:16,RnL.B), @(d:32,RnL.B),
@(d:16,Rn.W), @(d:32,Rn.W), @(d:16,ERn.L), or @(d:32,ERn.L)]
Register indirect with pre-/post-increment or pre-/post-decrement [@+ERn, @ER n+, @−
ERn, or @ERn−]
Absolute address [@aa:8, @aa:16, @aa:24, or @aa:32]
Immediate [#xx:3, #xx:4, #xx:8, #xx:16, or #xx:32]
Pr ogram-counter relative [@(d:8,PC) or @(d:16,PC)]
Program-counter relative with index register [@(RnL.B,PC), @(Rn.W,PC), or
• High-speed operation
All frequently-used instructions executed in one or two states
8/16/32-bit register-register add/subtract: 1 state
8 × 8-bit register-register multiply: 1 state
16 ÷ 8-bit register-register divide: 10 states
16 × 16-bit register-register multiply: 1 state
32 ÷ 16-bit register-register divide: 18 states
32 × 32-bit register-register multiply: 5 states
32 ÷ 32-bit register-register divide: 18 states
• Four CPU operating modes
No rmal mo de
Middle mode
Advanced mode
Maximum mode
• Power-down modes
Transition is made by execution of SLEEP instruction
Choice of CPU operating clocks
Notes: 1. Advanced mode is only supported as the CPU operating mode of the H8SX/1520
Group. Normal, middle, and maximum modes are not supported.
2. The multiplier and divider are supported by the H8SX/1520 Group.
3. In the H8SX/1520 Group, an instruction is fetched in 32-bit mode.
Rev. 3.00 Mar. 14, 2006 Page 20 of 804
REJ09B0104-0300
Section 2 CPU
2.2 CPU Operating Modes
The H8SX CPU has four operating modes: normal, middle, advanced and maximum modes. For
details on mode settings, see section 3.1, Operating Mode Selection.
Normal mode
Middle mode
CPU operating modes
Advanced mode
Maximum mode
Maximum 64 kbytes for program
and data areas combined
Maximum 16-Mbyte program
area and 64-kbyte data area,
maximum 16 Mbytes for program
and data areas combined
Maximum 16-Mbyte program
area and 4-Gbyte data area,
maximum 4 Gbytes for program
and data areas combined
Maximum 4 Gbytes for program
and data areas combined
Figure 2.1 CPU Operating Modes
2.2.1 Normal Mode
The exception vector table and stack have the same structure as in the H8/300 CPU.
Note: Normal mode is not supported in this LSI.
• Address Space
The maximum address space of 64 kbytes can be accessed.
• Extended Registers (En)
The extended registers (E0 to E7) can be used as 16-bit registers, or as the upper 16-bit
segments of 32-bit registers. When the extended register En is used as a 16-bit register it can
contain any value, even when the corresponding general register Rn is used as an address
register. (If the general register Rn is referenced in the register indirect addressing mode with
pre-/post-increment or pre-/post - decrement and a carry or borrow occurs, however, the value in
the corresponding extended register En will be affected.)
• Instruction Set
All instructions and addressing modes can be used. Only the lower 16 bits of effective
addresses (EA) are valid.
Rev. 3.00 Mar. 14, 2006 Page 21 of 804
REJ09B0104-0300
Section 2 CPU
• Exception Vector Table and Memory Indirect Branch Addresses
In normal mode, the top area starting at H'0000 is allocated to the exception vect o r tabl e. One
branch address is stored per 16 bits. The structure of the exception vector table is shown in
figure 2.2.
H'0000
H'0001
H'0002
H'0003
Reset exception vector
Reset exception vector
Exception
vector table
Figure 2.2 Exception Vector Table (Normal Mode)
The memory indirect (@@aa:8) and extended memory indirect (@@vec:7) addressing modes
are used in the JMP and JSR instructions. An 8-bit absolute address included in the instruction
code specifies a memory location. Execution branches to the contents of the memory location.
• Stack Structure
The stack structure of PC at a subroutine branch and that of PC and CCR at an exception
handling are shown in figure 2.3. The PC contents are saved or restored in 16-bit units.
SPSP
PC
(16 bits)
(SP )
2
*
1
EXR*
Reserved*1,*
CCR
3
CCR*
PC
(16 bits)
3
(a) Subroutine Branch (b) Exception Handling
Notes: 1.
When EXR is not used it is not stored on the stack.
SP when EXR is not used.
2.
Ignored on return.
3.
Figure 2.3 Stack Structure (Normal Mode)
Rev. 3.00 Mar. 14, 2006 Page 22 of 804
REJ09B0104-0300
Section 2 CPU
2.2.2 Middle Mode
The program area in middle mode is extended to 16 Mbytes as compared with that in normal
mode.
• Address Space
The maximum address space of 16 Mbytes can be accessed as a total of the program and data
areas. For individual areas, up to 16 Mbytes of the program area or up to 64 kbytes of the data
area can be allocated.
• Extended Registers (En)
The extended registers (E0 to E7) can be used as 16-bit registers, or as the upper 16-bit
segments of 32-bit registers. When the extended register En is used as a 16-bit register (in
other than the JMP and JSR instructions), it can contain any value even when the
corresponding general register Rn is used as an address register. (If the general register Rn is
referenced in the register indirect addressing mode with pre-/post-increment or pre-/postdecrement and a carry or borrow occurs, however, the value in the corresponding extended
register En will be affected.)
• Instruction Set
All instructions and addressing modes can be used. Only the lower 16 bits of effective
addresses (EA) are valid and the upper eight bits are sign-extended.
• Exception Vector Table and Memory Indirect Branch Addresses
In middle mode, the top area starting at H'000000 is allocated to the exception vector table.
One branch address is stored per 32 bits. The upper eight bits are ignored and the lower 24 bits
are stored. The structure of the exception vector table is shown in figure 2.4.
The memory indirect (@@aa:8) and extended memory indirect (@@vec:7) addressing modes
are used in the JMP and JSR instructions. An 8-bit absolute address included in the instruction
code specifies a memory location. Execution branches to the contents of the memory location.
In middle mode, an operand is a 32-bit (longword) operand, providing a 32-bit branch address.
The upper eight bits are reserved and assumed to be H'00.
• Stack Structure
The stack structure of PC at a subroutine branch and that of PC and CCR at an exception
handling are shown in figure 2.5. The PC contents are saved or restored in 24-bit units.
Rev. 3.00 Mar. 14, 2006 Page 23 of 804
REJ09B0104-0300
Section 2 CPU
2.2.3 Advanced Mode
The data area is extended to 4 Gbytes as compared with that in middle mode.
• Address Space
The maximum address space of 4 Gbytes can be linearly accessed. For individual areas, up to
16 Mbytes of the program area and up to 4 Gbytes of the data area can be allocated.
• Extended Registers (En)
The extended registers (E0 to E7) can be used as 16-bit registers, or as the upper 16-bit
segments of 32-bit registers or address registers.
• Instruction Set
All instructions and addressing modes can be used.
• Exception Vector Table and Memory Indirect Branch Addresses
In advanced mode, the top area starting at H'00000000 is allocated to the exception vector
table. One branch address is stored per 32 bits. The upper eight bits are ignored and the lower
24 bits are stored. The structure of the exception vector table is shown in figure 2.4.
H'00000000
H'00000001
H'00000002
H'00000003
H'00000004
H'00000005
H'00000006
H'00000007
Reserved
Reset exception vector
Reserved
Exception vector table
Figure 2.4 Exception Vector Table (Middle and Advanced Modes)
The memory indirect (@@aa:8) and extended memory indirect (@@vec:7) addressing modes
are used in the JMP and JSR instructions. An 8-bit absolute address included in the instruction
code specifies a memory location. Execution branches to the contents of the memory location.
In advanced mode, an operand is a 32-bit (longword) operand, providing a 32-bit branch
address. The upper eight bits are reserved and assumed to be H'00.
Rev. 3.00 Mar. 14, 2006 Page 24 of 804
REJ09B0104-0300
• Stack Structure
The stack structure of PC at a subroutine branch and that of PC and CCR at an exception
handling are shown in figure 2.5. The PC contents are saved or restored in 24-bit units.
1
SP
SP
Reserved
PC
(24 bits)
(a) Subroutine Branch(b) Exception Handling
2
*
(SP )
EXR*
Reserved*1,*
CCR
PC
(24 bits)
3
Section 2 CPU
Notes: 1.
When EXR is not used it is not stored on the stack.
SP when EXR is not used.
2.
Ignored on return.
3.
Figure 2.5 Stack Structure (Middle and Advanced Modes)
2.2.4 Maximum Mode
The program area is extended to 4 Gbytes as compared with that in advanced mode.
• Address Space
The maximum address space of 4 Gbytes can be linearly accessed.
• Extended Registers (En)
The extended registers (E0 to E7) can be used as 16-bit registers or as the upper 16-bit
segments of 32-bit registers or address registers.
• Instruction Set
All instructions and addressing modes can be used.
• Exception Vector Table and Memory Indirect Branch Addresses
In maximum mode, the top area starting at H'00000000 is allocated to the exception vector
table. One branch address is stored per 32 bits. The structure of the exception vector table is
shown in figure 2.6.
Rev. 3.00 Mar. 14, 2006 Page 25 of 804
REJ09B0104-0300
Section 2 CPU
H'00000000
H'00000001
H'00000002
H'00000003
H'00000004
H'00000005
H'00000006
H'00000007
Reset exception vector
Exception vector table
Figure 2.6 Exception Vector Table (Maximum Modes)
The memory indirect (@@aa:8) and extended memory indirect (@@vec:7) addressing modes
are used in the JMP and JSR instructions. An 8-bit absolute address included in the instruction
code specifies a memory location. Execution branches to the contents of the memory location.
In maximum mode, an operand is a 32-bit (longword) operand, providing a 32-bit branch
address.
• Stack Structure
The stack structure of PC at a subroutine branch and that of PC and CCR at an exception
handling are shown in figure 2.7. The PC contents are saved or restored in 32-bit units. The
EXR contents are saved or restored regardless of whether or not EXR is in use.
SP
PC
(32 bits)
(a) Subroutine Branch(b) Exception Handling
SP
Figure 2.7 Stack Structure (Maximum Mode)
Rev. 3.00 Mar. 14, 2006 Page 26 of 804
REJ09B0104-0300
EXR
CCR
PC
(32 bits)
Section 2 CPU
2.3 Instruction Fetch
The H8SX CPU has two modes for instruction fetch: 16-bit and 32-bit modes. It is recommended
that the mode be set according to the bus width of the memory in which a program is stored. The
instruction-fetch mode setting does not affect operation other than instruction fetch such as data
accesses.
Note: In the H8SX/1520 Group, an instruction is fetched in 32-bit mode .
2.4 Address Space
Figure 2.8 shows a memory map of the H8SX CPU. The address space differs depending on the
CPU operating mode.
Normal mode
H'0000H'000000
H'007FFF
Program area
Data area
H'FFFF
(64 kbytes)
H'FF8000
H'FFFFFF
Middle modeAdvanced mode
H'00000000
Program area
(16 Mbytes)
Data area
(64 kbytes)
H'00FFFFFF
H'FFFFFFFF
Figure 2.8 Memory Map
H'00000000
Program area
(16 Mbytes)
Data area
(4 Gbytes)
H'FFFFFFFF
Maximum mode
Program area
Data area
(4 Gbytes)
Rev. 3.00 Mar. 14, 2006 Page 27 of 804
REJ09B0104-0300
Section 2 CPU
2.5 Registers
The H8SX CPU has the internal registers shown in figure 2.9. There are two types of registers:
general registers and control registers. The control registers are the 32-bit program counter (PC),
8-bit extended control register (EXR), 8-bit condition-code register (CCR), 32-bit vector base
register (VBR), 32-bit short address base register (SBR), and 64-bit multiply-accumulate register
(MAC).
General Registers and Extended Registers
ER0
ER1
ER2
ER3
ER4
ER5
ER6
ER7 (SP)
Control Registers
[Legend]
SP:
PC:
CCR:
I:
UI:
H:
U:
N:
150 70 70
E0
E1
E2
E3
E4
E5
E6
E7
310
PC
31012
VBR
3108
SBR
63
MAC
Stack pointer
Program counter
Condition-code register
Interrupt mask bit
User bit or interrupt mask bit
Half-carry flag
User bit
Negative flag
Sign extension
Z:
V:
C:
EXR:
T:
I2 to I0:
VBR:
SBR:
MAC:
R0H
R1H
R2H
R3H
R4H
R5H
R6H
R7H
MACL
Zero flag
Overflow flag
Carry flag
Extended control register
Trace bit
Interrupt mask bits
Vector base register
Short address base register
Multiply-accumulate register
R0L
R1L
R2L
R3L
R4L
R5L
R6L
R7L
76543210
UI
HUNZ VCCCR
I
7654321
T
————
(Reserved)
I2 I1 I0EXR
(Reserved)
MACH
0
3241
031
Figure 2.9 CPU Registers
Rev. 3.00 Mar. 14, 2006 Page 28 of 804
REJ09B0104-0300
Section 2 CPU
2.5.1 General Registers
The H8SX CPU has eight 32-bit general registers. These general registers are all functionally alike
and can be used as both address registers and data registers. When a general register is used as a
data register, it can be accessed as a 32-bit, 16-bit, or 8-bit register. Figure 2.10 illustrates the
usage of the general registers.
When the general registers are used as 32-bit registers or address registers, they are designated by
the letters ER (ER0 to ER7).
When the general registers are used as 16-bit registers, the ER registers are divided into 16-bit
general registers designated by the letters E (E0 to E7) and R (R0 to R7). These registers are
functionally equivalent, providing a maximum sixteen 16-bit registers. The E registers (E0 to E7)
are also referred to as extended registers.
When the general registers are used as 8-bit registers, the R registers are divided into 8-bit general
registers designated by the letters RH (R0H to R7H) and RL (R0L to R7L). These registers are
functionally equivalent, providing a maximum sixteen 8-bit registers.
The general registers ER (ER0 to ER7), R (R0 to R7), and RL (R0L to R7L) are also used as index
registers. The size in the operand field determines which register is selected.
The usage of each register can be selected independently.
16-bit registers
Address registers
•
32-bit registers
•
32-bit index registers
•
General registers ER
(ER0 to ER7)
•
General registers E
(E0 to E7)
16-bit registers
•
16-bit index registers
•
General registers R
(R0 to R7)
8-bit registers
•
General registers RH
(R0H to R7H)
8-bit registers
•
8-bit index registers
•
General registers RL
(R0L to R7L)
Figure 2.10 Usage of General Registers
General register ER7 has the function of stack pointer (SP) in addition to its general-register
function, and is used implicitly in exception handling and subroutine branches. Figure 2.11 shows
the stack.
Rev. 3.00 Mar. 14, 2006 Page 29 of 804
REJ09B0104-0300
Section 2 CPU
Free area
SP (ER7)
Stack area
Figure 2.11 Stack
2.5.2 Program Counter (PC)
PC is a 32-bit counter that indicates the address of the next instruction the CPU will execute. The
length of all CPU instructions is 16 bits (one word) or a multiple of 16 bits, so the least significant
bit is ignored. (When the instruction code is fetched, the least significant bit is regarded as 0.
2.5.3 Condition-Code Register (CCR)
CCR is an 8-bit register that contains internal CPU status information, including an interrupt mask
(I) and user (UI, U) bits and half-carry (H), negative (N), zero (Z), overflow (V), and carry (C)
flags.
Operations can be performed on the CCR bits by the LDC, STC, ANDC, ORC, and XORC
instructions. The N, Z, V, and C flags are used as branch conditions for conditional branch (Bcc)
instructions.
Initial
Bit Bit Name
7 I 1 R/W Interrupt Mask Bit
6 UI Undefined R/W User Bit or Interrupt Mask Bit
Rev. 3.00 Mar. 14, 2006 Page 30 of 804
REJ09B0104-0300
Value R/W Description
Masks interrupts when set to 1. This bit is set to 1 at the
start of an exception handling.
Can be written to and read from by software using the
LDC, STC, ANDC, ORC, and XORC instructions. This
bit can also be used as an interrupt mask bit.
Initial
Bit Bit Name
Value R/W Description
5 H Undefined R/W Half-Carry Flag
When the ADD.B, ADDX.B, SUB.B, SUBX.B, CMP.B, or
NEG.B instruction is executed, this flag is set to 1 if
there is a carry or borrow at bit 3, and cleared to 0
otherwise. When the ADD.W, SUB.W, CMP.W, or
NEG.W instruction is executed, this flag is set to 1 if
there is a carry or borrow at bit 11, and cleared to 0
otherwise. When the ADD.L, SUB.L, CMP.L, or NEG.L
instruction is executed, this flag is set to 1 if there is a
carry or borrow at bit 27, and cleared to 0 otherwise.
4 U Undefined R/W User Bit
Can be written to and read from by software using the
LDC, STC, ANDC, ORC, and XORC instructions.
3 N Undefined R/W Negative Flag
Stores the value of the most significant bit (regarded as
sign bit) of data.
2 Z Undefined R/W Zero Flag
Set to 1 to indicate zero data, and cleared to 0 to
indicate non-zero data.
1 V Undefined R/W Overflow Flag
Set to 1 when an arithmetic overflow occurs, and
cleared to 0 otherwise.
0 C Undefined R/W Carry Flag
Set to 1 when a carry occurs, and cleared to 0
otherwise. A carry has the following types:
• Carry from the result of addition
• Borrow from the result of subtraction
• Carry from the result of shift or rotation
The carry flag is also used as a bit accumulator by bit
manipulation instructions.
Section 2 CPU
Rev. 3.00 Mar. 14, 2006 Page 31 of 804
REJ09B0104-0300
Section 2 CPU
2.5.4 Extended Control Register (EXR)
EXR is an 8-bit register that contains the trace bit (T) and three interrupt mask bits (I2 to I0).
Operations can be performed on the EXR bits by the LDC, STC, ANDC, ORC, and XORC
instructions.
For details, see the hardware manual for the corresponding product.
Initial
Bit Bit Name
7 T 0 R/W Trace Bit
6 to 3 All 1 R/W Reserved
2
1
0
I2
I1
I0
Value R/W Description
When this bit is set to 1, a trace exception is generated
each time an instruction is executed. When this bit is
cleared to 0, instructions are executed in sequence.
These bits are always read as 1.
1
1
1
R/W
Interrupt Mask Bits
R/W
These bits designate the interrupt mask level (0 to 7).
R/W
2.5.5 Vector Base Register (VBR)
VBR is a 32-bit register in which the upper 20 bits are valid. The lower 12 bits of this register are
read as 0s. This register is a base address of the vector area for exception handlings ot her t han a
reset and a CPU address error (extended memory indirect is also out of the target). The initial
value is H'00000000. The VBR contents are changed with the LDC and STC instructions.
2.5.6 Short Address Base Register (SBR)
SBR is a 32-bit register in which the upper 24 bits are valid. The lower eight bits are read as 0s. In
8-bit absolute address addressing mode (@aa:8), this register is used as the upper address. The
initial value is H'FFFFFF00. The SBR contents are changed with the LDC and STC instructions.
Rev. 3.00 Mar. 14, 2006 Page 32 of 804
REJ09B0104-0300
Section 2 CPU
2.5.7 Multiply-Accumulate Register (MAC)
MAC is a 64-bit register that stores the results of multiply-and-accumulate operations. It consists
of two 32-bit registers denoted MACH and MACL. The lower 10 bits of MACH are valid; the
upper bits are sign extended. The MAC contents are changed with the MAC, CLRMAC, LDMAC,
and STMAC instructions.
2.5.8 Initial Values of CPU Registers
Reset exception handling loads the start address from the vector table into the PC, clears the T bit
in EXR to 0, and sets the I bits in CCR and EXR to 1. The general registers, MAC, and the other
bits in CCR are not initialized. In particular, the initial value of the stack pointer (ER7) is
undefined. The SP should therefore be initialized using an MOV.L instruction executed
immediately after a reset.
2.6 2Data Formats
The H8SX CPU can process 1-bit, 4-bit BCD, 8-bit (byte), 16-bit (word), and 32-bit (longword)
data.
Bit-manipulation instructions operate on 1-bit data by accessing bit n (n = 0, 1, 2, …, 7) of byte
operand data. The DAA and DAS decimal-adjust instr ucti on s treat byt e d at a as two digi t s of 4-bi t
BCD data.
2.6.1 General Register Data Formats
Figure 2.12 shows the data formats in general registers.
Rev. 3.00 Mar. 14, 2006 Page 33 of 804
REJ09B0104-0300
Section 2 CPU
1-bit data
1-bit data
4-bit BCD data
4-bit BCD data
Byte data
Byte data
Word data
Word data
Longword data
RnH
RnL
RnH
RnL
RnH
RnL
Rn
En
ERn
15
MSBLSB
31
MSB
[Legend]
ERn:
General register ER
En:
General register E
Rn:
General register R
RnH:
General register RH
En
16
43
0
70
Don’t careUpperLower
43
7
Upper
0
Don’t care
LSB
70
MSB
Rn
7
76543210Don’t care
Don’t care7 654321
70
Don’t care
7
MSB
Don’t care
15
MSB
0
15
General register RL
RnL:
Most significant bit
MSB:
Least significant bit
LSB:
0
0
Lower
LSB
0
LSB
0
LSB
Figure 2.12 General Register Data Formats
Rev. 3.00 Mar. 14, 2006 Page 34 of 804
REJ09B0104-0300
Section 2 CPU
2.6.2 Memory Data Formats
Figure 2.13 shows the data formats in memory.
The H8SX CPU can access word data and longword data which are stored at any addresses in
memory. When word data begins at an odd address or longword data begins at an address other
than a multiple of 4, a bus cycle is divided into two or more accesses. For example, when
longword data begins at an odd address, the bus cycle is divided into byte, word, and byte
accesses. In this case, these accesses are assumed to be individual bus cycles.
However, instructions to be fetched, word and longword data to be accessed during execution of
the stack manipulation, branch table manipulation, block transfer instructions, and MAC
instruction should be located to even addresses.
When SP (ER7) is used as an address register to access the stack, the operand size should be word
size or longword size.
Data TypeData Format
Address
70
1-bit data
Address L
76543210
Byte data
Word data
Longword data
Address L
Address 2M
Address 2M + 1
Address 2N
Address 2N + 1
Address 2N + 2
Address 2N + 3
MSBLSB
MSB
LSB
MSB
LSB
Figure 2.13 Memory Data Formats
Rev. 3.00 Mar. 14, 2006 Page 35 of 804
REJ09B0104-0300
Section 2 CPU
2.7 Instruction Set
The H8SX CPU has 87 types of instructions. The instructions are classified by function as shown
in table 2.1. The arithmetic operation, logic operation, shift, and bit manipulation instructions are
called operation instruction in this manual.
Table 2.1 Instruction Classification
Function Instructions Size Types
Data transfer MOV B/W/L 6
MOVFPE*6, MOVTPE*
POP, PUSH*
LDC (VBR, SBR) L S
STC (CCR, EXR) B/W*9 D D D D*11 D
STC (VBR, SBR) L D
XORC
8
B S S S
B S S S
B S
@ERn−/
Rn.W/
ERn.L)
@+ERn @aa:8
@aa:16/
@aa:32
[Legend]
d: d:16 or d:32
S: Can be specified as a source operand.
D: Can be specified as a destination operand.
SD: Can be specified as either a source or destination operand or both.
S/D: Can be specified as either a source or destination operand.
S:4: 4-bit immediate data can be specified as a source operand.
Notes: 1. Only @aa:16 is available.
2. @ERn+ as a source operand and @−ERn as a destination operand
3. Specified by ER5 as a source address and ER6 as a destination address for data
transfer.
4. Size of data to be added with a displacement
5. Only @ERn− is available
6. When the number of bits to be shifted is 1, 2, 4, 8, or 16
7. When the number of bits to be shifted is specified by 5-bit immediate data or a general
register
8. Size of data to specify a branch condition
9. Byte when immediate or register direct, otherwise, word
10. Only @ERn+ is available
11. Only @−ERn is available
12. Not available in this LSI.
Rev. 3.00 Mar. 14, 2006 Page 40 of 804
REJ09B0104-0300
Section 2 CPU
Table 2.2 Combinations of Instructions and Addressing Modes (2)
Addressing Mode
@(RnL.
B/Rn.W/
Classification
Branch BRA/BS,
Instruction Size @ERn @(d,PC)
O
BRA/BC
BSR/BS,
O
BSR/BC
Bcc O
BRA O O
BRA/S O*
JMP O O O O O
BSR O
JSR O O O O O
RTS, RTS/L O
TRAPA O System
control
RTE, RTE/L O
[Legend]
d: d:8 or d:16
Note: * Only @(d:8, PC) is available.
ERn.L,
PC) @aa:24 @ aa:32 @@ aa:8 @@vec:7
Rev. 3.00 Mar. 14, 2006 Page 41 of 804
REJ09B0104-0300
Section 2 CPU
2.7.2 Table of Instructions Classified by Function
Tables 2.4 to 2.11 summarize the instructions in each functional category. The notation used in
these tables is defined in table 2.3.
Table 2.3 Operation Notation
Operation Notation Description
Rd General register (destination)*
Rs General register (source)*
Rn General register*
ERn General register (32-bit register)
(EAd) Destination operand
(EAs) Source operand
EXR Extended control register
CCR Condition-code register
VBR Vector base register
SBR Short address base register
N N (negative) flag in CCR
Z Z (zero) flag in CCR
V V (overflow) flag in CCR
C C (carry) flag in CCR
PC Program counter
SP Stack pointer
#IMM Immediate data
disp Displacement
+ Addition
− Subtraction
× Multiplication
÷ Division
∧ Logical AND
∨ Logical OR
⊕ Logical exclusive OR
→ Move
∼ Logical not (logical complement)
:8/:16/:24/:32 8-, 16-, 24-, or 32-bit length
Note: * General registers include 8-bit registers (R0H to R7H, R0L to R7L), 16-bit registers (R0
to R7, E0 to E7), and 32-bit registers (ER0 to ER7).
Rev. 3.00 Mar. 14, 2006 Page 42 of 804
REJ09B0104-0300
Table 2.4 Data Transfer Instructions
Instruction Size Function
MOV B/W/L #IMM → (EAd), (EAs) → (EAd)
Transfers data between immediate data, general registers, and memory.
MOVFPE* B (EAs) → Rd
MOVTPE* B Rs → (EAs)
POP W/L @SP+ → Rn
Restores the data from the stack to a general register.
PUSH W/L Rn → @−SP
Saves general register contents on the stack.
LDM L @SP+ → Rn (register list)
Restores the data from the stack to multiple general registers. Two, three,
or four general registers which have serial register numbers can be
specified.
STM L Rn (register list) → @−SP
Saves the contents of multiple general registers on the stack. Two, three,
or four general registers which have serial register numbers can be
specified.
MOVA B/W EA → Rd
Zero-extends and shifts the contents of a specified general register or
memory data and adds them with a displacement. The result is stored in a
general register.
Note: * Not available in this LSI.
Section 2 CPU
Rev. 3.00 Mar. 14, 2006 Page 43 of 804
REJ09B0104-0300
Section 2 CPU
Table 2.5 Block Transfer Instructions
Instruction Size Function
EEPMOV.B
EEPMOV.W
MOVMD.B B Transfers a data block.
MOVMD.W W Transfers a data block.
MOVMD.L L Transfers a data block.
MOVSD.B B Transfers a data block with zero data detection.
B Transfers a data block.
Transfers byte data which begins at a memory location specified by ER5
to a memory location specified by ER6. The number of byte data to be
transferred is specified by R4 or R4L.
Transfers byte data which begins at a memory location specified by ER5
to a memory location specified by ER6. The number of byte data to be
transferred is specified by R4.
Transfers word data which begins at a memory location specified by ER5
to a memory location specified by ER6. The number of word data to be
transferred is specified by R4.
Transfers longword data which begins at a memory location specified by
ER5 to a memory location specified by ER6. The number of longword
data to be transferred is specified by R4.
Transfers byte data which begins at a memory location specified by ER5
to a memory location specified by ER6. The number of byte data to be
transferred is specified by R4. When zero data is detected during transfer,
the transfer stops and execution branches to a specified address.
Rev. 3.00 Mar. 14, 2006 Page 44 of 804
REJ09B0104-0300
Table 2.6 Arithmetic Operation Instructions
Instruction Size Function
ADD
SUB
ADDX
SUBX
INC
DEC
ADDS
SUBS
DAA
DAS
MULXU B/W Rd × Rs → Rd
MULU W/L Rd × Rs → Rd
MULU/U L Rd × Rs → Rd
MULXS B/W Rd × Rs → Rd
MULS W/L Rd × Rs → Rd
MULS/U L Rd × Rs → Rd
B/W/L (EAd) ± #IMM → (EAd), (EAd) ± (EAs) → (EAd)
Performs addition or subtraction on data between immediate data,
general registers, and memory. Immediate byte data cannot be
subtracted from byte data in a general register.
B/W/L (EAd) ± #IMM ± C → (EAd), (EAd) ± (EAs) ± C → (EAd)
Performs addition or subtraction with carry on data between immediate
data, general registers, and memory. The addressing mode which
specifies a memory location can be specified as register indirect with
post-decrement or register indirect.
B/W/L Rd ± 1 → Rd, Rd ± 2 → Rd
Increments or decrements a general register by 1 or 2. (Byte operands
can be incremented or decremented by 1 only.)
L Rd ± 1 → Rd, Rd ± 2 → Rd, Rd ± 4 → Rd
Adds or subtracts the value 1, 2, or 4 to or from data in a general register.
B Rd (decimal adjust) → Rd
Decimal-adjusts an addition or subtraction result in a general register by
referring to the CCR to produce 2-digit 4-bit BCD data.
Performs unsigned multiplication on data in two general registers: either 8
bits × 8 bits → 16 bits, or 16 bits × 16 bits → 32 bits.
Performs unsigned multiplication on data in two general registers: either 8
bits × 8 bits → 16 bits, or 16 bits × 16 bits → 32 bits.
Performs unsigned multiplication on data in two general registers (32 bits
× 32 bits → upper 32 bits).
Performs signed multiplication on data in two general registers: either 8
bits × 8 bits → 16 bits, or 16 bits × 16 bits → 32 bits.
Performs signed multiplication on data in two general registers: either 16
bits × 16 bits → 16 bits, or 32 bits × 32 bits → 32 bits.
Performs signed multiplication on data in two general registers (32 bits ×
32 bits → upper 32 bits).
Section 2 CPU
Rev. 3.00 Mar. 14, 2006 Page 45 of 804
REJ09B0104-0300
Section 2 CPU
Instruction Size Function
DIVXU B/W Rd ÷ Rs → Rd
Performs unsigned division on data in two general registers: either 16 bits
÷ 8 bits → 8-bit quotient and 8-bit remainder, or 32 bits ÷ 16 bits → 16-bit
quotient and 16-bit remainder.
DIVU W/L Rd ÷ Rs → Rd
Performs unsigned division on data in two general registers: either 16 bits
÷ 16 bits → 16-bit quotient, or 32 bits ÷ 32 bits → 32-bit quotient.
DIVXS B/W Rd ÷ Rs → Rd
Performs signed division on data in two general registers: either 16 bits ÷
8 bits → 8-bit quotient and 8-bit remainder, or 32 bits ÷ 16 bits → 16-bit
quotient and 16-bit remainder.
DIVS W/L Rd ÷ Rs → Rd
Performs signed division on data in two general registers: either 16 bits ÷
16 bits → 16-bit quotient, or 32 bits ÷ 32 bits → 32-bit quotient.
CMP B/W/L (EAd) − #IMM, (EAd) − (EAs)
Compares data between immediate data, general registers, and memory
and stores the result in CCR.
NEG B/W/L 0 − (EAd) → (EAd)
Takes the two's complement (arithmetic complement) of data in a general
register or the contents of a memory location.
EXTU W/L (EAd) (zero extension) → (EAd)
Performs zero-extension on the lower 8 or 16 bits of data in a general
register or memory to word or longword size.
The lower 8 bits to word or longword, or the lower 16 bits to longword can
be zero-extended.
EXTS W/L (EAd) (sign extension) → (EAd)
Performs sign-extension on the lower 8 or 16 bits of data in a general
register or memory to word or longword size.
The lower 8 bits to word or longword, or the lower 16 bits to longword can
be sign-extended.
TAS B @ERd − 0, 1 → (<bit 7> of @EAd)
Tests memory contents, and sets the most significant bit (bit 7) to 1.
MAC (EAs) × (EAd) + MAC → MAC
Performs signed multiplication on memory contents and adds the result to
MAC.
Performs a logical exclusive OR operation on data between immediate
data, general registers, and memory.
NOT B/W/L ∼ (EAd) → (EAd)
Takes the one's complement of the contents of a general register or a
memory location.
Section 2 CPU
Rev. 3.00 Mar. 14, 2006 Page 47 of 804
REJ09B0104-0300
Section 2 CPU
Table 2.8 Shift Operation Instructions
Instruction Size Function
SHLL
SHLR
SHAL
SHAR
ROTL
ROTR
ROTXL
ROTXR
B/W/L (EAd) (shift) → (EAd)
Performs a logical shift on the contents of a general register or a memory
location.
The contents of a general register or a memory location can be shifted by
1, 2, 4, 8, or 16 bits. The contents of a general register can be shifted by
any bits. In this case, the number of bits is specified by 5-bit immediate
data or the lower 5 bits of the contents of a general register.
B/W/L (EAd) (shift) → (EAd)
Performs an arithmetic shift on the contents of a general register or a
memory location.
1-bit or 2-bit shift is possible.
B/W/L (EAd) (rotate) → (EAd)
Rotates the contents of a general register or a memory location.
1-bit or 2-bit rotation is possible.
B/W/L (EAd) (rotate) → (EAd)
Rotates the contents of a general register or a memory location with the
carry bit.
1-bit or 2-bit rotation is possible.
Rev. 3.00 Mar. 14, 2006 Page 48 of 804
REJ09B0104-0300
Table 2.9 Bit Manipulation Instructions
Instruction Size Function
BSET B 1 → (<bit-No.> of <EAd>)
Sets a specified bit in the contents of a general register or a memory
location to 1. The bit number is specified by 3-bit immediate data or the
lower three bits of a general register.
BSET/cc B if cc, 1 → (<bit-No.> of <EAd>)
If the specified condition is satisfied, this instruction sets a specified bit in
a memory location to 1. The bit number can be specified by 3-bit
immediate data, or by the lower three bits of a general register. The Z flag
status can be specified as a condition.
BCLR B 0 → (<bit-No.> of <EAd>)
Clears a specified bit in the contents of a general register or a memory
location to 0. The bit number is specified by 3-bit immediate data or the
lower three bits of a general register.
BCLR/cc B if cc, 0 → (<bit-No.> of <EAd>)
If the specified condition is satisfied, this instruction clears a specified bit
in a memory location to 0. The bit number can be specified by 3-bit
immediate data, or by the lower three bits of a general register. The Z flag
status can be specified as a condition.
BNOT B ∼ (<bit-No.> of <EAd>) → (<bit-No.> of <EAd>)
Inverts a specified bit in the contents of a general register or a memory
location. The bit number is specified by 3-bit immediate data or the lower
three bits of a general register.
BTST B ∼ (<bit-No.> of <EAd>) → Z
Tests a specified bit in the contents of a general register or a memory
location and sets or clears the Z flag accordingly. The bit number is
specified by 3-bit immediate data or the lower three bits of a general
register.
BAND B C ∧ (<bit-No.> of <EAd>) → C
ANDs the carry flag with a specified bit in the contents of a general
register or a memory location and stores the result in the carry flag. The
bit number is specified by 3-bit immediate data.
BIAND B C ∧ [∼ (<bit-No.> of <EAd>)] → C
ANDs the carry flag with the inverse of a specified bit in the contents of a
general register or a memory location and stores the result in the carry
flag. The bit number is specified by 3-bit immediate data.
BOR B C ∨ (<bit-No.> of <EAd>) → C
ORs the carry flag with a specified bit in the contents of a general register
or a memory location and stores the result in the carry flag. The bit
number is specified by 3-bit immediate data.
Section 2 CPU
Rev. 3.00 Mar. 14, 2006 Page 49 of 804
REJ09B0104-0300
Section 2 CPU
Instruction Size Function
BIOR B C ∨ [~ (<bit-No.> of <EAd>)] → C
ORs the carry flag with the inverse of a specified bit in the contents of a
general register or a memory location and stores the result in the carry
flag. The bit number is specified by 3-bit immediate data.
BXOR B C ⊕ (<bit-No.> of <EAd>) → C
Exclusive-ORs the carry flag with a specified bit in the contents of a
general register or a memory location and stores the result in the carry
flag. The bit number is specified by 3-bit immediate data.
BIXOR B C ⊕ [~ (<bit-No.> of <EAd>)] → C
Exclusive-ORs the carry flag with the inverse of a specified bit in the
contents of a general register or a memory location and stores the result
in the carry flag. The bit number is specified by 3-bit immediate data.
BLD B (<bit-No.> of <EAd>) → C
Transfers a specified bit in the contents of a general register or a memory
location to the carry flag. The bit number is specified by 3-bit immediate
data.
BILD B ~ (<bit-No.> of <EAd>) → C
Transfers the inverse of a specified bit in the contents of a general
register or a memory location to the carry flag. The bit number is specified
by 3-bit immediate data.
BST B C → (<bit-No.> of <EAd>)
Transfers the carry flag value to a specified bit in the contents of a
general register or a memory location. The bit number is specified by 3-bit
immediate data.
BSTZ B Z → (<bit-No.> of <EAd>)
Transfers the zero flag value to a specified bit in the contents of a
memory location. The bit number is specified by 3-bit immediate data.
BIST B ∼ C → (<bit-No.> of <EAd>)
Transfers the inverse of the carry flag value to a specified bit in the
contents of a general register or a memory location. The bit number is
specified by 3-bit immediate data.
Rev. 3.00 Mar. 14, 2006 Page 50 of 804
REJ09B0104-0300
Section 2 CPU
Instruction Size Function
BISTZ B ∼ Z → (<bit-No.> of <EAd>)
Transfers the inverse of the zero flag value to a specified bit in the
contents of a memory location. The bit number is specified by 3-bit
immediate data.
BFLD B (EAs) (bit field) → Rd
Transfers a specified bit field in memory location contents to the lower bits
of a specified general register.
BFST B Rs → (EAd) (bit field)
Transfers the lower bits of a specified general register to a specified bit
field in memory location contents.
Table 2.10 Branch Instructions
Instruction Size Function
BRA/BS
BRA/BC
BSR/BS
BSR/BC
Bcc Branches to a specified address if the specified condition is satisfied.
BRA/S Branches unconditionally to a specified address after executing the next
JMP Branches unconditionally to a specified address.
BSR Branches to a subroutine at a specified address.
JSR Branches to a subroutine at a specified address.
RTS Returns from a subroutine.
RTS/L Returns from a subroutine, restoring data from the stack to multiple
B Tests a specified bit in memory location contents. If the specified
condition is satisfied, execution branches to a specified address.
B Tests a specified bit in memory location contents. If the specified
condition is satisfied, execution branches to a subroutine at a specified
address.
instruction. The next instruction should be a 1-word instruction except for
the block transfer and branch instructions.
general registers.
Rev. 3.00 Mar. 14, 2006 Page 51 of 804
REJ09B0104-0300
Section 2 CPU
Table 2.11 System Control Instructions
Instruction Size Function
TRAPA Starts trap-instruction exception handling.
RTE Returns from an exception-handling routine.
RTE/L Returns from an exception-handling routine, restoring data from the stack
Loads immediate data or the contents of a general register or a memory
location to CCR or EXR.
Although CCR and EXR are 8-bit registers, word-size transfers are
performed between them and memory. The upper 8 bits are valid.
L Rs → VBR, Rs → SBR
Transfers the general register contents to VBR or SBR.
B/W CCR → (EAd), EXR → (EAd)
Transfers the contents of CCR or EXR to a general register or memory.
Although CCR and EXR are 8-bit registers, word-size transfers are
performed between them and memory. The upper 8 bits are valid.
L VBR → Rd, SBR → Rd
Transfers the contents of VBR or SBR to a general register.
Logically ANDs the CCR or EXR contents with immediate data.
Logically ORs the CCR or EXR contents with immediate data.
Logically exclusive-ORs the CCR or EXR contents with immediate data.
Only increments the program counter.
Rev. 3.00 Mar. 14, 2006 Page 52 of 804
REJ09B0104-0300
Section 2 CPU
2.7.3 Basic Instruction Formats
The H8SX CPU instructions consist of 2-byte (1-word) units. An instruction consists of an
operation field (op field), a register field (r fi el d), an effective address extension (EA field), and a
condition field (cc).
Figure 2.14 shows examples of instruction formats.
(1) Operation field only
op
(2) Operation field and register fields
op
(3) Operation field, register fields, and effective address extension
op
EA (disp)
(4) Operation field, effective address extension, and condition field
opccEA (disp)BRA d:16, etc
rn
rnrm
rm
NOP, RTS, etc.
ADD.B Rn, Rm, etc.
MOV.B @(d:16, Rn), Rm, etc.
Figure 2.14 Instruction Formats
• Operation Field
Indicates the function of the instruction, and specifies the addressing mode and operation to be
carried out on the operand. The operation field always includes the first four bits of the
instruction. Some instructions have two operation fields.
• Register Field
Specifies a general register. Address registers are specified by 3 bits, data registers by 3 bits or
4 bits. Some instructions have two register fi el ds. Some hav e no regist er fi el d.
• Effective Address Extension
8, 16, or 32 bits specifying immediate data, an absolute address, or a displacement.
• Condition Field
Specifies the branch condition of Bcc instructions.
Rev. 3.00 Mar. 14, 2006 Page 53 of 804
REJ09B0104-0300
Section 2 CPU
2.8 Addressing Modes and Effective Address Calculation
The H8SX CPU supports the 11 addressing modes listed in table 2.12. Each instruction uses a
subset of these addressing modes.
Bit manipulation instructions use register direct, register indirect, or absolute addressing mode to
specify an operand, and register direct (BSET, BCLR, BNOT, and BTST instructions) or
immediate (3-bit) addressing mode to specify a bit number in the operand.
Table 2.12 Addressing Modes
No. Addressing Mode Symbol
1 Register direct Rn
2 Register indirect @ERn
3 Register indirect with displacement @(d:2,ERn)/@(d:16,ERn)/@(d:32,ERn)
4 Index register indirect with displacement @(d:16, RnL.B)/@(d:16,Rn.W)/@(d:16,ERn.L)
@(d:32, RnL.B)/@(d:32,Rn.W)/@(d:32,ERn.L)
5 Register indirect with post-increment @ERn+
Register indirect with pre-decrement @−ERn
Register indirect with pre-increment @+ERn
Register indirect with post-decrement @ERn−
6 Absolute address @aa:8/@aa:16/@aa:24/@aa:32
7 Immediate #xx:3/#xx:4/#xx:8/#xx:16/#xx:32
8 Program-counter relative @(d:8,PC)/@(d:16,PC)
9 Program-counter relative with index register @(RnL.B,PC)/@(Rn.W,PC)/@(ERn.L,PC)
10 Memory indirect @@aa:8
11 Extended memory indirect @@vec:7
Rev. 3.00 Mar. 14, 2006 Page 54 of 804
REJ09B0104-0300
Section 2 CPU
2.8.1 Register Direct—Rn
The operand value is the contents of an 8-, 16-, or 32-bit general register whi ch is specified by the
register field in the instruction code.
R0H to R7H and R0L to R7L can be specified as 8-bit registers.
R0 to R7 and E0 to E7 can be specified as 16-bit registers.
ER0 to ER7 can be specified as 32-bit registers.
2.8.2 Register Indirect—@ERn
The operand value is the contents of the memory location which is pointed to by the contents of an
address register (ERn). ERn is specified by the register field of the instruction code.
In advanced mode, if this addressing mode is used in a branch instruction, the lower 24 bits are
valid and the upper 8 bits are all assumed to be 0 (H'00).
2.8.3 Register Indirect with Displacement—@(d:2, ERn), @(d:16, ERn), or
@(d:32, ERn)
The operand value is the contents of a memory location which is pointed to by the sum of the
contents of an address register (ERn) and a 16- or 32-bit displacement. ERn is specified by the
register field of the instruction code. The displacement is included in the instruction code and the
16-bit displacement is sign-extended when added to ERn.
This addressing mode has a short format (@(d:2, ERn)). The short format can be used when the
displacement is 1, 2, or 3 and the operand is byte data, when the displacement is 2, 4, or 6 and the
operand is word data, or when the displacement is 4, 8, or 12 and the operand is longword data.
Rev. 3.00 Mar. 14, 2006 Page 55 of 804
REJ09B0104-0300
Section 2 CPU
2.8.4 Index Register Indirect with Displacement—@(d:16,RnL.B), @(d:32,RnL.B),
@(d:16,Rn.W), @(d:32,Rn.W), @(d:16,ERn.L), or @(d:32,ERn.L)
The operand value is the contents of a memory location which is pointed to by the sum of the
following operation result and a 16- or 32-bit displacement: a specified bits of the contents of an
address register (RnL, Rn, ERn) specified by the register field in the instruction code are zeroextended to 32-bit data and multiplied by 1, 2, or 4. The displacement is included in the instruction
code and the 16-bit displacement is sign-extended when added to ERn. If the operand is byte data,
ERn is multiplied by 1. If the operand is word or longword data, ERn is multiplied by 2 or 4,
respectively.
2.8.5 Register Indirect with Post-Increment, Pre-Decrement, Pre-Increment,
or Post-Decrement—@ERn+, @−ERn, @+ERn, or @ERn−
(1) Register indirect with post-increment—@ERn+
The operand value is the contents of a memory location which is pointed to by the contents of an
address register (ERn). ERn is specified by the register field of the instruction code. After the
memory location is accessed, 1, 2, or 4 is added to the address register contents and the sum is
stored in the address register. The value added is 1 for byte access, 2 for word access, or 4 for
longword access.
(2) Register indirect with pre-decrement—@−ERn
The operand value is the contents of a memory location which is pointed to by the fo llowing
operation result: the value 1, 2, or 4 is subtracted from the contents of an address register (ERn).
ERn is specified by the register field of the instruction code. After that, the operand value is stored
in the address register. The value subtracted is 1 for byte access, 2 for word access, or 4 for
longword access.
(3) Register indirect with pre-increment—@+ERn
The operand value is the contents of a memory location which is pointed to by the fo llowing
operation result: the value 1, 2, or 4 is added to the contents of an address register (ERn). ERn is
specified by the register field of the instruction code. After that, the operand value is stored in the
address register. The value added is 1 for byte access, 2 for word access, or 4 for longword access.
Rev. 3.00 Mar. 14, 2006 Page 56 of 804
REJ09B0104-0300
Section 2 CPU
(4) Register indirect with post-decrement—@ERn−
The operand value is the contents of a memory location which is pointed to by the contents of an
address register (ERn). ERn is specified by the register field of the instruction code. After the
memory location is accessed, 1, 2, or 4 is subtracted from the address register contents and the
remainder is stored in the address register. The value subtracted is 1 for byte access, 2 for word
access, or 4 for longword access.
If the contents of a general register which is also used as an address register is written to memory
using this addressing mode, data to be written is the contents of the general register after
calculating an effective address. If the same general register is specified in an instruction and two
effective addresses are calculated, the contents of the general register after the first calculation of
an effective address is used in the second calculation of an effective address.
Example 1:
MOV.W R0, @ER0+
When ER0 before execution is H'12345678, H'567A is written at H'12345678.
Example 2:
MOV.B @ER0+, @ER0+
When ER0 before execution is H'00001000, H'00001000 is read and the contents is written at
H'00001001.
After execution, ER0 is H'00001002.
Rev. 3.00 Mar. 14, 2006 Page 57 of 804
REJ09B0104-0300
Section 2 CPU
2.8.6 Absolute Address—@aa:8, @aa:16, @aa:24, or @aa:32
The operand value is the contents of a memory location which is pointed to by an ab solute address
included in the instruction code.
There are 8-bit (@aa:8), 16-bit (@aa:16), 24-bit (@aa:24), and 32-bit (@aa:32) absolute
addresses.
To access the data area, the absolute address of 8 bits (@aa:8), 16 bits (@aa:16), or 32 bits
(@aa:32) is used. For an 8-bit absolute address, the upper 24 bits are specif ied by SBR. For a 16bit absolute address, the upper 16 bits are sign-extended. A 32-bit absolute address can access the
entire address space.
To access the program area, the absolute address of 24 bits (@aa:24) or 32 bits (@aa:32) is used.
For a 24-bit absolute address, the upper 8 bits are all assumed to be 0 (H'00).
Table 2.13 shows the accessible absolute address ranges.
Table 2.13 Absolute Address Access Ranges
Absolute
Address
Data area 8 bits
(@aa:8)
16 bits
(@aa:16)
32 bits
(@aa:32)
Program area 24 bits
(@aa:24)
32 bits
(@aa:32)
Rev. 3.00 Mar. 14, 2006 Page 58 of 804
REJ09B0104-0300
Normal
Mode
A consecutive 256-byte area (the upper address is set in SBR)
H'0000 to
H'FFFF
H'000000 to
H'00000000 to
Middle
Mode
H'000000 to
H'007FFF,
H'FF8000 to
H'FFFFFF
H'FFFFFF
Advanced
Mode
H'00000000 to H'00007FFF,
H'FFFF8000 to H'FFFFFFFF
H'00000000 to H'FFFFFFFF
H'00000000 to H'00FFFFFF
H'00FFFFFF
Maximum
Mode
H'00000000 to
H'FFFFFFFF
Section 2 CPU
2.8.7 Immediate—#xx
The operand value is 8-bit (#xx:8), 16-bit (#xx:16), or 32-bit (#xx:32) data included in the
instruction code.
This addressing mode has short formats in which 3- or 4-bit immediate data can be used.
When the size of immediate data is less than that of the destination operand value (byte, word, or
longword) the immediate data is zero-extended.
The ADDS, SUBS, INC, and DEC instructions contain immediate data implicitly. Some bit
manipulation instructions contain 3-bit immediate data in the instruction code, for specifying a bit
number. The BFLD and BFST instructions contain 8-bit immediate data in the instruction code,
for specifying a bit field. The TRAPA instruction contains 2-bit immediate data in the instruction
code, for specifying a vector address.
2.8.8 Program-Counter Relative—@(d:8, PC) or @(d:16, PC):
This mode is used in the Bcc and BSR instructions. The opera n d value is a 32-bit branch ad dress,
which is the sum of an 8- or 16-bit displacement in the instruction code and the 32-bit address of
the PC contents. The 8-bit or 16-bit displacement is sign-extended to 32 bits when added to the PC
contents. The PC contents to which the displacement is added is the address of the first byte of the
next instruction, so the possible branching range is −126 to +128 bytes (−63 to +64 words) or
−32766 to +32768 bytes (−16383 to +16384 words) from the branch instruction. The resulting
value should be an even number. In advanced mode, only the lower 24 bits of this branch address
are valid; the upper 8 bits are all assumed to be 0 (H'00).
2.8.9 Program-Counter Relative with Index Register—
@(RnL.B, PC), @(Rn.W, PC), or @(ERn.L, PC)
This mode is used in the Bcc and BSR instructions. The opera n d value is a 32-bit branch ad dress,
which is the sum of the following operation result and the 32-bit address of the PC contents: the
contents of an address register specified by the register field in the instruction code (RnL, Rn, or
ERn) is zero-extended and multiplied by 2. The PC contents to which the displacement is added is
the address of the first byte of the next instruction. In advanced mode, only the lower 24 bits of
this branch address are valid; the upper 8 bits are all assumed to be 0 (H'00).
Rev. 3.00 Mar. 14, 2006 Page 59 of 804
REJ09B0104-0300
Section 2 CPU
2.8.10 Memory Indirect—@@aa:8
This mode can be used by the JMP and JSR instructions. The operand value is a branch address,
which is the contents of a memory location pointed to by an 8-bit absolute address in the
instruction code.
The upper bits of an 8-bit absolute address are all assumed to be 0, so the address range is 0 to 255
(H'0000 to H'00FF in normal mode, H'000000 to H'0000FF in other modes).
In normal mode, the memory location is pointed to by word-size data and the branch address is 16
bits long. In other modes, the memory location is pointed to by longword-size data. In middle or
advanced mode, the first byte of the longword-size data is assumed to be all 0 (H'00).
Note that the top part of the address range is also used as the exception handling vector area. A
vector address of an exception handling other than a reset or a CPU address error can be changed
by VBR.
Figure 2.15 shows an example of specification of a br anch address using this addressing mode.
Specified
by @aa:8
Branch address
(a) Normal Mode(b) Advanced Mode
Specified
by @aa:8
Figure 2.15 Branch Address Specification in Memory Indirect Mode
Rev. 3.00 Mar. 14, 2006 Page 60 of 804
REJ09B0104-0300
Reserved
Branch address
Section 2 CPU
2.8.11 Extended Memory Indirect—@@vec:7
This mode can be used by the JMP and JSR instructions. The operand value is a branch address,
which is the contents of a memory location pointed to by the following operation result: the sum
of 7-bit data in the instruction code and the value of H'80 is multiplied by 2 or 4.
The address range to store a branch address is H'0100 to H'01FF in normal mode and H'000200 to
H'0003FF in other modes. In assembler notation, an address to store a branch address is specified.
In normal mode, the memory location is pointed to by word-size data and the branch address is 16
bits long. In other modes, the memory location is pointed to by longword-size data. In middle or
advanced mode, the first byte of the longword-size data is assumed to be all 0 (H'00).
2.8.12 Effective Address Calculation
Tables 2.14 and 2.15 show how effective addresses are calculated in each addressing mode. The
lower bits of the effective address are valid and the upper bit s are ign ore d (zero extended or sign
extended) according to the CPU operating mode.
The valid bits in middle mode are as follows:
• The lower 16 bits of the effective address are valid and the upper 16 bits are sign-extended for
the transfer and operation instructions.
• The lower 24 bits of the effective address are valid and the upper eight bits are zero-extended
for the branch instructions.
Rev. 3.00 Mar. 14, 2006 Page 61 of 804
REJ09B0104-0300
Section 2 CPU
Table 2.14 Effective Address Calculation for Transfer and Operation Instructions
No.
Addressing Mode and Instruction FormatEffective Address CalculationEffective Address (EA)
1
Immediate
IMM
Register direct
2
opoprm rn
Register indirect
3
op
r
4
Register indirect with 16-bit displacement
r
op
disp
Register indirect with 32-bit displacement
op
r
disp
310310
General register contents
310
General register contents
3115
Sign extension
310
General register contents
disp
disp
310
+
0
310
+
5
Index register indirect with 16-bit displacement
r
op
disp
Index register indirect with 32-bit displacement
r
op
Register indirect with post-increment or post-decrement
6
op
Register indirect with pre-increment or pre-decrement
op
8-bit absolute address
7
op
16-bit absolute address
32-bit absolute address
disp
r
r
aa
op
aa
op
aa
310
Zero extension
Contents of general register
(RL, R, or ER)
3115
Sign extension
310
Zero extension
Contents of general register
(RL, R, or ER)
31
31
31
3107
3115
Sign extension
31
disp
General register contents
General register contents
SBR
aa
1, 2, or 4
disp
1, 2, or 4
1, 2, or 4
1, 2, or 4
aa
aa
×
310
+
0
×
310
0
+
0
310
±
0
310
±
310
310
0
0
310
Rev. 3.00 Mar. 14, 2006 Page 62 of 804
REJ09B0104-0300
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.