U12197ej6v0um00 Nec Manual
U12197ej6v0um00 Nec Manual
U12197ej6v0um00 Nec Manual
TM
TM
V850E/MS1 , V850E/MS2
32-Bit Single-Chip Microcontrollers
Architecture
V850E/MS1:
PD703100
PD703100A
PD703101
PD703101A
PD703102
PD703102A
PD70F3102
PD70F3102A
V850E/MS2:
PD703130
[MEMO]
V800 Series, V850 Series, V850/SA1, V850/SB1, V850/SB2, V850/SC1, V850/SC2, V850/SC3, V850/SF1,
V850/SV1, V850E/IA1, V850E/IA2, V850E/MA1, V850E/MA2, V850E/MS1, V850E/MS2, V851, V852, V853, V854,
and IEBus are trademarks of NEC Electronics Corporation.
Windows is either a registered trademark or a trademark of Microsoft Corporation in the United States and/or
other countries.
The information in this document is current as of August, 2002. The information is subject to
change without notice. For actual design-in, refer to the latest publications of NEC Electronics data
sheets or data books, etc., for the most up-to-date specifications of NEC Electronics products. Not
all products and/or types are available in every country. Please check with NEC Electronics sales
representative for availability and additional information.
No part of this document may be copied or reproduced in any form or by any means without prior
written consent of NEC Electronics. NEC Electronics assumes no responsibility for any errors that may
appear in this document.
NEC Electronics does not assume any liability for infringement of patents, copyrights or other intellectual
property rights of third parties by or arising from the use of NEC Electronics products listed in this document
or any other liability arising from the use of such NEC Electronics products. No license, express, implied or
otherwise, is granted under any patents, copyrights or other intellectual property rights of NEC Electronics or
others.
Descriptions of circuits, software and other related information in this document are provided for illustrative
purposes in semiconductor product operation and application examples. The incorporation of these
circuits, software and information in the design of customer's equipment shall be done under the full
responsibility of customer. NEC Electronics assumes no responsibility for any losses incurred by customers
or third parties arising from the use of these circuits, software and information.
While NEC Electronics endeavors to enhance the quality, reliability and safety of NEC Electronics products,
customers agree and acknowledge that the possibility of defects thereof cannot be eliminated entirely. To
minimize risks of damage to property or injury (including death) to persons arising from defects in NEC
Electronics products, customers must incorporate sufficient safety measures in their design, such as
redundancy, fire-containment and anti-failure features.
NEC Electronics products are classified into the following three quality grades: "Standard", "Special" and
"Specific".
The "Specific" quality grade applies only to NEC Electronics products developed based on a customerdesignated "quality assurance program" for a specific application. The recommended applications of NEC
Electronics product depend on its quality grade, as indicated below. Customers must check the quality grade of
each NEC Electronics product before using it in a particular application.
"Standard": Computers, office equipment, communications equipment, test and measurement equipment, audio
and visual equipment, home electronic appliances, machine tools, personal electronic equipment
and industrial robots.
"Special": Transportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster
systems, anti-crime systems, safety equipment and medical equipment (not specifically designed
for life support).
"Specific": Aircraft, aerospace equipment, submersible repeaters, nuclear reactor control systems, life
support systems and medical equipment for life support, etc.
The quality grade of NEC Electronics products is "Standard" unless otherwise expressly specified in NEC
Electronics data sheets or data books, etc. If customers wish to use NEC Electronics products in applications
not intended by NEC Electronics, they must contact NEC Electronics sales representative in advance to
determine NEC Electronics's willingness to support a given application.
(Note)
(1) "NEC Electronics" as used in this statement means NEC Electronics Corporation and also includes its
majority-owned subsidiaries.
(2) "NEC Electronics products" means any product developed or manufactured by or for NEC Electronics
(as defined above).
M8E 02. 11
Regional Information
Some information contained in this document may vary from country to country. Before using any NEC
Electronics product in your application, pIease contact the NEC Electronics office in your country to
obtain a list of authorized representatives and distributors. They will verify:
Device availability
Ordering information
Development environment specifications (for example, specifications for third-party tools and
components, host computers, power plugs, AC supply voltages, and so forth)
Network requirements
In addition, trademarks, registered trademarks, export restrictions, and other legal issues may also vary
from country to country.
Filiale Italiana
Milano, Italy
Tel: 02-66 75 41
Fax: 02-66 75 42 99
Hong Kong
Tel: 2886-9318
Fax: 2886-9022/9044
Seoul Branch
Seoul, Korea
Tel: 02-528-0303
Fax: 02-528-4411
Tyskland Filial
Taeby, Sweden
Tel: 08-63 80 820
Fax: 08-63 80 388
Taipei, Taiwan
Tel: 02-2719-2377
Fax: 02-2719-5951
J02.11
Description
p.60
p.90
p.105
p.110
p.112
p.185
The mark
PREFACE
Readers
This manual is intended for users who wish to understand the functions of the
V850E/MS1 and V850E/MS2 for designing systems using the V850E/MS1 and
V850E/MS2. The following products are described.
V850E/MS1:
PD703100, 703100A, 703101A, 703102, 703102A, 70F3102,
V850E/MS2:
Purpose
70F3102A
PD703130
This manual presents information on the architecture and instruction set of the
V850E/MS1 and V850E/MS2.
Organization
Data type
Instruction format and instruction set
Interrupts and exceptions
Pipeline flow
It is assumed that the reader of this manual has general knowledge in the fields of
electrical engineering, logic circuits, and microcontrollers.
To learn about the hardware functions,
Read V850E/MS1 Hardware Users Manual and V850E/MS2 Hardware Users
Manual.
To learn about the functions of a specific instruction in detail,
Read CHAPTER 5 INSTRUCTIONS.
To learn about the electrical specifications,
Read the DATA SHEET of each device.
To understand the overall functions of the V850E/MS1 and V850E/MS2,
Read this manual in the order of the contents.
With the V850E/MS1 and V850E/MS2, data consisting of 2 bytes is called a halfword,
and data consisting of 4 bytes is called a word.
In this manual, the V850E/MS1 is explained as the typical product unless there are any
functional differences.
Conventions
Data significance:
Active low:
Note:
Caution:
Remark:
Supplementary information
Numeric representation:
Binary ... or B
Decimal ...
Hexadecimal ... H
210 = 1024
Word32 bits
Halfword16 bits
Byte8 bits
Related Documents
The related documents indicated in this publication may include preliminary versions.
However, preliminary versions are not marked as such.
Documents related to devices
Document Name
Document Number
U13995E
U14168E
U13844E
U13845E
U15390E
U12688E
U14985E
This manual
U14214E
Document Number
U13875E
IE-703102-MC-EM1, IE-703102-MC-EM1-A
(In-circuit emulator option board)
U13876E
Operation
U14568E
C language
U14566E
Project manager
U14569E
Assembly language
U14567E
U14580E
U14782E
U14873E
Fundamental
U13430E
Installation
U13410E
Technical
U13431E
Fundamental
U13773E
Installation
U13774E
Technical
U13772E
U13916E
U13737E
U11181E
U13502E
CONTENTS
CHAPTER 1 INTRODUCTION........................................................................................................................... 14
1.1
1.2
1.3
1.4
1.5
General .................................................................................................................................................. 14
Features ................................................................................................................................................ 15
Product Development .......................................................................................................................... 16
CPU Configuration ............................................................................................................................... 17
Differences with Architecture of V850 CPU....................................................................................... 18
2.2
2.2.2
2.2.3
2.2.4
2.2.5
2.2.6
2.2.7
2.2.8
3.2
3.3
Integer...................................................................................................................................................... 29
3.2.2
Unsigned integer...................................................................................................................................... 30
3.2.3
Bit............................................................................................................................................................. 30
Instruction address................................................................................................................................... 33
4.2.2
10
6.2
6.3
6.1.2
6.2.2
Initialization......................................................................................................................................... 140
Starting Up .......................................................................................................................................... 140
8.4
8.3.2
8.3.3
Arithmetic operation instructions (excluding multiply and divide instructions) ....................................... 147
8.3.4
8.3.5
8.3.6
8.3.7
8.3.8
8.3.9
8.3.10
8.4.2
8.4.3
8.4.4
Referencing execution result of LDSR instruction for EIPC and FEPC ................................................. 157
8.4.5
11
LIST OF FIGURES
Figure No.
12
Title
Page
1-1
1-2
2-1
2-2
2-3
4-1
Memory Map..................................................................................................................................................... 32
4-2
4-3
4-4
4-5
4-6
4-7
6-1
6-2
6-3
6-4
6-5
6-6
8-1
8-2
8-3
8-4
8-5
8-6
8-7
8-8
8-9
Example of Execution Result of LDSR Instruction for EIPC and FEPC ......................................................... 157
LIST OF TABLES
Table No.
Title
Page
1-1
2-1
5-1
5-2
5-3
5-4
5-5
Branch Instructions........................................................................................................................................... 45
5-6
5-7
5-8
5-9
5-10
6-1
7-1
8-1
A-1
B-1
B-2
D-1
Instructions Added to V850E CPU and V850 CPU Instructions with Same Instruction Code ........................ 180
13
CHAPTER 1 INTRODUCTION
TM
is a collection of NEC Electronics single-chip microcontrollers that have a CPU core that uses
TM
the RISC microprocessor technology of the V800 Series , and incorporate functions such as internal ROM/RAM and
peripheral I/O.
The V850 Series of microcontrollers provides a migration path to NEC Electronics existing 78K Series of original
single-chip microcontrollers, and boasts a higher cost-performance.
The V850 Series includes products that incorporate the V850 CPU and products that incorporate the V850E CPU.
The V850E/MS1 is one of the latter.
This chapter briefly outlines the V850 Series.
1.1 General
Real-time control systems are used in a wide range of applications, including:
Office equipment such as HDDs (Hard Disk Drives), PPCs (Plain Paper Copiers), printers, and facsimiles,
Automotive electronics such as engine control systems and ABSs (Antilock Braking Systems)
Factory automation equipment such as NC (Numerical Control) machine tools and various controllers.
The great majority of these systems conventionally employ 8-bit or 16-bit microcontrollers. However, the
performance level of these microcontrollers has become inadequate in recent years as control operations have risen
in complexity, leading to the development of increasingly complicated instruction sets and hardware design. As a
result, the need has arisen for a new generation of microcontrollers operable at much higher frequencies to achieve
an acceptable level of performance under todays more demanding requirements.
The V850 Series of microcontrollers was developed to satisfy this need. This series uses RISC architecture that
provides maximum performance with simpler hardware, allowing users to obtain a performance approximately 15
times higher than that of the existing 78K/III Series and 78K/IV Series of CISC single-chip microcontrollers at a lower
total cost.
In addition to the basic instructions of conventional RISC CPUs, the V850 Series is provided with special
instructions such as saturation, bit manipulation, and multiply/divide (executed by a hardware multiplier), which are
especially well suited to digital servo control systems. Moreover, instruction formats are designed for maximum
compiler coding efficiency, allowing the reduction in the object code size.
14
CHAPTER 1 INTRODUCTION
1.2 Features
4 GB linear
Special instructions
Saturation operation instructions
Bit manipulation instructions
On-chip multiplier executing multiplication in 1 to 2 clocks
16 bits 16 bits 32 bits
32 bits 32 bits 32 or 64 bits
15
CHAPTER 1 INTRODUCTION
TM
TM
TM
TM
TM
TM
The members of V850 Series are the V851 , V852 , V853 , V854 , V850/SV1 , V850/SA1 , V850/SB1 ,
TM
TM
TM
TM
TM
V850/SB2 , V850/SF1 , V850/SC1 , V850/SC2 , and V850/SC3 , which incorporate the V850 CPU, and the
TM
TM
TM
TM
such
as
language
switch
statement
processing,
table
lookup
branching,
stack
frame
generation/deletion, and data conversion. The instruction code is upwardly compatible at the object code level with
the V850 CPU, allowing the software resources contained in the V850 CPU to be used as is.
Figure 1-1. V850 Series Lineup
Performance
Under development
V850E/xxx
V850E/IA1
Internal flash
V853
V851
V854
V850E/MS1
Memory controller
added
ASSP
V850E/MS2
Compact version
V850E/MA2
V850E/IA2
Compact version
Compact version
V850/SV1
V852
V850/SB1
Ultra-low power
consumption
V850/SA1
3 V, low-power version
V850/SC2
5 V, low-power version
V850/SB2
V850/SF1
V850/SC1
5 V, low-power version with many pins
V850/SC3
5 V, low-power version with
many pins and CAN
Year of development
16
CHAPTER 1 INTRODUCTION
ROM/
Flash
memory
CPU
BIU
DRAM
control
Instruction
queue
Multiplier
32 32 64
PC
Internal
peripheral
I/O
System
registers
Barrel
Shifter
Generalpurpose
registers
32 bits 32
ALU
Internal RAM
ROM
control
Bus
control
Internal bus
Contains
dedicated hardware such as a multiplier (32 32 bits) and a barrel shifter (32 bits/clock)
to execute complicated instructions at high speeds.
Internal ROM .................... <V850E/MS1>
ROM or flash memory mapped from address 00000000H. Can be accessed by the CPU
in one clock during instruction fetch.
<V850E/MS2>
Internal ROM is not provided.
Internal RAM .................... RAM mapped to a space preceding address FFFFEFFFH. Can be accessed by the CPU
in one clock during data access.
Internal peripheral I/O ....... Peripheral I/O area mapped from address FFFFF000H.
BIU ................................... Starts a necessary bus cycle based on a physical address obtained by the CPU.
17
CHAPTER 1 INTRODUCTION
V850E CPU
BSH reg2, reg3
BSW reg2, reg3
CALLT imm6
CLR1 reg2, [reg1]
CMOV cccc, imm5, reg2, reg3
CMOV cccc, reg1, reg2, reg3
CTRET
DISPOSE imm5, list12
DISPOSE imm5, list12 [reg1]
DIV reg1, reg2, reg3
DIVH reg1, reg2, reg3
DIVHU reg1, reg2, reg3
DIVU reg1, reg2, reg3
HSW reg2, reg3
LD.BU disp16 [reg1] , reg2
LD.HU disp16 [reg1] , reg2
MOV imm32, reg1
MUL imm9, reg2, reg3
MUL reg1, reg2, reg3
MULU reg1, reg2, reg3
MULU imm9, reg2, reg3
NOT1 reg2, [reg1]
PREPARE list12, imm5
PREPARE list12, imm5, sp/imm
SASF cccc, reg2
SET1 reg2, [reg1]
SLD.BU disp4 [ep] , reg2
SLD.HU disp5 [ep] , reg2
SWITCH reg1
SXB reg1
SXH reg1
TST1 reg2, [reg1]
ZXB reg1
ZXH reg1
18
Provided
V850 CPU
Not provided
CHAPTER 1 INTRODUCTION
Table 1-1. Differences Between V850E CPU and V850 CPU (2/2)
Item
Instruction format
V850E CPU
V850 CPU
Format IV
Format XI
Provided
Not provided
Format XII
Format XIII
Instruction execution clocks
Program space
64 MB linear
16 MB linear
Lower 26 bits
Lower 24 bits
Provided
Not provided
DBPC, DBPSW
EIPC, EIPSW
Can be set.
Cannot be set.
(misalign access
prohibited)
1 or 2
Pipeline
Note
+ No. of waits
3 + No. of waits
19
The registers of the V850 Series can be classified into two types: program registers that can be used for general
programming, and system registers that can control the execution environment. All the registers consist of 32 bits.
20
r0
Zero register
r1
r2
r3
r4
r5
r6
r7
r8
r9
r10
r11
r12
r13
r14
r15
r16
r17
r18
r19
r20
r21
r22
r23
r24
r25
r26
r27
r28
r29
r30
r31
PC
Program counter
21
Usage
Operation
r0
Zero register
Always holds 0.
r1
Assembler-reserved
register
r2
Address/data variable registers (when the real-time OS does not use r2)
r3
Stack pointer
r4
Global pointer
r5
Text pointer
r6 to r29
r30
Element pointer
r31
Link pointer
PC
Program counter
For detailed descriptions of r1, r3, r4, r5, r31 used by the assembler and C compiler, see the
CA850 (C Compiler Package) Users Manual.
2625
1 0
0
RFU
22
EIPC
Exception/Interrupt PC
EIPSW
Exception/Interrupt PSW
FEPC
Fatal Error PC
FEPSW
ECR
PSW
CTPC
CALLT Caller PC
CTPSW
DBPC
ILGOP Caller PC
DBPSW
CTBP
31
EIPC
RFU
PC
31
EIPSW
8 7
RFU
0
PSW
23
31
FEPC
0
PC
RFU
31
8 7
FEPSW
RFU
0
PSW
16 15
ECR
FECC
Bit Position
31 to 16
0
EICC
Field
FECC
Function
Fatal Error Cause Code
NMI code
15 to 0
EICC
24
8 7 6 5 4 3 2 1 0
N E I S C O
S Z
A
P P D T Y V
RFU
Bit Position
31 to 8
Flag
RFU
Function
Reserved for Future Use
Reserved field (fixed to 0).
NP
NMI Pending
Indicates that NMI processing is in progress. This flag is set when an NMI is
acknowledged.
The NMI request is then masked, and multiple interrupts are disabled.
NP = 0: NMI processing is not in progress
NP = 1: NMI processing is in progress
EP
Exception Pending
Indicates that exception processing is in progress. This flag is set when an exception
occurs. Even when this bit is set, interrupt requests can be acknowledged.
EP = 0: Exception processing is not in progress
EP = 1: Exception processing is in progress
ID
Interrupt Disable
Indicates whether external interrupt request can be acknowledged.
ID = 0: Interrupt can be acknowledged
ID = 1: Interrupt cannot be acknowledged
SATNote
Saturated
Indicates that an overflow has occurred in a saturated operation and the result is
saturated. This is a cumulative flag. Once the result is saturated, the flag is set to 1 and
is not reset to 0 even if the next result is not saturated. To reset this flag, load data to the
PSW.
This flag is neither set nor reset by general arithmetic operation instruction.
SAT = 0: Not saturated
SAT = 1: Saturated
CY
Carry
Indicates whether a carry or borrow occurred as a result of the operation.
CY = 0: Carry or borrow did not occur
CY = 1: Carry or borrow occurred
OVNote
Overflow
Indicates whether an overflow occurred as a result of the operation.
OV = 0: Overflow did not occur
OV = 1: Overflow occurred
SNote
Sign
Indicates whether the result of the operation is negative
S = 0: Result is positive or zero
S = 1: Result is negative
Zero
Indicates whether the result of the operation is zero
Z = 0: Result is not zero
Z = 1: Result is zero
Note In the case of saturation instructions, the SAT, S, and OV flags will be set according to the result of the
operation as shown in the table below. Note that the SAT flag is set to 1 only when the OV flag has been
set due to an overflow condition caused by a saturation instruction.
25
Status of Flag
SAT
OV
7FFFFFFFH
80000000H
Value prior
to operation
retained
Operation result
26 25
0
PC
RFU
8 7
31
CTPSW
RFU
0
PSW
26 25
0
PC
RFU
8 7
31
DBPSW
RFU
0
PSW
26
26 25
RFU
0
Base address
System Register
Operand Specification
LDSR
STSR
EIPC
EIPSW
FEPC
FEPSW
ECR
PSW
16
CTPC
17
CTPSW
18
DBPC
19
DBPSW
20
CTBP
Reserved
6 to 15
21 to 31
Access prohibited
{:
Access enabled
Reserved:
Caution When using the LDSR instruction with the EIPC, FEPC and CTPC registers, only even address
values should be specified. After interrupt processing has ended with a RETI instruction, bit 0 in
the EIPC, FEPC and CTPC registers will be ignored and assumed to be zero when the PC is
restored.
27
Note
The LSB (Least Significant Bit) is bit 0 and the MSB (Most Significant Bit) is bit 7. A byte is specified by its
address A.
7
0
Data
Address
Note
number from 0 to 15. The LSB is bit 0 and the MSB is bit 15. A halfword is specified by its address A (with the
lowest bit fixed to 0 when misalign access is disabled)
15
Note
87
0
Data
A+1
28
Address
Note
from 0 to 31. The LSB is bit 0 and the MSB is bit 31. A word is specified by its address A (with the 2 lowest bits
fixed to 0 when misalign access is disabled)
31
24 23
Note
16 15
87
0
Data
A+3
A+2
A+1
Address
Note
--------------------
Data
A
Note
Bit number
Address
The V850E Series can access any byte boundary whether access is in halfword or word units
when misalign access is enabled.
Refer to 3.3 Data Alignment.
Range
Byte
8 bits
128 to +127
Halfword
16 bits
32768 to +32767
Word
32 bits
2147483648 to +2147483647
29
Data Length
Byte
Range
8 bits
0 to 255
Halfword
16 bits
0 to 65535
Word
32 bits
0 to 4294967295
3.2.3 Bit
The V850 Series can handle 1-bit data that can take a value of 0 (cleared) or 1 (set). Bit manipulation can only be
performed on 1-byte data in the memory space in the following four ways.
Set
Clear
Invert
Test
30
The V850 Series supports a 4 GB linear address space. Both memory and I/O are mapped to this address space
(memory-mapped I/O). The V850 Series outputs 32-bit addresses to the memory and I/O. The maximum address
is 2321.
Byte ordering is little endian. Byte data allocated at each address is defined with bit 0 as LSB and bit 7 as MSB.
In regards to multiple-byte data, the byte with the lowest address value is defined to have the LSB and the byte with
the highest address value is defined to have the MSB.
Data consisting of 2 bytes is called a halfword, and 4-byte data is called a word. In this users manual, data
consisting of 2 or more bytes is illustrated as shown below, with the lower address shown on the right and the higher
address on the left.
7
Byte of address A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Data
A
15
Halfword at address A
87
0
Data
- - - - - - - - - - - - - - - - - - - - - - - - A+1
31
Word at address A
Address
16 15
24 23
A
87
Address
0
Data
- - - - - - - - - A+3
A+2
A+1
Address
31
FFFFEFFFH
Internal RAM
4 GB linear
Internal ROM/
flash memory
00000000H
32
26 25
0 0 0 0 0 0
31
22 21
Sign extension
31
PC
0
disp22
26 25
0 0 0 0 0 0
0
PC
Memory to be manipulated
33
26 25
0 0 0 0 0 0
PC
31
9 8
Sign extension
31
26 25
0 0 0 0 0 0
0
disp9
0
PC
Memory to be manipulated
34
0
reg1
31
26 25
0 0 0 0 0 0
0
PC
Memory to be manipulated
35
An operand that is 5-bit immediate data that specifies the trap vector (00H to 1FH), and is
used by the TRAP instruction.
cccc:
An operand consisting of 4-bit data used by the SETF and CMOV instructions to specify the
condition code.
0
reg1
31
16 15
Sign extension
0
disp16
Memory to be manipulated
36
(b) Type 2
The address of the data memory location to be accessed is determined by adding the value in the 32-bit
element pointer (r30) to the 7- or 8-bit displacement value contained in the instruction. This addressing
mode applies to SLD and SST instructions.
Figure 4-6. Based Addressing (Type 2)
31
0
r30 (element pointer)
31
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
(Zero extension)
0
disp8
or
disp7
Memory to be manipulated
37
instructions.
Figure 4-7. Bit Addressing
31
0
reg1
31
16 15
Sign extension
0
disp16
Memory to be manipulated
38
CHAPTER 5 INSTRUCTIONS
11 10
reg2
opcode
reg1
11 10
reg2
opcode
imm
11 10
disp
7
opcode
4
disp
0
cond
39
CHAPTER 5 INSTRUCTIONS
11 10
reg2
opcode
disp
disp/sub-opcode
A 16-bit instruction format having a 7-bit opcode field, a general-purpose register specification field, and 4-bit
displacement.
15
11 10
reg2
opcode
0
disp
11 10
reg2
6 5
0 31
opcode
17 16
disp
11 10
reg2
5 4
0 31
opcode
reg1
16
imm
11 10
reg2
5 4
opcode
17 16
0 31
reg1
disp
disp/sub-opcode
40
CHAPTER 5 INSTRUCTIONS
11 10
bit #
5 4
0 31
opcode
16
reg1
disp
11 10
reg2
5 4
opcode
0 31
reg1/regID/cond
27 26
sub-opcode
RFU
16
21 20
RFU
13 12 11 10
RFU
5 4
0 31
opcode
27 26
RFU
RFU/sub-opcode
21 20
sub-opcode
16
RFU
RFU/immediate/vector
11 10
reg2
5 4
opcode
0 31
27 26
reg3
reg1
21 20
sub-opcode
18 17 16
RFU
S 0
11 10
reg2
5 4
opcode
0 31
imm (low)
27 26
reg3
23 22
sub-opcode
18 17 16
imm (high)
S 0
41
CHAPTER 5 INSTRUCTIONS
11 10
RFU
6 5
opcode
1 0 31
imm
42
21 20
list
16
reg2/sub-opcode
CHAPTER 5 INSTRUCTIONS
Arithmetic operation instructions ...... Add, subtract, multiply, divide, transfer, or compare data between
registers.
Table 5-2. Arithmetic Operation Instructions
MOV
MOVHI
MOVEA
ADD
ADDI
SUB
SUBR
MUL
MULH
MULHI
MULU
DIV
DIVH
DIVHU
DIVU
CMP
CMOV
SETF
SASF
43
CHAPTER 5 INSTRUCTIONS
Saturated operation instructions ......... Execute saturation addition or subtraction. If the result of the operation
exceeds the maximum positive value (7FFFFFFFH), 7FFFFFFFH is
returned.
80000000H is returned.
Table 5-3. Saturated Operation Instructions
SATADD
SATSUB
SATSUBI
SATSUBR
Logical operation instructions............ These instructions include logical operation instructions, shift instructions
and data type transfer. The shift instructions include arithmetic shift and
logical shift instructions. Operands can be shifted by two or more bit
positions in one clock cycle by the universal barrel shifter.
Table 5-4. Logical Operation Instructions
TST
OR
ORI
AND
ANDI
XOR
XORI
NOT
SHL
SHR
SAR
ZXB
ZXH
SXB
SXH
BSH
BSW
HSW
44
CHAPTER 5 INSTRUCTIONS
Branch instructions ........................ Branch instruction include unconditional branch along with conditional
branch instructions which alter the flow of control, depending on the status
of conditional flags in the PSW. Program control can be transferred to the
address specified by a branch instruction.
Table 5-5. Branch Instructions
JMP
JR
JARL
BGT
BGE
BLT
BLE
BH
BNL
BL
BNH
BE
BNE
BV
BNV
BN
BP
BC
BNC
BZ
BNZ
BR
BSA
45
CHAPTER 5 INSTRUCTIONS
Bit manipulation instructions......... Execute a logical operation to bit data in memory. Only the specified bit is
affected as a result of executing a bit manipulation instruction.
Table 5-6. Bit Manipulation Instructions
SET1
CLR1
NOT1
TST1
Special instructions ........................ These instructions are special in that they do not fall into any of the
categories of instructions described above.
Table 5-7. Special Instructions
LDSR
STSR
SWITCH
PREPARE
DISPOSE
CALLT
CTRET
TRAP
RETI
HALT
DI
EI
NOP
46
CHAPTER 5 INSTRUCTIONS
Mnemonic of instruction
Meaning of instruction
Instruction format
Indicates the description and operand of the instruction. The following symbols are used in the
description of an operand.
Symbol
Meaning
reg1
reg2
reg3
bit#3
imm
-bit immediate
disp
-bit displacement
regID
vector
cccc
ep
list
47
CHAPTER 5 INSTRUCTIONS
Operation
Describes the function of the instruction. The following symbols are used.
Symbol
Meaning
Assignment
GR [ ]
General-purpose register
SR [ ]
System register
zero-extend (n)
Zero-extends n to word
sign-extend (n)
Sign-extends n to word
load-memory (a, b)
store-memory (a, b, c)
load-memory-bit (a, b)
store-memory-bit (a, b, c)
saturated (n)
Format
48
result
Byte
Byte (8 bits)
Half-word
Word
Add
Subtract
||
Bit concatenation
Multiply
Divide
Remainder (Divide)
AND
And
OR
Or
XOR
Exclusive Or
NOT
Logical negate
CHAPTER 5 INSTRUCTIONS
Opcode
Flag
Meaning
1-bit data of code specifying reg1 or regID
cccc
bbb
Indicates the flags that are altered after executing the instruction.
CY
OV
SAT
Instruction
Explanation
Remark
Caution
49
CHAPTER 5 INSTRUCTIONS
Instruction List
Mnemonic
Function
Mnemonic
Load/store instructions
SLD.B
Function
Logical operation instructions
Load Byte
TST
Test
SLD.H
Load Half-word
OR
Or
SLD.W
Load Word
ORI
Or Immediate
SLD.BU
AND
And
SLD.HU
ANDI
And Immediate
LD.B
Load Byte
XOR
Exclusive-Or
LD.H
Load Half-word
XORI
Exclusive-Or Immediate
LD.W
Load Word
NOT
Not
LD.BU
SHL
LD.HU
SHR
SST.B
Store Byte
SAR
SST.H
Store Half-word
ZXB
SST.W
Store Word
ZXH
ST.B
Store Byte
SXB
ST.H
Store Half-word
SXH
ST.W
Store Word
BSH
Arithmetic instructions
BSW
MOV
Move
HSW
MOVHI
MOVEA
JMP
Jump
ADD
Add
JR
Jump Relative
ADDI
Add Immediate
JARL
SUB
Subtract
Bcond
SUBR
Subtract Reverse
Branch instructions
MUL
Multiply Word
SET1
Set Bit
MULH
Multiply Half-word
CLR1
Clear Bit
MULHI
NOT1
Not Bit
MULU
TST1
Test Bit
DIV
Divide Word
DIVH
Divide Half-word
LDSR
DIVHU
STSR
DIVU
SWITCH
CMP
Compare
PREPARE
CMOV
Conditional Move
DISPOSE
SETF
CALLT
SASF
Special instructions
CTRET
Saturate instructions
TRAP
Trap
SATADD
Saturated Add
RETI
SATSUB
Saturated Subtract
HALT
Halt
SATSUBI
DI
Disable Interrupt
SATSUBR
EI
Enable Interrupt
NOP
No Operation
50
CHAPTER 5 INSTRUCTIONS
ADD
Add
Instruction format
Operation
Format
(1) Format I
(2) Format II
Opcode
15
(1)
rrrrr001110RRRRR
15
(2)
Flag
Instruction
rrrrr010010iiiii
CY
OV
SAT
Explanation
(1) Adds the word data of general-purpose register reg1 to the word data of general-purpose
register reg2, and stores the result in general-purpose register reg2. The data of generalpurpose register reg1 is not affected.
(2) Adds 5-bit immediate data, sign-extended to word length, to the word data of generalpurpose register reg2, and stores the result in general-purpose register reg2.
51
CHAPTER 5 INSTRUCTIONS
ADDI
Add Immediate
Instruction format
Operation
Format
Format VI
Opcode
15
rrrrr110000RRRRR
Flag
31
16
iiiiiiiiiiiiiiii
CY
OV
SAT
Instruction
Explanation
Adds 16-bit immediate data, sign-extended to word length, to the word data of general-purpose
register reg1, and stores the result in general-purpose register reg2. The data of generalpurpose register reg1 is not affected.
52
CHAPTER 5 INSTRUCTIONS
AND
And
Instruction format
Operation
Format
Format I
Opcode
15
rrrrr001010RRRRR
Flag
CY
OV
SAT
Instruction
AND And
Explanation
ANDs the word data of general-purpose register reg2 with the word data of general-purpose
register reg1, and stores the result in general-purpose register reg2. The data of generalpurpose register reg1 is not affected.
53
CHAPTER 5 INSTRUCTIONS
ANDI
And Immediate
Instruction format
Operation
Format
Format VI
Opcode
15
rrrrr110110RRRRR
Flag
CY
OV
31
16
iiiiiiiiiiiiiiii
SAT
Instruction
Explanation
ANDs the word data of general-purpose register reg1 with the value of the 16-bit immediate
data, zero-extended to word length, and stores the result in general-purpose register reg2.
The data of general-purpose register reg1 is not affected.
54
CHAPTER 5 INSTRUCTIONS
Bcond
Branch on Condition Code
Instruction format
Bcond disp9
Operation
Format
Format III
Opcode
15
ddddd1011dddcccc
dddddddd is the higher 8 bits of disp9.
Flag
CY
OV
SAT
Instruction
Explanation
Tests the condition flag specified by the instruction. Branches if the specified condition is
satisfied; otherwise, executes the next instruction. The branch destination PC holds the sum
of the current PC value and 9-bit displacement, which is 8-bit immediate shifted 1 bit and signextended to word length.
Remark
Bit 0 of the 9-bit displacement is masked to 0. The current PC value used for calculation is the
address of the first byte of this instruction. If the displacement value is 0, therefore, the branch
destination is this instruction itself.
55
CHAPTER 5 INSTRUCTIONS
Instruction
Condition Code
(cccc)
Branch Condition
Signed
BGT
1111
( (S xor OV) or Z) = 0
integer
BGE
1110
(S xor OV) = 0
BLT
0110
(S xor OV) = 1
BLE
0111
( (S xor OV) or Z) = 1
Unsigned
BH
1011
(CY or Z) = 0
integer
BNL
1001
CY = 0
Common
Others
Caution
BL
0001
CY = 1
BNH
0011
(CY or Z) = 1
BE
0010
Z=1
Equal
BNE
1010
Z=0
Not equal
BV
0000
OV = 1
Overflow
BNV
1000
OV = 0
No overflow
BN
0100
S=1
Negative
BP
1100
S=0
Positive
BC
0001
CY = 1
Carry
BNC
1001
CY = 0
No carry
BZ
0010
Z=1
Zero
BNZ
1010
Z=0
Not zero
BR
0101
Always (unconditional)
BSA
1101
SAT = 1
Saturated
If executing a conditional branch instruction of a signed integer (BGT, BGE, BLT, or BLE)
when the SAT flag is set to 1 as a result of executing a saturated operation instruction, the
branch condition loses its meaning. In ordinary arithmetic operations, if an overflow condition
occurs, the S flag is inverted (0 1 or 1 0). This is because the result is a negative value if
it exceeds the maximum positive value and it is a positive value if it exceeds the maximum
negative value.
However, when a saturated operation instruction is executed, and if the result exceeds the
maximum positive value, the result is saturated with a positive value; if the result exceeds the
maximum negative value, the result is saturated with a negative value. Unlike the ordinary
operation, therefore, the S flag is not inverted even if an overflow occurs.
Hence, the S flag of the PSW is affected differently when the instruction is a saturate
operation, as opposed to an ordinary arithmetic operation. A branch condition which is an
XOR of the S and OV flags will therefore have no meaning.
56
CHAPTER 5 INSTRUCTIONS
BSH
Byte Swap Half-word
Instruction format
Operation
Format
Format XII
Opcode
15
rrrrr11111100000
Flag
31
16
wwwww01101000010
CY
OV
SAT
Instruction
Explanation
Endian translation.
57
CHAPTER 5 INSTRUCTIONS
BSW
Byte Swap Word
Instruction format
Operation
Format
Format XII
Opcode
15
rrrrr11111100000
Flag
16
CY
OV
SAT
Instruction
Explanation
Endian translation.
58
31
wwwww01101000000
CHAPTER 5 INSTRUCTIONS
CALLT
Call with Table Look Up
Instruction format
CALLT imm6
Operation
Format
Format II
Opcode
15
0000001000iiiiii
Flag
CY
OV
SAT
Instruction
Explanation
59
CHAPTER 5 INSTRUCTIONS
CLR1
Clear Bit
Instruction format
Operation
Format
Opcode
15
(1)
10bbb111110RRRRR
15
(2)
Flag
CY
OV
16
dddddddddddddddd
0
rrrrr111111RRRRR
31
31
16
0000000011100100
SAT
Instruction
Explanation
(1) Adds the data of general-purpose register reg1 to the 16-bit displacement, sign-extended
to word length, to generate a 32-bit address. Then reads the byte data referenced by the
generated data, clears the bit specified by the bit number of bit 3, and writes the data to
the former address.
(2) Reads the data of general-purpose register reg1 to generate a 32-bit address. Then reads
the byte data referenced by the generated address, clears the bit specified by the data of
the lower 3 bits of reg2, and writes the data to the former address.
Remark
The Z flag of the PSW indicates whether the specified bit was a 0 or 1 before this instruction
was executed. It does not indicate the contents of the specified bit after this instruction has
been executed.
60
CHAPTER 5 INSTRUCTIONS
CMOV
Conditional Move
Instruction format
Operation
Format
(1) Format XI
(2) Format XII
Opcode
15
(1)
(2)
Flag
31
16
rrrrr111111RRRRR
wwwww011001cccc0
15
31
rrrrr111111iiiii
CY
OV
SAT
16
wwwww011000cccc0
Instruction
Explanation
(1) The data of general-purpose register reg1 is transferred to general-purpose register reg3
if the condition specified by condition code cccc is satisfied; otherwise, the data of
general-purpose register reg2 is transferred.
61
CHAPTER 5 INSTRUCTIONS
CMP
Compare
Instruction format
Operation
Format
(1) Format I
(2) Format II
Opcode
15
(1)
rrrrr001111RRRRR
15
(2)
Flag
Instruction
rrrrr010011iiiii
CY
OV
SAT
Explanation
(1) Compares the word data of general-purpose register reg2 with the word data of generalpurpose register reg1, and indicates the result by using the condition flags. To compare,
the contents of general-purpose register reg1 are subtracted from the word data of
general-purpose register reg2. The data of general-purpose registers reg1 and reg2 are
not affected.
(2) Compares the word data of general-purpose register reg2 with 5-bit immediate data, signextended to word length, and indicates the result by using the condition flags.
To
compare, the contents of the sign-extended immediate data are subtracted from the word
data of general-purpose register reg2. The data of general-purpose register reg2 is not
affected.
62
CHAPTER 5 INSTRUCTIONS
CTRET
Return from CALLT
Instruction format
CTRET
Operation
PC
CTPC
PSW CTPSW
Format
Format X
Opcode
15
0000011111100000
Flag
31
16
0000000101000100
CY
OV
SAT
Instruction
Explanation
This instruction restores the restore PC and PSW from the appropriate system register and
returns from a routine called by CALLT. The operations of this instruction are as follows.
(1) The restore PC and PSW are read from CTPC and CTPSW.
(2) Once the PC and PSW are restored in the return values, control is transferred to the
return address.
63
CHAPTER 5 INSTRUCTIONS
DI
Disable Interrupt
Instruction format
DI
Operation
Format
Format X
Opcode
15
0000011111100000
Flag
CY
OV
SAT
ID
31
16
0000000101100000
Instruction
DI Disable Interrupt
Explanation
Sets the ID flag of the PSW to 1 to disable the acknowledgement of maskable interrupts during
execution of this instruction.
Remark
Interrupts are not sampled during execution of this instruction. The ID flag actually becomes
valid at the start of the next instruction.
instruction execution, interrupts are immediately disabled. Non-maskable interrupts are not
affected by this instruction.
64
CHAPTER 5 INSTRUCTIONS
DISPOSE
Function Dispose
Instruction format
Operation
Format
Format XIII
Opcode
15
(1)
0000011001iiiiiL
15
(2)
31
16
LLLLLLLLLLL00000
0
0000011001iiiiiL
31
16
LLLLLLLLLLLRRRRR
0 31
CY
OV
SAT
28 27 24 23 21
16
Instruction
Explanation
(1) Adds the data of 5-bit immediate imm5, logically shifted left by 2 and zero-extended to
word length, to sp. Then pops the (loads data from the address specified by sp and adds
4 to sp) general-purpose registers listed in list12. Bit 0 of the address is masked by 0.
(2) Adds the data of 5-bit immediate imm5, logically shifted left by 2 and zero-extended to
word length, to sp. Then pops (loads data from the address specified by sp and adds 4 to
sp) the general-purpose registers listed in list12, and transfers control to the address
specified by general-purpose register reg1. Bit 0 of the address is masked by 0.
65
CHAPTER 5 INSTRUCTIONS
Remark
General-purpose registers in list12 are loaded in the downward direction. (r31, r30, ... r20)
The 5-bit immediate imm5 is used to restore a stack frame for auto variables and temporary
data.
The lower 2 bits of the address specified by sp are always masked by 0 even if misalign
access is enabled.
If an interrupt occurs while this instruction is being executed, execution is aborted, and the
interrupt is processed. Upon returning from the interrupt, execution is restarted. Also, sp will
retain its original value prior to the start of execution.
66
CHAPTER 5 INSTRUCTIONS
DIV
Divide Word
Instruction format
Operation
Format
Format XI
Opcode
15
rrrrr111111RRRRR
Flag
31
16
wwwww01011000000
CY
OV
SAT
Instruction
Explanation
Divides the word data of general-purpose register reg2 by the word data of general-purpose
register reg1, and stores the quotient in general-purpose register reg2, and the remainder in
general-purpose register reg3. If the data is divided by 0, an overflow occurs, and the quotient
is undefined. The data of general-purpose register reg1 is not affected.
Remark
An overflow occurs when the maximum negative value (80000000H) is divided by 1 (in which
case the quotient is 80000000H) and when data is divided by 0 (in which case the quotient is
undefined).
If an interrupt occurs while this instruction is being executed, division is aborted, and the
interrupt is processed. Upon returning from the interrupt, the division is restarted from the
beginning, with the return address being the address of this instruction. Also, general-purpose
registers reg1 and reg2 will retain their original values prior to the start of execution.
If the address of reg2 is the same as the address of reg3, the remainder is stored in reg2
(=reg3).
67
CHAPTER 5 INSTRUCTIONS
DIVH
Divide Half-word
Instruction format
Operation
Format
(1) Format I
(2) Format XI
Opcode
15
(1)
rrrrr000010RRRRR
(2)
rrrrr111111RRRRR
15
Flag
31
16
wwwww01010000000
CY
OV
SAT
Instruction
Explanation
(1) Divides the word data of general-purpose register reg2 by the lower halfword data of
general-purpose register reg1, and stores the quotient in general-purpose register reg2. If
the data is divided by 0, an overflow occurs, and the quotient is undefined.
The data of general-purpose register reg1 is not affected.
(2) Divides the word data of general-purpose register reg2 by the lower halfword data of
general-purpose register reg1, and stores the quotient in general-purpose register reg2,
and the remainder in general-purpose register reg3.
overflow occurs, and the quotient is undefined. The data of general-purpose register reg1
is not affected.
Remark
68
CHAPTER 5 INSTRUCTIONS
execution.
Do not specify r0 as the destination register reg2.
The higher 16 bits of general-purpose register reg1 are ignored when division is executed.
(2) An overflow occurs when the maximum negative value (80000000H) is divided by 1 (in
which case the quotient is 80000000H) and when data is divided by 0 (in which case the
quotient is undefined).
If an interrupt occurs while this instruction is being executed, division is aborted, and the
interrupt is processed. Upon returning from the interrupt, the division is restarted from the
beginning, with the return address being the address of this instruction. Also, generalpurpose registers reg1 and reg2 will retain their original values prior to the start of
execution.
The higher 16 bits of general-purpose register reg1 are ignored when division is executed.
If the address of reg2 is the same as the address of reg3, the remainder is stored in reg2
(=reg3).
69
CHAPTER 5 INSTRUCTIONS
DIVHU
Divide Half-word Unsigned
Instruction format
Operation
Format
Format XI
Opcode
15
rrrrr111111RRRRR
Flag
31
16
wwwww01010000010
CY
OV
SAT
Instruction
Explanation
Divides the word data of general-purpose register reg2 by the lower halfword data of generalpurpose register reg1, and stores the quotient in general-purpose register reg2, and the
remainder in general-purpose register reg3. If the data is divided by 0, an overflow occurs,
and the quotient is undefined. The data of general-purpose register reg1 is not affected.
Remark
An overflow occurs when data is divided by 0 (in which case the quotient is undefined).
If an interrupt occurs while this instruction is being executed, division is aborted, and the
interrupt is processed. Upon returning from the interrupt, the division is restarted from the
beginning, with the return address being the address of this instruction. Also, general-purpose
registers reg1 and reg2 will retain their original values prior to the start of execution.
If the address of reg2 is the same as the address of reg3, the remainder is stored in reg2
(=reg3).
70
CHAPTER 5 INSTRUCTIONS
DIVU
Divide Word Unsigned
Instruction format
Operation
Format
Format XI
Opcode
15
rrrrr111111RRRRR
Flag
31
16
wwwww01011000010
CY
OV
SAT
Instruction
Explanation
Divides the word data of general-purpose register reg2 by the word data of general-purpose
register reg1, and stores the quotient in general-purpose register reg2, and the remainder to
general-purpose register reg3. If the data is divided by 0, overflow occurs, and the quotient is
undefined. The data of general-purpose register reg1 is not affected.
Remark
An overflow occurs when data is divided by 0 (in which case the quotient is undefined).
If an interrupt occurs while this instruction is being executed, division is aborted, and the
interrupt is processed. Upon returning from the interrupt, the division is restarted from the
beginning, with the return address being the address of this instruction. Also, general-purpose
registers reg1 and reg2 will retain their original values prior to the start of execution.
If the address of reg2 is the same as the address of reg3, the remainder is stored in reg2
(=reg3).
71
CHAPTER 5 INSTRUCTIONS
EI
Enable Interrupt
Instruction format
EI
Operation
Format
Format X
Opcode
15
1000011111100000
Flag
CY
OV
SAT
ID
31
16
0000000101100000
Instruction
EI Enable Interrupt
Explanation
Resets the ID flag of the PSW to 0 and enables the acknowledgement of maskable interrupts
beginning at the next instruction.
Remark
72
CHAPTER 5 INSTRUCTIONS
HALT
Halt
Instruction format
HALT
Operation.
Halts
Format
Format X
Opcode
15
0000011111100000
Flag
CY
OV
SAT
31
16
0000000100100000
Instruction
HALT Halt
Explanation
Stops the operating clock of the CPU and places the CPU in the HALT mode.
Remark
73
CHAPTER 5 INSTRUCTIONS
HSW
Half-word Swap Word
Instruction format
Operation
Format
Format XII
Opcode
15
rrrrr11111100000
Flag
31
CY
OV
SAT
Instruction
Explanation
Endian translation.
74
16
wwwww01101000100
CHAPTER 5 INSTRUCTIONS
JARL
Jump and Register Link
Instruction format
Operation
GR [reg2] PC + 4
PC PC + sign-extend (disp22)
Format
Format V
Opcode
15
rrrrr11110dddddd
31
16
ddddddddddddddd0
CY
OV
SAT
Instruction
Explanation
Saves the current PC value plus 4 to general-purpose register reg2, adds the current PC value
and 22-bit displacement, sign-extended to word length, and transfers control to the PC. Bit 0
of the 22-bit displacement is masked by 0.
Remark
The current PC value used for calculation is the address of the first byte of this instruction. If
the displacement value is 0, the branch destination is this instruction itself.
This instruction is equivalent to a call subroutine instruction, and stores the restore PC address
in general-purpose register reg2. The JMP instruction, which is equivalent to a subroutinereturn instruction, can be used to specify the general-purpose register storing the restore PC
as general-purpose register reg1.
75
CHAPTER 5 INSTRUCTIONS
JMP
Jump Register
Instruction format
JMP [reg1]
Operation
PC GR [reg1]
Format
Format I
Opcode
15
00000000011RRRRR
Flag
CY
OV
SAT
Instruction
Explanation
Bit 0 of the
address is masked by 0.
Remark
When using this instruction as the subroutine-return instruction, specify the restore PC using
general-purpose register reg1. When using the JARL instruction, which is equivalent to the
subroutine-call instruction, store the restore PC address in general-purpose register reg2.
76
CHAPTER 5 INSTRUCTIONS
JR
Jump Relative
Instruction format
JR disp22
Operation
PC PC + sign-extend (disp22)
Format
Format V
Opcode
15
0000011110dddddd
31
16
ddddddddddddddd0
CY
OV
SAT
Instruction
JR Jump Relative
Explanation
Adds the 22-bit displacement, sign-extended to word length, to the current PC value and
stores the value in the PC, and then transfers control to the PC.
displacement is masked by 0.
Remark
The current PC value used for the calculation is the address of the first byte of this instruction
itself. Therefore, if the displacement value is 0, the jump destination is this instruction.
77
CHAPTER 5 INSTRUCTIONS
LD
Load
Instruction format
Operation
Format
Format VII
Opcode
15
(1)
rrrrr111000RRRRR
15
(2)
31
16
dddddddddddddddd
0
rrrrr111001RRRRR
31
16
ddddddddddddddd0
rrrrr111001RRRRR
31
16
ddddddddddddddd1
rrrrr11110bRRRRR
31
16
ddddddddddddddd1
78
CHAPTER 5 INSTRUCTIONS
15
(5)
rrrrr111111RRRRR
31
16
ddddddddddddddd1
Flag
Instruction
CY
OV
SAT
Explanation
(1) Adds the data of general-purpose register reg1 to a 16-bit displacement sign-extended to
word length to generate a 32-bit address. Byte data is read from the generated address,
sign-extended to word length, and stored in general-purpose register reg2.
(2) Adds the data of general-purpose register reg1 to a 16-bit displacement sign-extended to
word length to generate a 32-bit address. Halfword data is read from this 32-bit address
with its bit 0 masked by 0, sign-extended to word length, and stored in general-purpose
register reg2.
(3) Adds the data of general-purpose register reg1 to a 16-bit displacement sign-extended to
word length to generate a 32-bit address. Word data is read from this 32-bit address with
bits 0 and 1 masked by 0, and stored in general-purpose register reg2.
(4) Adds the data of general-purpose register reg1 to a 16-bit displacement sign-extended to
word length to generate a 32-bit address. Byte data is read from the generated address,
zero-extended to word length, and stored in general-purpose register reg2.
Do not specify r0 as the destination register reg2.
(5) Adds the data of general-purpose register reg1 to a 16-bit displacement sign-extended to
word length to generate a 32-bit address. Halfword data is read from this 32-bit address
with its bit 0 masked by 0, zero-extended to word length, and stored in general-purpose
register reg2.
Do not specify r0 as the destination register reg2.
Caution
The result of adding the data of general-purpose register reg1 and the 16-bit displacement
sign-extended to word length is as follows.
Lower bits are not masked and address is generated.
79
CHAPTER 5 INSTRUCTIONS
LDSR
Load to System Register
Instruction format
Operation
SR [regID] GR [reg2]
Format
Format IX
Opcode
15
rrrrr111111RRRRR
Remark
31
16
0000000000100000
The fields used to define reg1 and reg2 are swapped in this instruction. Normally,
"RRR" is used for reg1 and is the source operand while rrr signifies reg2 and is
the destination operand. In this instruction, RRR is still the source operand, but
is represented by reg2, while rrr is the special register destination, as labeled
below.
rrrrr: regID specification
RRRRR: reg2 specification
Flag
CY
OV
SAT
Instruction
Explanation
Loads the word data of general-purpose register reg2 to a system register specified by the
system register number (regID). The data of general-purpose register reg2 is not affected.
Remark
If the system register number (regID) is equal to 5 (PSW register), the values of the
corresponding bits of the PSW are set according to the contents of reg2. This only affects the
flag bits, and the reserved bits remain 0. Also, interrupts are not sampled when the PSW is
being written with a new value. If the ID flag is enabled with this instruction, interrupt disabling
begins at the start of execution, even though the ID flag does not become valid until the
beginning of the next instruction.
Caution
The system register number regID is a number which identifies a system register. Accessing
system registers which are reserved or write-prohibited is prohibited and will lead to undefined
results.
80
CHAPTER 5 INSTRUCTIONS
MOV
Move
Instruction format
Operation
Format
(1) Format I
(2) Format II
(3) Format VI
Opcode
15
(1)
rrrrr000000RRRRR
15
(2)
rrrrr010000iiiii
15
(3)
00000110001RRRRR
31
16
iiiiiiiiiiiiiiii
47
32
IIIIIIIIIIIIIIII
Instruction
CY
OV
SAT
Explanation
(1) Transfers the word data of general-purpose register reg1 to general-purpose register reg2.
The data of general-purpose register reg1 is not affected.
(2) Transfers the value of a 5-bit immediate data, sign-extended to word length, to generalpurpose register reg2.
Do not specify r0 as the destination register reg2.
(3) Transfers the value of a 32-bit immediate data to general-purpose register reg1.
81
CHAPTER 5 INSTRUCTIONS
MOVEA
Move Effective Address
Instruction format
Operation
Format
Format VI
Opcode
15
rrrrr110001RRRRR
Flag
CY
OV
SAT
31
16
iiiiiiiiiiiiiiii
Instruction
Explanation
Adds the 16-bit immediate data, sign-extended to word length, to the word data of generalpurpose register reg1, and stores the result in general-purpose register reg2. The data of
general-purpose register reg1 is not affected. The flags are not affected by the addition.
Do not specify r0 as the destination register reg2.
Remark
This instruction calculates a 32-bit address and stores the result without affecting the PSW
flags.
82
CHAPTER 5 INSTRUCTIONS
MOVHI
Move High Half-word
Instruction format
Operation
Format
Format VI
Opcode
15
rrrrr110010RRRRR
Flag
CY
OV
SAT
31
16
iiiiiiiiiiiiiiii
Instruction
Explanation
Adds a word value, whose higher 16 bits are specified by the 16-bit immediate data and lower
16 bits are 0, to the word data of general-purpose register reg1 and stores the result in
general-purpose register reg2. The data of general-purpose register reg1 is not affected. The
flags are not affected by the addition.
Do not specify r0 as the destination register reg2.
Remark
83
CHAPTER 5 INSTRUCTIONS
MUL
Multiply Word
Instruction format
Operation
Format
(1) Format XI
(2) Format XII
Opcode
15
(1)
rrrrr111111RRRRR
15
(2)
16
wwwww01000100000
0
rrrrr111111iiiii
31
31
16
wwwww01001IIII00
Instruction
CY
OV
SAT
Explanation
(1) Multiplies the word data of general-purpose register reg2 by the word data of generalpurpose register reg1, and stores the result in general-purpose register reg2 and reg3 as
double word data. The data of general-purpose register reg1 is not affected.
(2) Multiplies the word data of general-purpose register reg2 by a 9-bit immediate data, signextended to word length, and stores the result in general-purpose registers reg2 and reg3.
Remark
The higher 32 bits of the result are stored in general-purpose register reg3.
If the address of reg2 is the same as the address of reg3, the higher 32 bits of the result are
stored in reg2 (=reg3)
84
CHAPTER 5 INSTRUCTIONS
MULH
Multiply Half-word
Instruction format
Operation
Format
(1) Format I
(2) Format II
Opcode
15
(1)
rrrrr000111RRRRR
15
(2)
Flag
Instruction
rrrrr010111iiiii
CY
OV
SAT
Explanation
(1) Multiplies the lower halfword data of general-purpose register reg2 by the halfword data of
general-purpose register reg1, and stores the result in general-purpose register reg2 as
word data. The data of general-purpose register reg1 is not affected.
Do not specify r0 as the destination register reg2.
(2) Multiplies the lower halfword data of general-purpose register reg2 by a 5-bit immediate
data, sign-extended to halfword length, and stores the result in general-purpose register
reg2.
Do not specify r0 as the destination register reg2.
Remark
The higher 16 bits of general-purpose registers reg1 and reg2 are ignored in this operation.
85
CHAPTER 5 INSTRUCTIONS
MULHI
Multiply Half-word Immediate
Instruction format
Operation
Format
Format VI
Opcode
15
rrrrr110111RRRRR
Flag
CY
OV
SAT
31
16
iiiiiiiiiiiiiiii
Instruction
Explanation
Multiplies the lower halfword data of general-purpose register reg1 by the 16-bit immediate
data, and stores the result in general-purpose register reg2. The data of general-purpose
register reg1 is not affected.
Do not specify r0 as the destination register reg2.
Remark
86
The higher 16 bits of general-purpose register reg1 are ignored in this operation.
CHAPTER 5 INSTRUCTIONS
MULU
Multiply Word Unsigned
Instruction format
Operation
Format
(1) Format XI
(2) Format XII
Opcode
15
(1)
rrrrr111111RRRRR
15
(2)
16
wwwww01000100010
0
rrrrr111111iiiii
31
31
16
wwwww01001IIII10
Instruction
CY
OV
SAT
Explanation
(1) Multiplies the word data of general-purpose register reg2 by the word data of generalpurpose register reg1, and stores the result in general-purpose registers reg2 and reg3 as
double word data. The data of general-purpose register reg1 is not affected.
(2) Multiplies the word data of general-purpose register reg2 by a 9-bit immediate data, zeroextended to word length, and stores the result in general-purpose registers reg2 and reg3.
Remark
The higher 32 bits of the result are stored in general-purpose register reg3.
If the address of reg2 is the same as the address of reg3, the higher 32 bits of the result are
stored in reg2 (=reg3).
87
CHAPTER 5 INSTRUCTIONS
NOP
No Operation
Instruction format
NOP
Operation
Format
Format I
Opcode
15
0000000000000000
Flag
CY
OV
SAT
Instruction
NOP No Operation
Explanation
Remark
The contents of the PC are incremented by two. The opcode is the same as that of MOV r0,
r0.
88
CHAPTER 5 INSTRUCTIONS
NOT
Not
Instruction format
Operation
Format
Format I
Opcode
15
rrrrr000001RRRRR
Flag
CY
OV
SAT
Instruction
NOT Not
Explanation
Logically negates (takes the 1s complement of) the word data of general-purpose register
reg1, and stores the result in general-purpose register reg2. The data of general-purpose
register reg1 is not affected.
89
CHAPTER 5 INSTRUCTIONS
NOT1
Not Bit
Instruction format
Operation
Format
Opcode
15
(1)
01bbb111110RRRRR
15
(2)
Flag
CY
OV
16
dddddddddddddddd
0
rrrrr111111RRRRR
31
31
16
0000000011100010
SAT
Instruction
Explanation
(1) Adds the data of general-purpose register reg1 to a 16-bit displacement, sign-extended to
word length, to generate a 32-bit address. Then reads the byte data referenced by the
generated address, inverts the bit specified by the 3-bit field bbb, and writes the data to
the previous address.
(2) Reads the data of general-purpose register reg1 to generate a 32-bit address. Then reads
the byte data referenced by the generated address, inverts the bit specified by the data of
the lower 3 bits of reg2, and writes the data to the previous address.
Remark
The Z flag of the PSW indicates whether the specified bit was 0 or 1 before this instruction was
executed, and does not indicate the contents of the specified bit after this instruction has been
executed.
90
CHAPTER 5 INSTRUCTIONS
OR
Or
Instruction format
OR reg1, reg2
Operation
Format
Format I
Opcode
15
rrrrr001000RRRRR
Flag
CY
OV
SAT
Instruction
OR Or
Explanation
ORs the word data of general-purpose register reg2 with the word data of general-purpose
register reg1, and stores the result in general-purpose register reg2. The data of generalpurpose register reg1 is not affected.
91
CHAPTER 5 INSTRUCTIONS
ORI
Or Immediate
Instruction format
Operation
Format
Format VI
Opcode
15
rrrrr110100RRRRR
Flag
CY
OV
31
16
iiiiiiiiiiiiiiii
SAT
Instruction
OR Or immediate (16-bit)
Explanation
ORs the word data of general-purpose register reg1 with the value of the 16-bit immediate
data, zero-extended to word length, and stores the result in general-purpose register reg2.
The data of general-purpose register reg1 is not affected.
92
CHAPTER 5 INSTRUCTIONS
PREPARE
Function Prepare
Instruction format
Format
Format XIII
Opcode
15
(1)
0000011110iiiiiL
15
(2)
31
16
LLLLLLLLLLL00001
0
0000011110iiiiiL
31
16
LLLLLLLLLLLff011
Optional(47-32 or 63-32)
imm16 / imm32
In the case of 32-bit immediate data (imm32), bits 47 to 32 are the lower 16 bits of imm32, bits
63 to 48 are the higher 16 bits of imm32.
ff = 00: Load sp to ep
01: Load 16-bit immediate data (bit 47 to 32), sign-extended, to ep
10: Load 16-bit immediate data (bit 47 to 32), logically shifted left by 16, to ep
11: Load 32-bit immediate data (bit 63 to 32) to ep
Bit assignment of list12 is below
15
0 31
CY
OV
SAT
28 27 24 23 21
16
Instruction
Explanation
(1) Pushes (subtracts 4 from sp and stores the data in that address) the general-purpose
registers listed in list12. Then subtracts the data of 5-bit immediate imm5, logically shifted
left by 2 and zero-extended to word length, from sp.
93
CHAPTER 5 INSTRUCTIONS
(2) Pushes (subtracts 4 from sp and stores the data in that address) the general-purpose
registers listed in list12. Then subtracts the data of 5-bit immediate imm5, logically shifted
left by 2 and zero-extended to word length, from sp.
Next, load the data specified by 3rd operand to ep.
Remark
The general-purpose registers in list12 are stored in the upward direction. (r20, r21, ... r31)
The 5-bit immediate imm5 is used to make a stack frame for auto variables and temporary
data.
The lower 2 bits of the address specified by sp are always masked by 0 even if misalign
access is enabled.
If an interrupt occurs while this instruction is being executed, execution is aborted, and the
interrupt is processed. Upon returning from the interrupt, execution is restarted. Also, sp and
ep will retain their original values prior to the start of execution.
94
CHAPTER 5 INSTRUCTIONS
RETI
Return from Trap or Interrupt
Instruction format
RETI
Operation
if PSW.EP = 1
then PC
EIPC
PSW EIPSW
else if PSW.NP = 1
then PC
FEPC
PSW FEPSW
else PC
EIPC
PSW EIPSW
Format
Format X
Opcode
15
0000011111100000
Flag
31
16
0000000101000000
CY
OV
SAT
Instruction
Explanation
This instruction reads the restore PC and PSW from the appropriate system register, and
operation returns from an exception or interrupt routine. The operations of this instruction are
as follows.
(1) If the EP flag of the PSW is 1, the restore PC and PSW are read from EIPC and EIPSW,
regardless of the status of the NP flag of the PSW.
If the EP flag of the PSW is 0 and the NP flag of the PSW is 1, the restore PC and PSW
are read from FEPC and FEPSW.
If the EP flag of the PSW is 0 and the NP flag of the PSW is 0, the restore PC and PSW
are read from EIPC and EIPSW.
(2) Once the restore PC and PSW values are set to the PC and PSW, the operation returns to
the address immediately before the trap or interrupt occurred.
95
CHAPTER 5 INSTRUCTIONS
Caution
When returning from an NMI or exception routine using the RETI instruction, the PSW.NP and
PSW.EP flags must be set accordingly to restore the PC and PSW:
When returning from non-maskable interrupt routine using the RETI instruction:
PSW.NP = 1 and PSW.EP = 0
When returning from an exception routine using the RETI instruction:
PSW.EP = 1
Use the LDSR instruction for setting the flags.
Interrupts are not acknowledged in the latter half of the ID stage during LDSR execution
because of the operation of the interrupt controller.
96
CHAPTER 5 INSTRUCTIONS
SAR
Shift Arithmetic Right
Instruction format
Operation
Format
(1) Format IX
(2) Format II
Opcode
15
(1)
rrrrr111111RRRRR
15
(2)
Flag
CY
31
16
0000000010100000
rrrrr010101iiiii
1 if the bit shifted out last is 1; otherwise, 0.
However, if the number of shifts is 0, the result is 0.
Instruction
OV
SAT
Explanation
(1) Arithmetically shifts the word data of general-purpose register reg2 to the right by n
positions, where n is a value from 0 to +31, specified by the lower 5 bits of generalpurpose register reg1 (after the shift, the MSB prior to shift execution is copied and set as
the new MSB value), and then writes the result in general-purpose register reg2. If the
number of shifts is 0, general-purpose register reg2 retains the same value prior to
instruction execution. The data of general-purpose register reg1 is not affected.
(2) Arithmetically shifts the word data of general-purpose register reg2 to the right by n
positions, where n is a value from 0 to +31, specified by the 5-bit immediate data, zeroextended to word length (after the shift, the MSB prior to shift execution is copied and set
as the new MSB value), and then writes the result in general-purpose register reg2. If the
number of shifts is 0, general-purpose register reg2 retains the same value prior to
instruction execution.
97
CHAPTER 5 INSTRUCTIONS
SASF
Shift and Set Flag Condition
Instruction format
Operation
Format
Opcode
Format IX
15
rrrrr1111110cccc
Flag
CY
OV
SAT
31
16
0000001000000000
Instruction
Explanation
General-purpose register reg2 is logically shifted left by 1, and its LSB is set to 1 if the
condition specified by condition code cccc is satisfied; otherwise, the LSB is set to 0. One of
the codes shown in Table 5-9 Condition Codes should be specified as the condition code
cccc.
Remark
98
CHAPTER 5 INSTRUCTIONS
SATADD
Saturated Add
Instruction format
Operation
Format
(1) Format I
(2) Format II
Opcode
15
(1)
rrrrr000110RRRRR
(2)
rrrrr010001iiiii
15
Flag
Instruction
CY
OV
SAT
Explanation
(1) Adds the word data of general-purpose register reg1 to the word data of general-purpose
register reg2, and stores the result in general-purpose register reg2. However, if the
result exceeds the maximum positive value 7FFFFFFFH, 7FFFFFFFH is stored in reg2; if
the result exceeds the maximum negative value 80000000H, 80000000H is stored in reg2.
The SAT flag is set to 1. The data of general-purpose register reg1 is not affected.
Do not specify r0 as the destination register reg2.
(2) Adds a 5-bit immediate data, sign-extended to word length, to the word data of generalpurpose register reg2, and stores the result in general-purpose register reg2. However, if
the result exceeds the maximum positive value 7FFFFFFFH, 7FFFFFFFH is stored in
reg2; if the result exceeds the maximum negative value 80000000H, 80000000H is stored
in reg2. The SAT flag is set to 1.
Do not specify r0 as the destination register reg2.
Remark
The SAT flag is a cumulative flag. Once the result of the saturated operation instruction has
been saturated, this flag is set to 1 and is not reset to 0 even if the result of the subsequent
operation is not saturated.
Even if the SAT flag is set to 1, the saturated operation instruction is executed normally.
Caution
To reset the SAT flag to 0, load data to the PSW by using the LDSR instruction.
99
CHAPTER 5 INSTRUCTIONS
SATSUB
Saturated Subtract
Instruction format
Operation
Format
Format I
Opcode
15
rrrrr000101RRRRR
Flag
CY
OV
SAT
Instruction
Explanation
Subtracts the word data of general-purpose register reg1 from the word data of generalpurpose register reg2, and stores the result in general-purpose register reg2. However, if the
result exceeds the maximum positive value 7FFFFFFFH, 7FFFFFFFH is stored in reg2; if the
result exceeds the maximum negative value 80000000H, 80000000H is stored in reg2. The
SAT flag is set to 1. The data of general-purpose register reg1 is not affected.
Do not specify r0 as the destination register reg2.
Remark
The SAT flag is a cumulative flag. Once the result of the operation of the saturated operation
instruction has been saturated, this flag is set to 1 and is not reset to 0 even if the result of the
subsequent operations is not saturated.
Even if the SAT flag is set to 1, the saturated operation instruction is executed normally.
Caution
100
To reset the SAT flag to 0, load data to the PSW by using the LDSR instruction.
CHAPTER 5 INSTRUCTIONS
SATSUBI
Saturated Subtract Immediate
Instruction format
Operation
Format
Format VI
Opcode
15
rrrrr110011RRRRR
Flag
31
16
iiiiiiiiiiiiiiii
CY
OV
SAT
Instruction
Explanation
Subtracts the 16-bit immediate data, sign-extended to word length, from the word data of
general-purpose register reg1, and stores the result in general-purpose register reg2.
However, if the result exceeds the maximum positive value 7FFFFFFFH, 7FFFFFFFH is
stored in reg2; if the result exceeds the maximum negative value 80000000H, 80000000H is
stored in reg2. The SAT flag is set to 1. The data of general-purpose register reg1 is not
affected.
Do not specify r0 as the destination register reg2.
Remark
The SAT flag is a cumulative flag. Once the result of the operation of the saturated operation
instruction has been saturated, this flag is set to 1 and is not reset to 0 even if the result of the
subsequent operations is not saturated.
Even if the SAT flag is set to 1, the saturated operation instruction is executed normally.
Caution
To reset the SAT flag to 0, load data to the PSW by using the LDSR instruction.
101
CHAPTER 5 INSTRUCTIONS
SATSUBR
Saturated Subtract Reverse
Instruction format
Operation
Format
Format I
Opcode
15
rrrrr000100RRRRR
Flag
CY
OV
SAT
Instruction
Explanation
Subtracts the word data of general-purpose register reg2 from the word data of generalpurpose register reg1, and stores the result in general-purpose register reg2. However, if the
result exceeds the maximum positive value 7FFFFFFFH, 7FFFFFFFH is stored in reg2; if the
result exceeds the maximum negative value 80000000H, 80000000H is stored in reg2. The
SAT flag is set to 1. The data of general-purpose register reg1 is not affected.
Do not specify r0 as the destination register reg2.
Remark
The SAT flag is a cumulative flag. Once the result of the operation of the saturated operation
instruction has been saturated, this flag is set to 1 and is not reset to 0 even if the result of the
subsequent operations is not saturated.
Even if the SAT flag is set to 1, the saturated operation instruction is executed normally.
Caution
102
To reset the SAT flag to 0, load data to the PSW by using the LDSR instruction.
CHAPTER 5 INSTRUCTIONS
SETF
Set Flag Condition
Instruction format
Operation
Format
Opcode
Format IX
15
rrrrr1111110cccc
Flag
CY
OV
SAT
31
16
0000000000000000
Instruction
Explanation
General-purpose register reg2 is set to 1 if the condition specified by condition code cccc is
satisfied; otherwise, 0 is stored in the register.
103
CHAPTER 5 INSTRUCTIONS
Condition Name
Condition Expression
(cccc)
0000
104
OV = 1
1000
NV
OV = 0
0001
C/L
CY = 1
1001
NC/NL
CY = 0
0010
Z=1
1010
NZ
Z=0
0011
NH
(CY or Z) = 1
1011
(CY or Z) = 0
0100
S/N
S=1
1100
NS/P
S=0
0101
always
1101
SA
SAT = 1
0110
LT
(S xor OV) = 1
1110
GE
(S xor OV) = 0
0111
LE
1111
GT
CHAPTER 5 INSTRUCTIONS
SET1
Set Bit
Instruction format
Operation
Format
Opcode
15
(1)
00bbb111110RRRRR
15
(2)
Flag
CY
OV
16
dddddddddddddddd
0
rrrrr111111RRRRR
31
31
16
0000000011100000
SAT
Instruction
Explanation
(1) Adds the 16-bit displacement, sign-extended to word length, to the data of generalpurpose register reg1 to generate a 32-bit address. Then reads the byte data referenced
by the generated address, inverts the bit specified by the 3-bit field bbb, and writes the
data to the previous address. Bits other than the specified bit are not affected.
(2) Reads the data of general-purpose register reg1 to generate a 32-bit address. Then reads
the byte data referenced by the generated address, inverts the bit specified by the data of
the lower 3 bits of reg2, and writes the data to the previous address. Bits other than the
specified bit are not affected.
Remark
The Z flag of the PSW indicates whether the specified bit was 0 or 1 before this instruction was
executed, and does not indicate the content of the specified bit after this instruction has been
executed.
105
CHAPTER 5 INSTRUCTIONS
SHL
Shift Logical Left
Instruction format
Operation
Format
(1) Format IX
(2) Format II
Opcode
15
(1)
rrrrr111111RRRRR
15
(2)
Flag
CY
31
16
0000000011000000
0
rrrrr010110iiiii
1 if the bit shifted out last is 1; otherwise, 0.
However, if the number of shifts is 0, the result is 0.
OV
Instruction
SAT
Explanation
(1) Logically shifts the word data of general-purpose register reg2 to the left by n positions,
where n is a value from 0 to +31, specified by the lower 5 bits of general-purpose register
reg1 (0 is shifted to the LSB side), and then writes the result in general-purpose register
reg2. If the number of shifts is 0, general-purpose register reg2 retains the same value
prior to instruction execution. The data of general-purpose register reg1 is not affected.
(2) Logically shifts the word data of general-purpose register reg2 to the left by n positions,
where n is a value from 0 to +31, specified by the 5-bit immediate data, zero-extended to
word length (0 is shifted to the LSB side), and then writes the result in general-purpose
register reg2. If the number of shifts is 0, general-purpose register reg2 retains the value
prior to instruction execution.
106
CHAPTER 5 INSTRUCTIONS
SHR
Shift Logical Right
Instruction format
Operation
Format
(1) Format IX
(2) Format II
Opcode
15
(1)
rrrrr111111RRRRR
15
(2)
Flag
CY
31
16
0000000010000000
0
rrrrr010100iiiii
1 if the bit shifted out last is 1; otherwise, 0.
However, if the number of shifts is 0, the result is 0.
OV
Instruction
SAT
Explanation
(1) Logically shifts the word data of general-purpose register reg2 to the right by n positions
where n is a value from 0 to +31, specified by the lower 5 bits of general-purpose register
reg1 (0 is shifted to the MSB side). This instruction then writes the result in generalpurpose register reg2. If the number of shifts is 0, general-purpose register reg2 retains
the same value prior to instruction execution. The data of general-purpose register reg1 is
not affected.
(2) Logically shifts the word data of general-purpose register reg2 to the right by n positions,
where n is a value from 0 to +31, specified by the 5-bit immediate data, zero-extended to
word length (0 is shifted to the MSB side).
107
CHAPTER 5 INSTRUCTIONS
SLD
Short Load
Instruction format
Operation
Format
Format IV
Opcode
15
(1)
rrrrr0110ddddddd
15
(2)
rrrrr1000ddddddd
rrrrr1010dddddd0
rrrrr0000110dddd
rrrrr0000111dddd
108
CHAPTER 5 INSTRUCTIONS
Flag
Instruction
CY
OV
SAT
Explanation
(1) Adds the 7-bit displacement, zero-extended to word length, to the element pointer to
generate a 32-bit address. Byte data is read from the generated address, sign-extended
to word length, and stored in reg2.
(2) Adds the 8-bit displacement, zero-extended to word length, to the element pointer to
generate a 32-bit address.
(1) The result of adding the element pointer and the 8-bit displacement zero-extended to word
length can be of two types depending on the type of data to be accessed (halfword, word)
and the misaligned mode setting.
Lower bits are masked by 0 and address is generated (when misalign access is
disabled)
Lower bits are not masked and address is generated (when misalign access is enabled)
109
CHAPTER 5 INSTRUCTIONS
110
CHAPTER 5 INSTRUCTIONS
SST
Store
Instruction format
Operation
Format
Format IV
Opcode
15
(1)
rrrrr0111ddddddd
15
(2)
rrrrr1001ddddddd
ddddddd is the higher 7 bits of disp8.
15
(3)
rrrrr1010dddddd1
dddddd is the higher 6 bits of disp8.
Flag
Instruction
CY
OV
SAT
111
CHAPTER 5 INSTRUCTIONS
Explanation
(1) Adds the 7-bit displacement, zero-extended to word length, to the element pointer to
generate a 32-bit address, and stores the data of the lowest byte of reg2 in the generated
address.
(2) Adds the 8-bit displacement, zero-extended to word length, to the element pointer to
generate a 32-bit address, and stores the lower halfword data of reg2 in the generated 32bit address with bit 0 masked by 0.
(3) Adds the 8-bit displacement, zero-extended to word length, to the element pointer to
generate a 32-bit address, and stores the word data of reg2 in the generated 32-bit
address with bits 0 and 1 masked by 0.
Cautions
(1) The result of adding the element pointer and the 8-bit displacement zero-extended to word
length can be of two types depending on the type of data to be accessed (halfword, word)
and the misaligned mode setting.
Lower bits are masked by 0 and address is generated (when misalign access is
disabled)
Lower bits are not masked and address is generated (when misalign access is enabled)
For details on misalign access, see 3.3 Data Alignment.
(2) Branch instructions may not be correctly executed in the following instruction sequence.
Instruction 1
Instruction 2
Instruction 3
sst instruction
Instruction 4
bcond (bc, be, bge, bgt, bh, bl, ble, blt, bn, bnc, bne, bnh, bnl, bnv, bnz,
bp, br, bsa, bv, bz) instruction
112
CHAPTER 5 INSTRUCTIONS
ST
Store
Instruction format
Operation
Format
Format VII
Opcode
15
(1)
rrrrr111010RRRRR
15
(2)
31
16
dddddddddddddddd
0
rrrrr111011RRRRR
31
16
ddddddddddddddd0
rrrrr111011RRRRR
31
16
ddddddddddddddd1
Instruction
CY
OV
SAT
113
CHAPTER 5 INSTRUCTIONS
Explanation
(1) Adds the 16-bit displacement, sign-extended to word length, to the data of generalpurpose register reg1 to generate a 32-bit address, and stores the lowest byte data of
general-purpose register reg2 in the generated address.
(2) Adds the 16-bit displacement, sign-extended to word length, to the data of generalpurpose register reg1 to generate a 32-bit address, and stores the lower halfword data of
general-purpose register reg2 in the generated 32-bit address with bit 0 masked by 0.
Therefore, stored data is automatically aligned on a halfword boundary.
(3) Adds the 16-bit displacement, sign-extended to word length, to the data of generalpurpose register reg1 in generate a 32-bit address, and stores the word data of generalpurpose register reg2 in the generated 32-bit address with bits 0 and 1 masked by 0.
Therefore, stored data is automatically aligned on a word boundary.
Caution
The result of adding the data of general-purpose register reg1 and the 16-bit displacement
sign-extended to word length can be of two types depending on the type of data to be
accessed (halfword, word), and the misalign mode setting.
Lower bits are masked by 0 and address is generated (when misalign access is
disabled)
Lower bits are not masked and address is generated (when misalign access is enabled)
For details on misalign access, see 3.3 Data Alignment.
114
CHAPTER 5 INSTRUCTIONS
STSR
Store Contents of System Register
Instruction format
Operation
GR [reg2] SR [regID]
Format
Format IX
Opcode
15
rrrrr111111RRRRR
Flag
CY
OV
SAT
31
16
0000000001000000
Instruction
Explanation
Stores the contents of a system register specified by a system register number (regID) in
general-purpose register reg2. The contents of the system register are not affected.
Remark
The system register number regID is a number which identifies a system register. Accessing a
system register which is reserved is prohibited and will lead to undefined results.
115
CHAPTER 5 INSTRUCTIONS
SUB
Subtract
Instruction format
Operation
Format
Format I
Opcode
15
rrrrr001101RRRRR
Flag
CY
OV
SAT
Instruction
SUB Subtract
Explanation
Subtracts the word data of general-purpose register reg1 from the word data of generalpurpose register reg2, and stores the result in general-purpose register reg2. The data of
general-purpose register reg1 is not affected.
116
CHAPTER 5 INSTRUCTIONS
SUBR
Subtract Reverse
Instruction format
Operation
Format
Format I
Opcode
15
rrrrr001100RRRRR
Flag
CY
OV
SAT
Instruction
Explanation
Subtracts the word data of general-purpose register reg2 from the word data of generalpurpose register reg1, and stores the result in general-purpose register reg2. The data of
general-purpose register reg1 is not affected.
117
CHAPTER 5 INSTRUCTIONS
SWITCH
Jump with Table Look Up
Instruction format
SWITCH reg1
Operation
Format
Format I
Opcode
15
00000000010RRRRR
Flag
CY
OV
SAT
Instruction
Explanation
<1>
Adds the table entry address (address following the SWITCH instruction) and data of
general-purpose register reg1 logically shifted left by 1, and generates 32-bit table entry
address.
<2>
<3>
Sign-extends the loaded halfword data to word length, and adds the table entry address
after logically shifts it left by 1 bit (next address following SWITCH instruction) to
generate a 32-bit target address.
<4>
118
CHAPTER 5 INSTRUCTIONS
SXB
Sign Extend Byte
Instruction format
SXB reg1
Operation
Format
Format I
Opcode
15
00000000101RRRRR
Flag
CY
OV
SAT
Instruction
Explanation
119
CHAPTER 5 INSTRUCTIONS
SXH
Sign Extend Half-word
Instruction format
SXH reg1
Operation
Format
Format I
Opcode
15
00000000111RRRRR
Flag
CY
OV
SAT
Instruction
Explanation
120
CHAPTER 5 INSTRUCTIONS
TRAP
Software Trap
Instruction format
TRAP vector
Operation
EIPC
PC + 4 (restore PC)
EIPSW
PSW
ECR.EICC
interrupt code
PSW.EP
PSW.ID
PC
Format
Format X
Opcode
15
00000111111iiiii
Flag
CY
OV
SAT
31
16
0000000100000000
Instruction
TRAP Trap
Explanation
Saves the restore PC and PSW to EIPC and EIPSW, respectively; sets the exception code
(EICC of ECR) and the flags of the PSW (EP and ID flags); jumps to the address of the trap
handler corresponding to the trap vector specified by vector number (0-31), and starts
exception processing. The condition flags are not affected.
The restore PC is the address of the instruction following the TRAP instruction.
121
CHAPTER 5 INSTRUCTIONS
TST
Test
Instruction format
Operation
Format
Format I
Opcode
15
rrrrr001011RRRRR
Flag
CY
OV
SAT
Instruction
TST Test
Explanation
ANDs the word data of general-purpose register reg2 with the word data of general-purpose
register reg1. The result is not stored, and only the flags are changed. The data of generalpurpose registers reg1 and reg2 are not affected.
122
CHAPTER 5 INSTRUCTIONS
TST1
Test Bit
Instruction format
Operation
Format
Opcode
15
(1)
11bbb111110RRRRR
15
(2)
Flag
CY
OV
16
dddddddddddddddd
0
rrrrr111111RRRRR
31
31
16
0000000011100110
SAT
Instruction
Explanation
(1) Adds the data of general-purpose register reg1 to a 16-bit displacement, sign-extended to
word length, to generate a 32-bit address. Performs the test on the bit specified by the 3bit field bbb, at the byte data location referenced by the generated address.
If the
specified bit is 0, the Z flag is set to 1; if the bit is 1, the Z flag is reset to 0. The byte data,
including the specified bit, is not affected.
(2) Reads the data of general-purpose register reg1 to generate a 32-bit address. Performs a
test on the bit specified by the lower 3 bits of reg2, at the byte data location referenced by
the generated address. If the specified bit is 0, the Z flag is set to 1; if the bit is 1, the Z
flag is reset to 0. The byte data, including the specified bit, is not affected.
123
CHAPTER 5 INSTRUCTIONS
XOR
Exclusive Or
Instruction format
Operation
Format
Format I
Opcode
15
rrrrr001001RRRRR
Flag
CY
OV
SAT
Instruction
XOR Exclusive Or
Explanation
Exclusively ORs the word data of general-purpose register reg2 with the word data of generalpurpose register reg1, and stores the result in general-purpose register reg2. The data of
general-purpose register reg1 is not affected.
124
CHAPTER 5 INSTRUCTIONS
XORI
Exclusive Or Immediate
Instruction format
Operation
Format
Format VI
Opcode
15
rrrrr110101RRRRR
Flag
31
16
iiiiiiiiiiiiiiii
CY
OV
SAT
Instruction
Explanation
Exclusively ORs the word data of general-purpose register reg1 with a 16-bit immediate data,
zero-extended to word length, and stores the result in general-purpose register reg2. The data
of general-purpose register reg1 is not affected.
125
CHAPTER 5 INSTRUCTIONS
ZXB
Zero Extend Byte
Instruction format
ZXB reg1
Operation
Format
Format I
Opcode
15
00000000100RRRRR
Flag
CY
OV
SAT
Instruction
Explanation
126
CHAPTER 5 INSTRUCTIONS
ZXH
Zero Extend Half-word
Instruction format
ZXH reg1
Operation
Format
Format I
Opcode
15
00000000110RRRRR
Flag
CY
OV
SAT
Instruction
Explanation
127
CHAPTER 5 INSTRUCTIONS
Mnemonic
Operand
Bytes
Execution Clocks
irl
SLD.B
disp7 [ep], r
1 1 nNote 1
SLD.H
disp8 [ep], r
1 1 nNote 1
SLD.W
disp8 [ep], r
1 1 nNote 1
SLD.BU
disp4 [ep], r
1 1 nNote1
SLD.HU
disp5 [ep], r
1 1 nNote 1
LD.B
disp16 [R], r
1 1 nNote 2
LD.H
disp16 [R], r
1 1 nNote 2
LD.W
disp16 [R], r
1 1 nNote 2
LD.BU
disp16 [R], r
1 1 nNote 2
LD.HU
disp16 [R], r
1 1 nNote 2
SST.B
r, disp7 [ep]
111
SST.H
r, disp8 [ep]
111
SST.W
r, disp8 [ep]
111
ST.B
r, disp16 [R]
111
ST.H
r, disp16 [R]
111
ST.W
r, disp16 [R]
111
Arithmetic
MOV
R, r
111
operation
MOV
imm5, r
111
MOV
imm32, r
222
MOVEA
imm16, R, r
111
MOVHI
imm16, R, r
111
DIVH
R, r
35 35 35
DIVH
R, r, w
35 35 35
DIVHU
R, r, w
34 34 34
DIV
R, r, w
35 35 35
DIVU
R, r, w
34 34 34
MULH
R, r
112
MULH
imm5, r
112
MULHI
imm16, R, r
112
MUL
R, r, w
1 2Note 3 2
MUL
imm9, r, w
1 2Note 3 2
Load
Store
128
CHAPTER 5 INSTRUCTIONS
Mnemonic
Operand
Bytes
Execution Clocks
irl
Arithmetic
MULU
R, r, w
1 2Note 3 2
operation
MULU
imm9, r, w
1 2Note 3 2
(continued)
ADD
R, r
111
ADD
imm5, r
111
ADDI
imm16, R, r
111
CMP
R, r
111
CMP
imm5, r
111
SUBR
R, r
111
SUB
R, r
111
CMOV
cccc, R, r, w
111
CMOV
cccc, imm5, r, w
111
SASF
cccc, r
111
SETF
cccc, r
111
Saturated
SATSUBR
R, r
111
operation
SATSUB
R, r
111
SATADD
R, r
111
SATADD
imm5, r
111
SATSUBI
imm16, R, r
111
Logical
NOT
R, r
111
operation
OR
R, r
111
XOR
R, r
111
AND
R, r
111
TST
R, r
111
SHR
imm5, r
111
SAR
imm5, r
111
SHL
imm5, r
111
ORI
imm16, R, r
111
XORI
imm16, R, r
111
ANDI
imm16, R, r
111
SHR
R, r
111
SAR
R, r
111
SHL
R, r
111
ZXB
111
ZXH
111
SXB
111
SXH
111
129
CHAPTER 5 INSTRUCTIONS
Mnemonic
Operand
Bytes
Execution Clocks
irl
Logical
BSH
r, w
111
operation
BSW
r, w
111
HSW
r, w
111
Branch
JMP
[R]
333
(Continued)
JR
disp22
222
JARL
disp22, r
Bcond
disp9
2Note 4 2Note 4
111
Bit
SET1
manipulation
SET1
r, [R]
CLR1
CLR1
r, [R]
NOT1
NOT1
r, [R]
TST1
TST1
r, [R]
LDSR
R, SR
111
STSR
SR, r
111
SWITCH
Special
555
Note 6
N+1Note6 N+1Note 6
PREPARE
list12, imm5
N+1
PREPARE
list12, imm5, sp
PREPARE
PREPARE
DISPOSE
imm5, list12
DISPOSE
CALLT
imm6
444
CTRET
333
TRAP
vector
333
RETI
333
HALT
111
EI
111
DI
111
NOP
111
333
130
222
Note 4
CHAPTER 5 INSTRUCTIONS
Notes
1.
2.
3.
1 if r = w (lower 32 bits of results are not written to register) or w = r0 (higher 32 bits of results are
not written to register).
4.
5.
6.
131
CHAPTER 5 INSTRUCTIONS
Remarks
1. Operand conventions
Symbol
Meaning
R: reg1
r: reg2
w: reg3
System register
imm: immediate
-bit immediate
disp: displacement
-bit displacement
Element pointer
B: Byte
Byte (8 bits)
H: Half-word
W: Word
cccc: conditions
vector
list
Meaning
i: issue
r: repeat
When the same instruction is repeatedly executed immediately after the instruction has been
executed
l: latency
When a subsequent instruction uses the result of execution of the preceding instruction immediately
after its execution
132
Interrupts are events that occur independently of the program execution and are divided into two types: maskable
and non-maskable interrupts. In contrast, an exception is an event whose occurrence is dependent on the program
execution.
The V850 Series can process various interrupt requests from the on-chip peripheral hardware and external
sources. In addition, exception processing can be started by an instruction (TRAP instruction) and by occurrence of
an exception event (exception trap).
The interrupts and exceptions supported in the V850 Series are described below. When an interrupt or exception
is deleted, control is transferred to a handler whose address is determined by the source of the interrupt or exception.
The source of the event is specified by the exception code that is stored in the exception cause register (ECR). Each
handler analyzes the exception cause register (ECR) and performs appropriate interrupt servicing or exception
processing. The restore PC and PSW are written to the status saving registers (EIPC, EIPSW/FEPC, FEPSW).
To restore execution from interrupt or exception processing, use the RETI instruction.
Read the restore PC and PSW from the status saving register, and transfer control to the restore PC.
133
Classification
Exception Code
Trigger
Handler
Restore PC
Address
NMI
NMI input
Interrupt
0010H
00000010H
next PC Note 3
Maskable interrupt
Note 2
Interrupt
Note 2
Note 1
next PC Note 3
TRAP0n (n = 0 to FH)
TRAP instruction
Exception
004nH
00000040H
next PC
TRAP1n (n = 0 to FH)
TRAP instruction
Exception
005nH
00000050H
next PC
ILGOP
Illegal opcode
Exception
0060H
00000060H
next PC Note 4
Notes 1. The higher 16 bits of the handler address are 0000H and the lower 16 bits of the handler address are
the same as the exception code.
2. Differs depending on the type of interrupt.
3. If an interrupt is acknowledged during execution of a DIV/DIVH/DIVU (divide) instruction, the restore
PC becomes the PC value for the currently executed instruction (DIV/DIVH/DIVU).
4. The execution address of the illegal instruction is obtained by restore PC-4 when an illegal opcode
exception occurs.
The restore PC is the PC saved to EIPC or FEPC when interrupt/exception processing is started. next PC is the
PC that starts processing after interrupt/exception processing.
The processing of maskable interrupts is controlled by the user through the interrupt controller (INTC). The INTC
is different for each device in the V850 Series due to variations in on-chip peripherals, interrupt/exception sources
and exception codes.
134
INT input
INTC acknowledgement
No
xxIF=1
Interrupt request?
Yes
No
xxMK=0
Is the interrupt
mask released?
Yes
Priority higher than
that of interrupt currently
being serviced?
No
Yes
Priority higher
than that of other interrupt
request?
No
Yes
Highest default
priority of interrupt requests
with the same priority?
No
Yes
Maskable interrupt request
CPU processing
PSW.NP = 0
No
Yes
PSW.ID = 0
No
Yes
EIPC
EIPSW
ECR. EICC
PSW. EP
PSW. ID
PC
Restored PC
PSW
Exception code
0
1
Handler address
Interrupt servicing
135
NMI input
INTC acknowledgement
Non-maskable interrupt request
CPU processing
PSW.NP = 0
No
Yes
FEPC
FEPSW
ECR.FECC
PSW.NP
PSW.EP
PSW.ID
PC
Restored PC
PSW
0010H
1
0
1
00000010H
Interrupt servicing
136
EIPC
EIPSW
ECR.EICC
PSW.EP
PSW.ID
PC
Restore PC
PSW
Exception code
1
1
Handler address
Exception processing
137
13 12 11 10
x x x
Remark
5 4
0 31
27 26
x x 1 1 1 1 1 1 x x x x x x x x x x
0 0 1
to
1 1 1
23 22 21 20
17 16
x x x x x x x
1
: Dont care
: Opcode/sub-opcode
If an exception trap occurs, the CPU performs the following steps, and transfers control to the handler routine.
(1) Saves restore PC to DBPC.
(2) Saves current PSW to DBPSW.
(3) Sets NP, EP, and ID bits of PSW.
(4) Sets handler address (00000060H) for exception trap to PC and transfers control.
Figure 6-5 illustrates how the exception trap is processed.
Figure 6-5. Exception Trap Processing Format
Exception trap
(ILGOP) occurs
DBPC
DBPSW
PSW.NP
PSW.EP
PSW.ID
PC
Restore PC
PSW
1
1
1
00000060H
Exception processing
The execution address of the illegal instruction is obtained by restore PC - 4 when an exception trap occurs.
Caution In addition to the defined opcodes and illegal opcodes, there is a range of codes not recognized
by this processor. If an instruction corresponding to these codes is executed, normal operation
is undetermined.
138
No
PSW.EP = 0
Yes
Restoration
from
exception
PSW.NP = 0
No
Yes
Restoration from
non-maskable
interrupt
Restoration
from maskable
interrupt
PC
PSW
EIPC
EIPSW
PC
PSW
FEPC
FEPSW
Jump to PC
139
CHAPTER 7 RESET
When a low-level signal is input to the RESET pin, the system is reset, and all on-chip hardware is initialized.
7.1 Initialization
When a low-level signal is input to the RESET pin, the system is reset, and each hardware register is set in the
status shown in Table 7-1. When the RESET signal goes high, program execution begins. If necessary, initialize the
contents of each register by program control.
Table 7-1. Register Status After Reset
Hardware (Symbol)
Program counter
PC
00000000H
EIPC
Undefined
EIPSW
Undefined
FEPC
Undefined
FEPSW
Undefined
FECC
0000H
EICC
0000H
PSW
00000020H
CTPC
Undefined
CTPSW
Undefined
DBPC
Undefined
DBPSW
Undefined
CTBP
Undefined
r0
Fixed to 00000000H
r1 to r31
Undefined
7.2 Starting Up
All devices in the V850 Series begin program execution from address 00000000H after reset.
No interrupt
requests are acknowledged immediately after reset. To enable interrupts, clear the ID bit of the program status word
(PSW) to 0.
140
CHAPTER 8 PIPELINE
The V850 Series is based on RISC architecture and executes almost all instructions in one clock cycle under the
control of a 5-stage pipeline.
The V850E/MS1 includes the V850E CPU core. The V850E CPU core, by optimizing the pipeline, improves the
CPI (Cycles Per Instruction) rate over the previous V850 CPU core.
The pipeline configuration of the V850E CPU core is shown in Figure 8-1.
Figure 8-1. Pipeline Configuration
Master pipeline
(V850 CPU compatible)
ID
EX
DF
IF
WB
Asynchronous WB pipeline
br/sld
pipeline
ID
MEM
Address calculation
stage
IF (instruction fetch):
WB
ID (instruction decode):
WB (write back):
DF (data fetch):
141
CHAPTER 8 PIPELINE
8.1 Features
(1) Non-blocking load/store
As the pipeline does not stop during external memory access, efficient processing is possible. For example,
Figure 8-2 shows a comparison of pipeline operations between the V850 CPU and the V850E CPU when the
ADD instruction is executed after the execution of a load instruction for external memory.
Figure 8-2. Non-Blocking Load/Store
Previous version (V850 CPU)
Load instruction
IF
ADD instruction
IF
ID
EX
IF
ID
Next instruction
V850E CPU
Load instruction
ADD instruction
Next instruction
Notes
ID
T1
T2
T3
WB
MEM WB
EX MEM WB
T1
T2
WB
ID
EX
DF
WB
IF
ID
EX MEM WB
ID
EX
IF
1. The basic bus cycle for the external memory of the V850 is 3 clocks.
2. The basic bus cycle for the external memory of the V850E is 2 clocks.
V850 CPU
The EX stage of the ADD instruction is usually executed in 1 clock. However, a wait time is generated in the
EX stage of the ADD instruction during execution of the MEM stage of the previous load instruction. This is
because the same stage of the 5 stages on the pipeline cannot be executed in the same internal clock
interval. This also causes a wait time to be generated in the ID stage of the next instruction after the ADD
instruction.
V850E CPU
An asynchronous WB pipeline for the instructions that are necessary for the MEM stage is provided in addition
to the master pipeline. The MEM stage of the load instruction is therefore processed on this asynchronous
WB pipeline. Because the ADD instruction is processed on the master pipeline, a wait time is not generated,
making it possible to execute instructions efficiently.
142
CHAPTER 8 PIPELINE
Branch instruction
IF
ID
EX
Branch destination
instruction
WB
IF
ID
EX
MEM
WB
V850E CPU
Branch instruction
MEM
IF
ID
MEM
WB
IF
ID
Branch destination
instruction
EX
MEM
WB
143
CHAPTER 8 PIPELINE
ADD instruction
IF
Branch instruction
ID
EX
IF
ID
(MEM) WB
EX
MEM
WB
IF
ID
EX
MEM
WB
MEM
V850E CPU
ADD instruction
Branch instruction
IF
ID
EX
DF
ID
MEM
WB
IF
ID
WB
EX
V850 CPU
Although the instruction codes up to the next branch instruction are fetched in the IF stage of the ADD
instruction, the ID stage of the ADD instruction and the ID stage of the branch instruction cannot operate
together within the same internal clock. Therefore, it takes 5 clocks from the branch instruction fetch to the
branch destination instruction fetch.
V850E CPU
Because V850E CPU has an ID stage for branch/short load instructions in addition to the ID stage on the
master pipeline, the parallel execution of the ID stage of the ADD instruction and the ID stage of the branch
instruction within the same internal clock is possible. Therefore, it takes only 3 clocks from the branch
instruction fetch to the branch destination instruction.
144
CHAPTER 8 PIPELINE
IF
ID
IF
EX
ID
IF
MEM
EX
ID
IF
WB
MEM
EX
ID
IF
End of
instruction 1
WB
MEM
EX
ID
IF
End of
instruction 2
WB
MEM
EX
ID
IF
End of
instruction 3
WB
MEM
EX
ID
IF
End of
instruction 4
10
11
12
13
WB
MEM
EX
ID
IF
WB
MEM WB
EX
MEM WB
ID
EX
MEM WB
End of
instruction 5
End of
instruction 6
End of
instruction 7
End of
instruction 8
End of
instruction 9
1 through 13 in the figure above indicate the states of the CPU. In each state, write-back of instruction n, memory
access of instruction n+1, execution of instruction n+2, decoding of instruction n+3, and fetching of instruction n+4
are simultaneously performed. It takes five clock cycles to process a standard instruction, including fetching and
writeback. Because five instructions can be processed at the same time, however, a standard instruction can be
executed in 1 clock on average.
145
CHAPTER 8 PIPELINE
Stage
Internal RAM
External MemoryNote
(32 Bits)
(8/16 Bits)
(8/16 Bits)
Instruction fetch
1 or 2
Not possible
2+n
3+n
2+n
n: Wait number
[Pipeline]
LD instruction
IF
Next instruction
[Description]
ID
EX
MEM
WB
IF
ID
EX
MEM
WB
The pipeline consists of 5 stages, IF, ID, EX, MEM, and WB. If an instruction using the
execution result is placed immediately after the LD instruction, data wait time occurs.
(2) SLD
1
[Pipeline]
SLD instruction
IF
Next instruction
[Description]
ID
MEM
WB
IF
ID
EX
MEM
WB
ST, SST
1
[Pipeline]
Store instruction
Next instruction
[Description]
IF
ID
EX
MEM
WB
IF
ID
EX
MEM
WB
The pipeline consists of 5 stages, IF, ID, EX, MEM and WB. However, no operation is
performed in the WB stage, because no data is written to registers.
146
CHAPTER 8 PIPELINE
MOV, MOVEA, MOVHI, ADD, ADDI, CMP, SUB, SUBR, SETF, SASF, CMOV, ZXB, ZXH,
SXB, SXH, BSH, BSW, HSW
1
[Pipeline]
Arithmetic operation
instruction
IF
Next instruction
[Description]
ID
EX
DF
WB
IF
ID
EX
MEM
WB
MOV imm32
[Pipeline]
Arithmetic operation
instruction
IF
Next instruction
ID
EX1
EX2
DF
WB
IF
ID
EX
MEM
WB
The pipeline consists of 6 stages, IF, ID, EX1, EX2, DF and WB.
[Pipeline]
IF
Next instruction
ID
EX1
EX2
WB
IF
ID
EX
MEM
WB
[Description]
IF
ID
EX1
EX2
WB
IF
ID
EX1
EX2
WB
The pipeline consists of 5 stages, IF, ID, EX1, EX2, and WB. The EX stage requires 2 clocks,
but the EX1 and EX2 stages can operate independently. Therefore, the number of clocks for
instruction execution is always 1, even if several multiply instructions are executed in a row.
However, if an instruction using the execution result is placed immediately after a multiply
instruction, data wait time occurs.
147
CHAPTER 8 PIPELINE
[Pipeline]
Divide instruction
IF
Next instruction
ID
EX1
EX2
EX34
EX35
DF
IF
ID
EX
MEM
WB
IF
ID
EX
MEM
36
37
38
39
40
41
WB
WB
When a DIVU or DIVHU instruction is executed, the pipeline consists of 38 stages of IF, ID,
EX1 to EX34, DF, and WB.
When a DIVH or DIV instruction is executed, the pipeline consists of 39 stages of IF, ID, EX1
to EX35, DF, and WB.
NOT, OR, ORI, XOR, XORI, AND, ANDI, TST, SHR, SAR, SHL
1
[Pipeline]
Logical operation
instruction
IF
Next instruction
[Description]
ID
EX
DF
WB
IF
ID
EX
MEM
WB
The pipeline consists of 5 stages, IF, ID, EX, DF, and WB.
[Pipeline]
Saturation operation
instruction
Next instruction
[Description]
148
IF
ID
EX
DF
WB
IF
ID
EX
MEM
WB
The pipeline consists of 5 stages, IF, ID, EX, DF, and WB.
CHAPTER 8 PIPELINE
Bcond instructions (BGT, BGE, BLT, BLE, BH, BNL, BL, BNH, BE, BNE, BV, BNV, BN, BP,
BC, BNC, BZ, BNZ, BSA): Except BR instruction
[Pipeline]
IF
Next instruction
ID
MEM
WB
IF
ID
EX
MEM
WB
IF
ID
MEM
WB
IF
ID
IF
Next instruction
Branch destination instruction
EX
MEM
WB
The pipeline consists of 4 stages, IF, ID, MEM, and WB. However, no operation is performed
in the MEM and WB stages, because memory is not accessed and no data is written to
registers.
(a) When the condition is not realized
The number of execution clocks for the branch instruction is 1.
(b) When the condition is realized
The number of execution clocks for the branch instruction is 2. IF stage of the next
instruction of the branch instruction is not executed. If an instruction overwriting the
contents of PSW occurs immediately before a branch instruction execution, condition wait
time occurs.
JR, JARL, BR
1
[Pipeline]
Unconditional branch
IF
instruction
ID
Next instruction
IF
IF :
MEM
WB *
IF
ID
EX
MEM
WB
149
CHAPTER 8 PIPELINE
[Description]
The pipeline consists of 4 stages, IF, ID, MEM, and WB. However, no operation is performed
in the MEM and WB stages, because memory is not accessed and no data is written to
registers. However, in the case of the JARL instruction, data is written to the restore PC in the
WB stage. Also, the IF stage of the next instruction of the branch instruction is not executed.
JMP, CTRET
1
[Pipeline]
Register indirect
branch instruction
IF
2
ID
3
EX
MEM
WB
IF
ID
IF
Next instruction
Branch destination instruction
EX
MEM
The pipeline consists of 5 stages, IF, ID, EX, MEM, and WB. However, no operation is
performed in the MEM and WB stages, because memory is not accessed and no data is
written to registers.
(4)
CALLT
1
[Pipeline]
Table indirect call
instruction
IF
2
ID
3
MEM
4
EX
MEM
WB
IF
ID
IF
Next instruction
Branch destination instruction
EX
MEM
WB
The pipeline consists of 6 stages, IF, ID, MEM, EX, MEM, and WB. However, no operation is
performed in the second MEM and WB stages, because there is no second memory access
and no data is written to registers.
(5)
SWITCH
1
[Pipeline]
ID
Next instruction
IF
3
EX1
4
MEM
5
EX2
150
MEM
WB
IF
ID
EX
MEM
10
WB
CHAPTER 8 PIPELINE
[Description]
The pipeline consists of 7 stages, IF, ID, EX1, MEM, EX2, MEM, and WB. However, no
operation is performed in the second MEM and WB stages, because there is no second
memory access and no data is written to registers.
[Pipeline]
SET1, CLR1, NOT1
instruction
IF
Next instruction
ID
EX1
MEM
EX2
MEM
IF
ID
EX
MEM
WB
IF
ID
EX
MEM
WB
WB
The pipeline consists of 7 stages, IF, ID, EX1, MEM, EX2, MEM, and WB. However, no
operation is performed in the WB stage, because no data is written to registers.
In the case of these instructions, the memory access is read modify write, and the EX and
MEM stages require 2 and 2 clocks, respectively.
(2) TST1
[Pipeline]
TST1 instruction
Next instruction
IF
ID
EX1
MEM
EX2
MEM
IF
ID
EX
MEM
WB
IF
ID
EX
MEM
WB
WB
The pipeline consists of 7 stages, IF, ID, EX1, MEM, EX2, MEM, and WB. However, no
operation is performed in the second MEM and WB stages, because there is no second
memory access nor data write to registers.
In the case of this instruction, the memory access is read modify write, and the EX and MEM
stages require 2 and 2 clocks, respectively.
151
CHAPTER 8 PIPELINE
[Pipeline]
LDSR, STSR
instruction
IF
Next instruction
[Description]
ID
EX
DF
WB
IF
ID
EX
MEM
WB
The pipeline consists of 5 stages, IF, ID, EX, DF, and WB. If the STSR instruction using the
EIPC and FEPC system registers is placed immediately after the LDSR instruction setting
these registers, data wait time occurs.
(2) NOP
1
[Pipeline]
IF
NOP instruction
Next instruction
[Description]
ID
EX
MEM
WB
IF
ID
EX
MEM
WB
The pipeline consists of 5 stages, IF, ID, EX, MEM, and WB. However, no operation is
performed in the EX, MEM and WB stages, because no operation and no memory access is
executed, and no data is written to registers.
(3) EI, DI
1
[Pipeline]
IF
EI, DI instruction
Next instruction
[Description]
ID
EX
MEM
WB
IF
ID
EX
MEM
WB
The pipeline consists of 5 stages, IF, ID, EX, MEM, and WB. However, no operation is
performed in the MEM and WB stages, because memory is not accessed and data is not
written to registers.
(4) HALT
[Pipeline]
1
HALT
instruction
IF
Next instruction
ID
EX
MEM
WB
IF
HALT release
ID
EX
MEM
WB
IF
ID
EX
MEM
WB
The pipeline consists of 5 stages, IF, ID, EX, MEM and WB. No operation is performed in the
MEM and WB stages, because memory is not accessed and no data is written to registers.
Also, for the next instruction, the ID stage is delayed until the HALT state is released.
152
CHAPTER 8 PIPELINE
(5) TRAP
1
[Pipeline]
TRAP instruction
IF
ID1
ID2
EX
DF
WB
IF
ID
EX
IF
Next instruction
Jump destination instruction
MEM
WB
The pipeline consists of 6 stages, IF, ID1, ID2, EX, DF, and WB. The ID stage requires 2
clocks. Also, the IF stage of the next instruction is not executed.
(6) RETI
1
[Pipeline]
RETI instruction
IF
ID1
ID2
EX
MEM
WB
IF
ID
EX
IF
Next instruction
Jump destination instruction
MEM
WB
The pipeline consists of 6 stages, IF, ID1, ID2, EX, MEM, and WB. However, no operation is
performed in the MEM and WB stages, because memory is not accessed and no data is
written to registers. The ID stage requires 2 clocks. Also, the IF stage of the next instruction is
not executed.
PREPARE, DISPOSE
[Pipeline]
IF
Next instruction
ID
EX
MEM
MEM
MEM
MEM
WB
IF
ID
EX
MEM
WB
IF
ID
EX
MEM
WB
153
CHAPTER 8 PIPELINE
IF
2
ID
3
EX
4
MEM
MEM
MEM
MEM
WB
IF
Next instruction
IF
ID
EX
The pipeline consists of n (Number of register lists) + 4 stages, IF, ID, EX, n + 1 times MEM,
and WB. The MEM stage requires n clocks.
154
CHAPTER 8 PIPELINE
(b) Pipeline
1
32 bits
X8H
Instruc- Instruction d
tion e
X4H
Instruc- Instruction b
tion c
X0H
Instruc- Instruction a
tion b
Branch instruction IF
ID
EX
MEM
Next instruction
IF
Branch destination instruction
IF1
IF2
(instruction b)
Branch destination's next instruction (instruction c)
MEM
EX
WB
MEM
WB
ID
IF
EX
ID
WB
First instruction fetch that occurs during align hazard. It is a 2byte fetch that fetches the 2 bytes on the lower address of
instruction b.
IF2:
Align hazards can be prevented through the following handling in order to obtain faster instruction execution.
Use 2-byte branch destination instruction.
Use 4-byte instructions placed at word boundaries (A1=0, A0=0) for branch destination instructions.
155
CHAPTER 8 PIPELINE
1
Load instruction 1
IF
(LD [R4], R6)
Instruction 2 (ADD 2, R6)
Instruction 3
Instruction 4
2
ID
IF
3
EX
IL
IF
4
MEM
ID
5
WB
EX
ID
IF
6
MEM
EX
ID
7
WB
MEM
EX
WB
MEM
WB
2
ID
IF
EX1
IL
IF
EX2
ID
5
WB
EX
ID
IF
6
MEM
EX
ID
7
WB
MEM
EX
156
WB
MEM
WB
CHAPTER 8 PIPELINE
As described in Figure 8-8, when an instruction placed immediately after a multiply instruction uses its execution
result, a data wait time occurs due to the interlock function, and the execution speed is lowered. This drop in
execution speed can be avoided by placing instructions that use the execution result of a multiply instruction at least
2 instructions after the multiply instruction.
8.4.4 Referencing execution result of LDSR instruction for EIPC and FEPC
When using the LDSR instruction to set the data of the EIPC and FEPC system registers, and immediately after
referencing the same system registers with the STSR instruction, the use of the system registers for the STSR
instruction is delayed until the setting of the system registers with the LDSR instruction is completed (occurrence of
hazard).
The V850 Series interlock function delays the ID stage of the STSR instruction immediately after.
As a result of the above, when using the execution result of the LDSR instruction for EIPC and FEPC for an STSR
instruction following immediately after, the number of execution clocks of the LDSR instruction becomes 3.
Figure 8-9. Example of Execution Result of LDSR Instruction for EIPC and FEPC
LDSR instruction
(LDSR R6, 0) Note
IF
STSR instruction
Note
(STSR 0, R7)
Next instruction
Next to next instruction
2
ID
IF
3
EX
IL
IF
4
MEM
IL
5
WB
ID
6
EX
ID
IF
7
MEM
EX
ID
8
WB
MEM
EX
WB
MEM
10
WB
157
Operand
Format
CY
OV
SAT
Mnemonic
Convention
ADD
reg1, reg2
Instruction
Mnemonic
Operand
Name
Name
Indicates
Instruction Format
Meaning
General-purpose register (used as source register)
reg2
General-purpose register (mainly used as destination register. Some are also used as
source registers)
reg3
bit#3
imm
-bit immediate
disp
-bit displacement
regID
vector
cccc
list
Meaning
Reset (to 0)
No change
Describes
Movement of Flags
reg1
Identifier
158
Operand
Format
CY
OV
SAT
Instruction Function
Mnemonic
ADD
reg1, reg2
ADD
imm5, reg2
II
Add. Adds the 5-bit immediate data, signextended to word length, to the word data of
reg2, and stores the result in reg2.
ADDI
VI
AND
reg1, reg2
ANDI
VI
Bcond
disp9
III
BSH
reg2, reg3
XII
BSW
reg2, reg3
XII
CALLT
imm6
II
CLR1
bit#3, disp16
[reg1]
VIII
159
Operand
Format
CY
OV
SAT
Instruction Function
Mnemonic
CLR1
reg2 [reg1]
IX
CMOV
XI
CMOV
XII
Conditional Move. Reg3 is set to the data of 5immediate, sign-extended to word length, if the
condition specified by condition code cccc is
satisfied; otherwise, set to the data of reg2.
CMP
reg1, reg2
CMP
imm5, reg2
II
XIII
CTRET
DI
DISPOSE
imm5, list12
160
Operand
Format
CY
OV
SAT
Instruction Function
Mnemonic
DISPOSE
XIII
DIV
XI
DIVH
reg1, reg2
DIVH
XI
DIVHU
XI
DIVU
XI
EI
HALT
HSW
reg2, reg3
XII
JARL
disp22, reg2
161
Operand
Format
CY
OV
SAT
Instruction Function
Mnemonic
JMP
[reg1]
JR
disp22
LD.B
VII
LD.H
VII
LD.W
VII
LD.BU
VII
LD.HU
VII
LDSR
reg2, regID
IX
162
Operand
Format
CY
OV
SAT
Instruction Function
Mnemonic
MOV
reg1, reg2
MOV
imm5, reg2
II
MOV
imm32, reg1
VI
MOVEA
VI
MOVHI
VI
MUL
XI
MUL
XII
MULH
reg1, reg2
MULH
imm5, reg2
II
MULHI
VI
MULU
XI
163
Operand
Format
CY
OV
SAT
Instruction Function
XII
No Operation.
Mnemonic
MULU
NOP
NOT
reg1, reg2
NOT1
VIII
NOT1
reg2 [reg1]
IX
OR
reg1, reg2
ORI
VI
PREPARE
list12, imm5
XIII
PREPARE
XIII
164
Operand
Format
CY
OV
SAT
Instruction Function
Mnemonic
RETI
SAR
reg1, reg2
IX
SAR
imm5, reg2
II
SASF
cccc, reg2
IX
SATADD
reg1, reg2
SATADD
imm5, reg2
II
165
Operand
Format
CY
OV
SAT
Instruction Function
VI
Mnemonic
SATSUB
reg1, reg2
SATSUBI
SATSUBR
reg1, reg2
SETF
cccc, reg2
IX
SET1
VIII
Set Bit. First, adds a 16-bit displacement, signextended to word length, to the data of reg1 to
generate a 32-bit address. The bits, specified by
the 3-bit field bbb, are set at the byte data
location specified by the generated address.
SET1
reg2, [reg1]
IX
166
Operand
Format
CY
OV
SAT
Instruction Function
Mnemonic
SHL
reg1, reg2
IX
SHL
imm5, reg2
II
SHR
reg1, reg2
IX
SHR
imm5, reg2
II
SLD.B
IV
Byte Load. Adds the 7-bit displacement, zeroextended to word length, to the element pointer
to generate a 32-bit address. Byte data is read
from the generated address, sign-extended to
word length, and then stored in reg2.
SLD.H
IV
SLD.W
IV
Word Load. Adds the 8-bit displacement, zeroextended to word length, to the element pointer
to generate a 32-bit address. Word data is read
from this 32-bit address with bits 0 and 1
masked by 0, and stored in reg2.
167
Operand
Format
CY
OV
SAT
Instruction Function
Mnemonic
SLD.BU
IV
SLD.HU
IV
SST.B
IV
Byte Store. Adds the 7-bit displacement, zeroextended to word length, to the element pointer
to generate a 32-bit address, and stores the
data of the lowest byte of reg2 in the generated
address.
SST.H
IV
SST.W
IV
Word Store. Adds the 8-bit displacement, zeroextended to word length, to the element pointer
to generate a 32-bit address, and stores the
word data of reg2 in the generated 32-bit
address with bits 0 and 1 masked by 0.
ST.B
VII
Byte Store. Adds the 16-bit displacement, signextended to word length, to the data of reg1 to
generate a 32-bit address, and stores the lowest
byte data of reg2 in the generated address.
ST.H
VII
168
Operand
Format
CY
OV
SAT
Instruction Function
Mnemonic
ST.W
VII
Word Store. Adds the 16-bit displacement, signextended to word length, to the data of reg1 to
generate a 32-bit address, and stores the word
data of reg2 in the generated 32-bit address
with bits 0 and 1 masked by 0.
STSR
regID, reg2
IX
SUB
reg1, reg2
SUBR
reg1, reg2
SWITCH
reg1
SXB
reg1
SXH
reg1
TRAP
vector
TST
reg1, reg2
169
Operand
Format
CY
OV
SAT
Instruction Function
Mnemonic
TST1
VIII
TST1
reg2, [reg1]
IX
XOR
reg1, reg2
XORI
VI
ZXB
reg1
ZXH
reg1
170
Function
Mnemonic
Load/store
LD.B
LD.H
LD.W
LD.BU
LD.HU
SLD.B
SLD.H
SLD.W
SLD.BU
SLD.HU
ST.B
ST.H
ST.W
SST.B
SST.H
SST.W
SAR
BSH
BSW
HSW
Load Byte
Load Half-word
Load Word
Load Byte Unsigned
Load Half-word Unsigned
Load Byte
Load Half-word
Load Word
Load Byte Unsigned
Load Half-word Unsigned
Store Byte
Store Half-word
Store Word
Store Byte
Store Half-word
Store Word
(2-operand immediate)
MOV
ADD
CMP
SATADD
SETF
SHL
SHR
SAR
SASF
MOV
ADD
SUB
SUBR
MULH
DIVH
CMP
SATADD
SATSUB
Move
Add
Subtract
Subtract Reverse
Multiply Half-word
Divide Half-word
Compare
Saturated Add
Saturated Subtract
SATSUBR
TST
OR
AND
XOR
NOT
SHL
SHR
Move
Add
Compare
Saturated Add
Set Flag Condition
Shift Logical Left
Shift Logical Right
Shift Arithmetic Right
Shift and Set Flag Condition
(3-operand register)
Function
Shift Arithmetic Right
Byte Swap Half-word
Byte Swap Word
Half-word Swap Word
MUL
Multiply Word
MULU
DIVH
DIV
DIVHU
DIVU
MOVHI
MOVEA
ADDI
MULHI
SATSUBI
ORI
ANDI
XORI
MUL
MULU
JMP
JR
JARL
Bcond
Jump Register
Jump Relative
Jump and Register Link
Branch on Condition Code
171
Function
Bit manipulation
SET1
CLR1
NOT1
TST1
Set Bit
Clear Bit
Not Bit
Test Bit
Special
LDSR
STSR
TRAP
RETI
HALT
DI
EI
NOP
SWITCH
PREPARE
DISPOSE
CALLT
CTRET
172
Instruction
Code
b10 b5
Format
000000
000001
000010
000010
000011
000101
000100
000101
000101
000110
000110
000111
001100
001000
001001
001010
001011
001100
001101
001110
001111
MOV
NOT
DIHV
SWITCH
JMP
SATSUBR
ZXB
SATSUB
SXB
SATADD
ZXH
MULH
SXH
OR
XOR
AND
TST
SUBR
SUB
ADD
CMP
reg1, reg2
reg1, reg2
reg1, reg2
reg1
[reg1]
reg1, reg2
reg1
reg1, reg2
reg1
reg1, reg2
reg1
reg1, reg2
reg1
reg1, reg2
reg1, reg2
reg1, reg2
reg1, reg2
reg1, reg2
reg1, reg2
reg1, reg2
reg1, reg2
010000
010001
01000X
010010
010011
010100
010101
010110
010111
MOV
SATADD
CALLT
ADD
CMP
SHR
SAR
SHL
MULH
imm5, reg2
imm5, reg2
imm6
imm5, reg2
imm5, reg2
imm5, reg2
imm5, reg2
imm5, reg2
imm5, reg2
II
000011
000011
0110XX
0111XX
1000XX
1001XX
1010XX
1010XX
SLD.BU
SLD.HU
SLD.B
SST.B
SLD.H
SST.H
SLD.W
SST.W
IV
1011XX
Bcond
disp9
III
110000
110001
110001
110010
110011
110100
110101
110110
110111
ADDI
MOVEA
MOV
MOVHI
SATSUBI
ORI
XORI
ANDI
MULHI
VI
Remarks
173
Instruction
Code
b10 b5
111000
111001
111010
111010
111011
111011
11110X
111111
LD.B
LD.H
LD.W
ST.B
ST.H
ST.W
LD.BU
LD.HU
Format
VII
11110X
JARL
disp22, reg2
111110
111110
111110
111110
SET1
CLR1
NOT1
TST1
VIII
111111
111111
111111
111111
111111
111111
111111
111111
111111
111111
111111
SETF
LDSR
STSR
SHR
SAR
SHL
SASF
CLR1
NOT1
SET1
TST1
cccc, reg2
reg2, regID
regID, reg2
reg1, reg2
reg1, reg2
reg1, reg2
cccc, reg2
reg2, [reg1]
reg2, [reg1]
reg2, [reg1]
reg2, [reg1]
IX
111111
111111
111111
111111
111111
111111
111111
TRAP
vector
HALT
RETI
DI
EI
CTRET
Undefined instruction
111111
111111
111111
111111
111111
111111
111111
DIVH
DIV
DIVHU
DIVU
MUL
MULU
CMOV
XI
111111
111111
111111
MUL
MULU
CMOV
XII
111111
111111
111111
BSH
BSW
HSW
11001X
11001X
11110X
11110X
DISPOSE
DISPOSE
PREPARE
PREPARE
imm5, list12
imm5, list12 [reg1]
list12, imm5
list12, imm5, sp/imm
XIII
174
Remarks
The opcode map for the instruction code is shown in (a) to (i).
For the operand conventions, refer to Table 5-10 Remark 1 Operand conventions.
Instruction Codes
16-bit instruction format
15
11 10
5 4
11 10
5 4
0 31
27 26
21 20 19 18 17 16
Sub-opcode
(refer to (f), (g), (i))
175
(a) Opcode
Bits 6 and 5
00
01
10
11
Format
Bits 10 to 7
0000
MOV R, r
NOP
0001
NOT
Note 2
SATSUBR
ZXB
JMPNote 4
DIVH
Note 1
SATSUB
Note 4
SLD.BUNote 5
UndefinedNote 3
SLD.HUNote 6
SATADD R, r
MULH
Note 4
Note 4
ZXH
SXH
0010
OR
XOR
AND
TST
0011
SUBR
SUB
ADD R, r
CMP R, r
0100
MOV imm5, r
SATADD imm5, r
ADD imm5, r
CMP imm5, r
II
SAR imm5, r
SHL imm5, r
MULH imm5, r
II
CALLT
0101
SXB
Note 4
I, IV
SWITCH
Note 4
SHR imm5, r
UndefinedNote 4
0110
SLD.B
IV
0111
SST.B
IV
1000
SLD.H
IV
1001
SST.H
IV
1010
SLD.WNote 7
IV
SST.WNote 7
1011
1100
Bcond
ADDI
MOVEA
MOVHI
Note 4
MOV imm32 R
1101
ORI
III
XORI
SATSUBI
DISPOSE
ANDI
VI, XIII
Note 4
MULHI
VI
Note 4
Undefined
1110
LD.B
LD.HNote 8
ST.B
Note 8
ST.W
Bit manipulation 1Note 9
JR/JARL
Note 10
LD.BU
PREPARENote 11
176
VII
Note 8
LD.W
1111
ST.HNote 8
LD.HUNote 10
Note 11
Undefined
Expansion 1Note 12
V, VII,
VIII,
XIII
6.
7.
Refer to (b)
8.
Refer to (c)
9.
Refer to (d)
Bits 10 to 7
0110
SLD.B
0111
SST.B
1000
SLD.H
1001
SST.H
1010
SLD.W
SST.W
Bits 6 and 5
00
LD.B
01
LD.H
10
LD.W
ST.B
11
ST.H
ST.W
SET1
NOT1
CLR 1
TST 1
Bit 15
177
00
01
10
11
Format
0000
SETF
LDSR
STSR
Undefined
IX
0001
SHR
SAR
SHL
Bit
manipulation 2Note 1
IX
0010
TRAP
HALT
RETINote 2
CTRETNote 2
Undefined
EINote 3
DINote 3
Undefined
0011
Undefined
0100
SASF
0101
MUL R, r, w
MULU R, r, wNote 4
MUL imm9, r, w
MULU imm9, r, wNote 4
DIV
DIVUNote 4
XI
DIVH
DIVHUNote 4
0110
CMOV cccc,
imm5, r, w
BSWNote 5
BSHNote 5
HSWNote 5
CMOV cccc,
R, r, w
Undefined
XI, XII
Illegal Opcode
0111
to
1111
Notes 1.
Refer to (f)
2.
Refer to (g)
3.
Refer to (h)
4.
If bit17 = 1
5.
Refer to (i)
(g)
Bit 17
Bit 18
Bit 18
0
SET1
NOT1
RETI
Undefined
CLR1
TST1
CTRET
000
001
010
011
100
Bits 15 and 14
00
DI
01
10
11
178
Undefined
Undefined
EI
Undefined
Undefined
101
110
111
(i)
Bit 18
0
BSW
BSH
HSW
Undefined
179
The instruction codes of the V850E CPU are upwardly compatible with the instruction codes of the V850 CPU at
the object code level. In the case of the V850E CPU, instructions that even if executed have no meaning in the case
of the V850 CPU (mainly instructions that write to the r0 register) are extended as additional instructions.
The following table shows the V850 CPU instructions corresponding to the instruction codes added in the V850E
CPU. Refer to this table when switching from products that incorporate the V850 CPU to products that incorporate
the V850E CPU.
Table D-1. Instructions Added to V850E CPU and V850 CPU Instructions with Same Instruction Code (1/2)
Instructions Added in V850E CPU
CALLT imm6
SWITCH reg1
DIVH reg1, r0
SXB reg1
SATSUB reg1, r0
SXH reg1
MULH reg1, r0
ZXB reg1
SATSUBR reg1, r0
ZXH reg1
SATADD reg1, r0
(RFU)
MULH imm5, r0
(RFU)
Illegal instruction
180
Table D-1. Instructions Added to V850E CPU and V850 CPU Instructions with Same Instruction Code (2/2)
Instructions Added in V850E CPU
181
APPENDIX E INDEX
[A]
Add (ADD) .............................................................. 51
Add immediate (ADDI) ........................................... 52
Address space ....................................................... 31
Addressing mode ................................................... 33
And (AND) ........................................................ 48, 53
AND immediate (ANDI) ......................................... 54
Arithmetic operation instruction ...................... 43, 147
arithmetically shift right by ...................................... 48
[B]
Based addressing .................................................. 36
bbb ......................................................................... 49
BC .......................................................................... 56
BE .......................................................................... 56
BGE ....................................................................... 56
BGT ........................................................................ 56
BH .......................................................................... 56
Bit ..................................................................... 29, 30
Bit addressing ........................................................ 38
Bit manipulation instruction ............................ 46, 151
bit#3 ....................................................................... 47
BL ........................................................................... 56
BLE ........................................................................ 56
BLT ........................................................................ 56
BN .......................................................................... 56
BNC ....................................................................... 56
BNE ........................................................................ 56
BNH ....................................................................... 56
BNL ........................................................................ 56
BNV ........................................................................ 56
BNZ ........................................................................ 56
BP .......................................................................... 56
BR ......................................................................... 56
Branch instruction .......................................... 45, 149
Branch on condition code (Bcond) ......................... 55
BSA ........................................................................ 56
BV .......................................................................... 56
Byte .................................................................. 28, 48
Byte swap half-word (BSH) .................................... 57
Byte swap word (BSW) .......................................... 58
BZ .......................................................................... 56
[C]
Call with table look up (CALLT) ............................. 59
CALLT base pointer (CTBP) ............................ 26, 27
CALLT caller status saving register .................. 26, 27
cccc .................................................................. 47, 49
Clear bit (CLR1) .................................................... 60
Compare (CMP) ..................................................... 62
Conditional branch instruction .............................. 149
Conditional move (CMOV) ..................................... 61
CPU configuration .................................................. 17
182
APPENDIX E INDEX
[L]
L ............................................................................. 49
list ........................................................................ 47
Load (LD) ............................................................... 78
Load instructions .................................................. 146
Load to system register (LDSR) ............................. 80
Load/store instructions ........................................... 43
Load-memory (a, b) ............................................... 48
Load-memory-bit (a, b) ......................................... 48
Logical operation instruction .......................... 44, 148
logically shift left by ................................................ 48
logically shift right by .............................................. 48
[R]
R ............................................................................ 49
r ............................................................................. 49
r0 to r31 ................................................................. 22
reg1 ....................................................................... 47
reg2 ....................................................................... 47
reg3 ....................................................................... 47
regID ...................................................................... 47
Register addressing ....................................... 35, 36
Register indirect branch instruction ..................... 150
Relative addressing ............................................... 33
Reset ................................................................... 140
Restoring from interrupt/exception ...................... 139
Result .................................................................... 48
Return from CALLT (CTRET) ................................ 63
Return from trap or interrupt (RETI) ...................... 95
[M]
Maskable interrupt ............................................... 134
Memory map .......................................................... 32
Move (MOV) ........................................................... 81
Move effective address (MOVEA) .......................... 82
[S]
S ............................................................................
SAT .......................................................................
Saturated (n) ........................................................
Saturation add (SATADD) .....................................
25
25
48
99
183
APPENDIX E INDEX
150
150
122
123
[U]
Unconditional branch instruction .......................... 149
Unsigned integer .................................................... 30
[V]
Vector ..................................................................... 47
[W]
w ............................................................................ 49
Word (WORD) .................................................. 29, 48
[Z]
Z ............................................................................. 25
Zero extend byte (ZXB) ........................................ 126
zero-extend half-word (ZXH)................................. 127
Zero-extend (n) ...................................................... 48
184
The history of revisions up to this edition is shown below. Applied to: indicates the chapters to which the revision
was applied.
Edition
5th edition
Contents
Applied to:
Throughout
CHAPTER 1 INTRODUCTION
CHAPTER 5 INSTRUCTIONS
CHAPTER 8 PIPELINE
APPENDIX C INSTRUCTION
OPCODE MAP
CHAPTER 5 INSTRUCTIONS
APPENDIX F REVISION
HISTORY
185