Renesas Technology Corp. puts the maximum effort into making semiconductor products
better and more reliable, but there is always the possibility that trouble may occur with
them. Trouble with semiconductors may lead to personal injury, fire or property damage.
Remember to give due consideration to safety when making your circuit designs, with appropriate measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of nonflammable material or (iii) prevention against any malfunction or mishap.
Notes regarding these materials
1.
These materials are intended as a reference to assist our customers in the selection of the
Renesas Technology Corp. product best suited to the customer's application; they do not
convey any license under any intellectual property rights, or any other rights, belonging to
Renesas Technology Corp. or a third party.
2.
Renesas Technology Corp. assumes no responsibility for any damage, or infringement of
any third-party's rights, originating in the use of any product data, diagrams, charts, programs, algorithms, or circuit application examples contained in these materials.
3.
All information contained in these materials, including product data, diagrams, charts, programs and algorithms represents information on products at the time of publication of these
materials, and are subject to change by Renesas Technology Corp. without notice due to
product improvements or other reasons. It is therefore recommended that customers contact Renesas Technology Corp. or an authorized Renesas Technology Corp. product distributor for the latest product information before purchasing a product listed herein.
The information described here may contain technical inaccuracies or typographical errors.
Renesas Technology Corp. assumes no responsibility for any damage, liability, or other
loss rising from these inaccuracies or errors.
Please also pay attention to information published by Renesas Technology Corp. by various means, including the Renesas Technology Corp. Semiconductor home page (http://
www.renesas.com).
4.
When using any or all of the information contained in these materials, including product
data, diagrams, charts, programs, and algorithms, please be sure to evaluate all information as a total system before making a final decision on the applicability of the information
and products. Renesas Technology Corp. assumes no responsibility for any damage, liability or other loss resulting from the information contained herein.
5.
Renesas Technology Corp. semiconductors are not designed or manufactured for use in a
device or system that is used under circumstances in which human life is potentially at
stake. Please contact Renesas Technology Corp. or an authorized Renesas Technology
Corp. product distributor when considering the use of a product contained herein for any
specific purposes, such as apparatus or systems for transportation, vehicular, medical,
aerospace, nuclear, or undersea repeater use.
6.
The prior written approval of Renesas Technology Corp. is necessary to reprint or reproduce in whole or in part these materials.
7.
If these products or technologies are subject to the Japanese export control restrictions,
they must be exported under a license from the Japanese government and cannot be imported into a country other than the approved destination.
Any diversion or reexport contrary to the export control laws and regulations of Japan and/
or the country of destination is prohibited.
8.
Please contact Renesas Technology Corp. for further details on these materials or the
products contained therein.
Page 3
Using This Manual
This software manual is written for the R8C/Tiny Series. It applies to all microcomputers
integrating the R8C/Tiny Series CPU core.
The reader of this manual is assumed to have a basic knowledge of electrical circuits, logic
circuits, and microcomputers.
This manual consists of six chapters. The chapters and the subjects they cover are listed
below.
• Outline of the R8C/Tiny Series and its features ...............................Chapter 1, “Overview”
•
Operation of addressing modes.......................................................
How to calculate the number of cycles ................
•
This manual also contains quick reference sections immediately following the table of contents. These quick reference sections can be used to rapidly find the pages referring to
specific functions, instruction codes, and cycle counts.
Chapter
Chapter
4, “Instruction Codes/Number of Cycles”
6, “Calculating the Number of Cycles”
Chapter
2, “Addressing Modes”
3, “Functions”
• Alphabetic listing by mnemonic................................Quick Reference in Alphabetic Order
• Listing of mnemonics by function.......................................... Quick Reference by Function
• Listing of addressing modes by mnemonic ...........Quick Reference by Addressing Mode
A Q&A table, symbols, a glossary, and an index are appended at the end of this manual.
Page 4
M16C Family Documents
The following documents were prepared for the M16C family.
(1)
DocumentContents
Short SheetHardware overview
Data SheetHardware overview and electrical characteristics
Hardware ManualHardware specifications (pin assignments, memory maps, periph-
eral specifications, electrical characteristics, timing charts).
*Refer to the application note for how to use peripheral functions.
Software ManualDetailed description of assembly instructions and microcomputer
performance of each instruction
Application Note• Usage and application examples of peripheral functions
• Sample programs
• Introduction to the basic functions in the M16C family
• Programming method with Assembly and C languages
RENESAS TECHNICALPreliminary report about the specification of a product, a document, etc.
UPDATE
NOTES:
1. Before using this material, please visit the our website to verify that this is the most updated
document available.
MOVTransfer90193
MOVATransfer effective address92200
MOVDirTransfer 4-bit data93201
POPRestore register/memory101211
POPMRestore multiple registers103213
PUSHSave register/memory/immediate data104214
PUSHASave effective address105216
PUSHMSave multiple registers107217
LDETransfer from extended data area87191
STETransfer to extended data area123233
STNZConditional transfer124235
STZConditional transfer125235
STZXConditional transfer126236
XCHGExchange132242
BANDLogically AND bits47150
BCLRClear bit48150
BM
Cnd
BNANDLogically AND inverted bits50153
BNORLogically OR inverted bits51154
BNOTInvert bit52154
BNTSTTest inverted bit53155
BNXORExclusive OR inverted bits54156
BORLogically OR bits55156
BSETSet bit57157
BTSTTest bit58158
BTSTCTest bit and clear59159
BTSTSTest bit and set60160
BXORExclusive OR bits61160
ROLCRotate left with carry110218
RORCRotate right with carry111219
ROTRotate112220
SHAShift arithmetic116215
SHLShift logical117228
ABSAbsolute value39138
ADCAdd with carry40138
ADCFAdd carry flag41140
ADDAdd without carry42140
CMPCompare62161
DADCDecimal add with carry64165
Conditional bit transfer49152
Description
Page No. for
Function
Page No. for
Instruction Code
/No. of Cycles
Quick Reference-3
Page 11
Quick Reference by Function
Function
Arithmetic
Logical
Jump
String
Other
Mnemonic
DADDDecimal add without carry65167
DECDecrement66169
DIVSigned divide67170
DIVUUnsigned divide68171
DIVXSigned divide69172
DSBBDecimal subtract with borrow70173
DSUBDecimal subtract without borrow71175
EXTSExtend sign74178
INCIncrement77180
MULSigned multiply94203
MULUUnsigned multiply95205
NEGComplement of two96207
RMPACalculate sum-of-products109218
SBBSubtract with borrow114222
SUBSubtract without borrow127236
ANDLogical AND45147
NOTInvert all bits98208
ORLogical OR99209
TSTTest129239
XORExclusive OR133243
ADJNZAdd and conditional jump44146
SBJNZSubtract and conditional jump115224
JCndJump on condition80182
JMPUnconditional jump81184
JMPIJump indirect82185
JSRSubroutine call83187
JSRIIndirect subroutine call84188
RTSReturn from subroutine113221
SMOVBTransfer string backward118230
SMOVFTransfer string forward119231
SSTRStore string120231
BRKDebug interrupt56157
ENTERBuild stack frame72177
EXITDDeallocate stack frame73178
FCLRClear flag register bit75179
FSETSet flag register bit76180
INTInterrupt by INT instruction78181
INTOInterrupt on overflow79182
LDCTransfer to control register85189
LDCTXRestore context86189
LDINTBTransfer to INTB register88192
Description
Page No. for
Function
Page No. for
Instruction Code
/No. of Cycles
Quick Reference-4
Page 12
Quick Reference by Function
Function
OtherLDIPLSet interrupt enable level89193
Mnemonic
NOPNo operation97207
POPCRestore control register102213
PUSHCSave control register106216
REITReturn from interrupt108216
STCTransfer from control register121232
STCTXSave context122233
UNDInterrupt for undefined instruction130241
WAITWait131241
Description
Page No. for
Function
Page No. for
Instruction Code
/No. of Cycles
Quick Reference-5
Page 13
Quick Reference by Addressing Mode (General Instruction Addressing)
Mnemonic
ABS
ADC
ADCF
*1
ADD
ADJNZ
*1
AND
CMP
DADC
DADD
DEC
R0L/R0
R0H/R1
R1L/R2
R1H/R3
Addressing Mode
An
[An]
dsp:8[An]
dsp:8[SB/FB]
dsp:16[An]
dsp:16[SB]
abs16
#IMM8
#IMM16
#IMM20
Page No. for
Function
#IMM
39
40
41
42
44
45
62
64
65
66
Page No. for
Instruction
Code
/No. of Cycles
138
138
140
140
146
147
161
165
167
169
DIV
DIVU
DIVX
DSBB
DSUB
ENTER
EXTS
INC *3
*2
*4
INT
*1
JMPI
*1
JSRI
*1
LDC
*1
LDE
LDINTB
LDIPL
*1 Has special instruction addressing.
*2 Only R1L can be selected.
*3 Only R0L can be selected.
*4 Only R0H can be selected.
Quick Reference by Addressing Mode (General Instruction Addressing)
Mnemonic
STZX
SUB
TST
XCHG
XOR
R0L/R0
R0H/R1
R1L/R2
R1H/R3
Addressing Mode
An
[An]
dsp:8[An]
dsp:8[SB/FB]
dsp:16[An]
dsp:16[SB]
abs16
#IMM8
#IMM16
#IMM20
Page No. for
Function
#IMM
126
127
129
132
133
Page No. for
Instruction
Code
/No. of Cycles
236
236
239
242
243
Quick Reference-8
Page 16
Quick Reference by Addressing Mode (Special Instruction Addressing)
Mnemonic
*1
ADD
ADJNZ
*1
JCnd
JMP
*1
JMPI
JSR
*1
JSRI
*1
LDC
LDCTX
*1
LDE
LDINTB
*1
MOV
dsp:20[A0]
dsp:20[A1]
abs20
Addressing Mode
R2R0/R3R1
A1A0
[A1A0]
dsp:8[SP]
label
SB/FB
ISP/USP
FLG
INTBL/INTBH
*2
Page No. for
Function
PC
42
44
80
81
82
83
84
85
86
87
88
90
Page No. for
Instruction
Code
/No. of Cycles
140
146
182
184
185
187
188
189
189
191
192
193
POPC
POPM
PUSHC
PUSHM
SBJNZ
*1
SHA
*1
SHL
*1
STC
STCTX
*1
STE
*1
*1
*1
*1
102
103
106
107
115
116
117
121
122
123
*1 Has general instruction addressing.
*2 INTBL and INTBH can be set simultaneously when using the LDINTB instruction.
213
213
216
217
224
225
228
232
233
233
Quick Reference-9
Page 17
Quick Reference by Addressing Mode (Bit Instruction Addressing)
Mnemonic
BAND
BCLR
BM
Cnd
BNAND
BNOR
BNOT
BNTST
BNXOR
BOR
bit,Rn
Addressing Mode
bit,An
[An]
base:8[An]
bit,base:8[SB/FB]
base:16[An]
bit,base:16[SB]
bit,base:16
Page No. for
Function
bit,base:11
U/I/O/B/S/Z/D/C
47
48
49
50
21
52
53
54
55
Page No. for
Instruction
Code
/No. of Cycles
150
150
152
153
154
154
155
156
156
BSET
BTST
BTSTC
BTSTS
BXOR
FCLR
FSET
57
58
59
60
61
75
76
157
158
159
160
160
179
180
Quick Reference-10
Page 18
This page intentionally left blank.
Quick Reference-11
Page 19
Chapter 1
Overview
1.1 Features of R8C/Tiny Series
1.2 Address Space
1.3 Register Configuration
1.4 Flag Register (FLG)
1.5 Register Banks
1.6 Internal State after Reset is Cleared
1.7 Data Types
1.8 Data Arrangement
1.9 Instruction Formats
1.10 Vector Tables
Page 20
Chapter 1 Overview
1.1 Features of R8C/Tiny Series
1.1 Features of R8C/Tiny Series
The R8C/Tiny Series of single-chip microcomputers was developed for embedded applications.
The R8C/Tiny Series supports instructions tailored for the C language, with frequently used instructions
implemented in one-byte op-code. It thus allows development of efficient programs with reduced memory
requirements when using either assembly language or C. Furthermore, some instructions can be executed
in a single clock cycle, enabling fast arithmetic processing.
The instruction set comprises 89 discrete instructions matched to the R8C’s many addressing modes. This
powerful instruction set provides support for register-register, register-memory, and memory-memory operations, as well as arithmetic/logic operations using single-bit and 4-bit data.
Some R8C/Tiny Series models incorporate an on-chip multiplier, allowing for high-speed computation.
1.1.1 Features of R8C/Tiny Series
●Register configuration
Data registers:Four 16-bit registers (of which two can be used as 8-bit registers)
Address registers: Two 16-bit registers
Base registers:Two 16-bit registers
●Versatile instruction set
Instructions suited to C language (stack frame manipulation): ENTER, EXITD, etc.
Instructions that do not discriminate by register or memory area MOV, ADD, SUB, etc.
Powerful bit manipulation instructions: BNOT, BTST, BSET, etc.
4-bit transfer instructions: MOVLL, MOVHL, etc.
Frequently used 1-byte instructions: MOV, ADD, SUB, JMP, etc.
High-speed 1-cycle instructions: MOV, ADD, SUB, etc.
●Fast instruction execution time
Minimum 1-cycle instructions: Of 89 instructions, 20 are 1-cycle instructions. (Approximately 75% of
instructions execute in five cycles or fewer.)
Rev.2.00 Oct 17, 2005 page 2 of 263
REJ09B0001-0200
Page 21
Chapter 1 Overview
1.2 Address Space
1.2 Address Space
Figure 1.2.1 shows the address space.
Addresses 0000016 through 002FF16 make up an SFR (special function register) area. In some models in
the R8C/Tiny Series, the SFR area extends from 002FF16 to lower addresses.
Addresses from 0040016 and below make up the memory area. In some models in the R8C/Tiny Series, the
RAM area extends from address 0040016 to higher addresses, and the ROM area extends from 0FFFF16 to
lower addresses. Addresses 0FFDC16 through 0FFFF16 make up a fixed vector area.
0000016
002FF16
0040016
0FFDC16
0FFFF16
SFR area
Internal RAM area
Internal ROM area
Fixed vector area
The SFR area of some
models extends to
lower-address locations.
The RAM area of some
models extends to
higher-address locations.
The ROM area of some
models extends to
lower-address locations.
FFFFF16
Figure 1.2.1 Address Space
Rev.2.00 Oct 17, 2005 page 3 of 263
REJ09B0001-0200
Extention area
Page 22
Chapter 1 Overview
A
1.3 Register Configuration
1.3 Register Configuration
The central processing unit (CPU) contains the 13 registers shown in figure 1.3.1. Of these registers, R0,
R1, R2, R3, A0, A1, and FB each consist of two sets of registers configured as two register banks.
b31
R2
R3
b15
R0H (High-order of R0)
R1H (High-order of R1)
b19
b15
INTBH
INTBH is the upper 4 bits of INTB.
INTBL is the lower 16 bits of INTB.
b19
b15
b15
b15
IPL
b8 b7 b0
R0L (Low-order of R0)
R1L (Low-order of R1)
R2
R3
A0
A1
FB
INTBL
PC
USP
ISP
SB
FLG
b7 b8
Data register*
Address register*
Frame base register*
b0
Interrupt table register
b0
Program counter
b0
User stack pointer
Interrupt stack pointer
Static base register
b0
Flag register
b0
CDZSBOIU
Carry flag
Debug flag
Zero flag
Sign flag
Register bank select flag
Overflow flag
Interrupt enable flag
Stack pointer select flag
Reserved area
Processor interrupt priority level
Reserved area
Note: * These registers configure register banks.This register
bank consists of two sets.
Figure 1.3.1 CPU Register Configuration
1.3.1 Data Registers (R0, R0H, R0L, R1, R1H, R1L, R2, and R3)
The data registers (R0, R1, R2, and R3) each consist of 16 bits and are used primarily for transfers and
arithmetic/logic operations.
Registers R0 and R1 can be divided into separate high-order (R0H, R1H) and low-order (R0L, R1L)
parts for use as 8-bit data registers. For some instructions, moreover, R2 and R0 or R3 and R1 can be
combined to configure a 32-bit data register (R2R0 or R3R1).
Rev.2.00 Oct 17, 2005 page 4 of 263
REJ09B0001-0200
Page 23
Chapter 1 Overview
1.3 Register Configuration
1.3.2 Address Registers (A0 and A1)
The address registers (A0 and A1) are 16-bit registers with functions similar to those of the data registers. These registers are used for address register-based indirect addressing and address registerbased relative addressing.
For some instructions, registers A1 and A0 can be combined to configure a 32-bit address register
(A1A0).
1.3.3 Frame Base Register (FB)
The frame base register (FB) is a 16-bit register used for FB-based relative addressing.
1.3.4 Program Counter (PC)
The program counter (PC) is a 20-bit register that indicates the address of the instruction to be executed
next.
1.3.5 Interrupt Table Register (INTB)
The interrupt table register (INTB) is a 20-bit register that indicates the initial address of the interrupt
vector table.
1.3.6 User Stack Pointer (USP) and Interrupt Stack Pointer (ISP)
There are two types of stack pointers: a user stack pointer (USP) and an interrupt stack pointer (ISP).
Each consists of 16 bits.
The stack pointer (USP/ISP) to be used can be switched with the stack pointer select flag (U flag).
The stack pointer select flag (U flag) is bit 7 of the flag register (FLG).
1.3.7 Static Base Register (SB)
The static base register (SB) is a 16-bit register used for SB-based relative addressing.
1.3.8 Flag Register (FLG)
The flag register (FLG) is an 11-bit register used as flags in one-bit units. For details on the functions of
the flags, see Section 1.4, “Flag Register (FLG).”
Rev.2.00 Oct 17, 2005 page 5 of 263
REJ09B0001-0200
Page 24
Chapter 1 Overview
1.4 Flag Register (FLG)
1.4 Flag Register (FLG)
Figure 1.4.1 shows the configuration of the flag register (FLG). The function of each flag is described
below.
1.4.1 Bit 0: Carry Flag (C Flag)
This flag holds bits carried, borrowed, or shifted-out by the arithmetic/logic unit.
1.4.2 Bit 1: Debug Flag (D Flag)
This flag enables a single-step interrupt.
When this flag is set to 1, a single-step interrupt is generated after an instruction is executed. When the
interrupt is acknowledged, the flag is cleared to 0.
1.4.3 Bit 2: Zero Flag (Z Flag)
This flag is set to 1 when an arithmetic operation results in 0; otherwise, its value is 0.
1.4.4 Bit 3: Sign Flag (S Flag)
This flag is set to 1 when an arithmetic operation results in a negative value; otherwise, its value is 0.
1.4.5 Bit 4: Register Bank Select Flag (B Flag)
This flag selects a register bank. If it is set to 0, register bank 0 is selected; if it is set to 1, register bank
1 is selected.
1.4.6 Bit 5: Overflow Flag (O Flag)
This flag is set to 1 when an arithmetic operation results in an overflow.
1.4.7 Bit 6: Interrupt Enable Flag (I Flag)
This flag enables a maskable interrupt.
When this flag is set to 0, the interrupt is disabled; when it is set to 1, the interrupt is enabled. When the
interrupt is acknowledged, the flag is cleared to 0.
1.4.8 Bit 7: Stack Pointer Select Flag (U Flag)
When this flag is set to 0, the interrupt stack pointer (ISP) is selected; when it is set to 1, the user stack
pointer (USP) is selected.
This flag is cleared to 0 when a hardware interrupt is acknowledged or an INT instruction is executed for
software interrupt numbers 0 to 31.
1.4.9 Bits 8 to 11: Reserved
Rev.2.00 Oct 17, 2005 page 6 of 263
REJ09B0001-0200
Page 25
Chapter 1 Overview
1.4 Flag Register (FLG)
1.4.10 Bits 12 to 14: Processor Interrupt Priority Level (IPL)
The processor interrupt priority level (IPL) consists of three bits, enabling specification of eight processor interrupt priority levels from level 0 to level 7. If a requested interrupt’s priority level is higher than the
processor interrupt priority level (IPL), the interrupt is enabled.
1.4.11 Bit 15: Reserved
b15b0
IPLUIOBSZDC
Flag register (FLG)
Carry flag
Debug flag
Zero flag
Sign flag
Figure 1.4.1 Configuration of Flag Register (FLG)
Register bank select flag
Overflow flag
Interrupt enable flag
Stack pointer select flag
Reserved area
Processor interrupt priority level
Reserved area
Rev.2.00 Oct 17, 2005 page 7 of 263
REJ09B0001-0200
Page 26
Chapter 1 Overview
1.5 Register Banks
1.5 Register Banks
The R8C/Tiny has two register banks, each comprising data registers (R0, R1, R2, and R3), address registers (A0 and A1), and a frame base register (FB). These two register banks are switched by the register
bank select flag (B flag) in the flag register (FLG).
Figure 1.5.1 shows the configuration of the register banks.
Register bank 0 (B flag = 0) Register bank 1 (B flag = 1)
b15b8b7b0
R0HL
R1HL
R2
R3
A0
A1
FB
Figure 1.5.1 Configuration of Register Banks
b15b8b7b0
R0HL
R1HL
R2
R3
A0
A1
FB
Rev.2.00 Oct 17, 2005 page 8 of 263
REJ09B0001-0200
Page 27
Chapter 1 Overview
1.6 Internal State after Reset is Cleared
The contents of each register after a reset is cleared are as follows.
• Data registers (R0, R1, R2, and R3): 000016
• Address registers (A0 and A1): 000016
• Frame base register (FB): 000016
• Interrupt table register (INTB): 0000016
• User stack pointer (USP): 000016
• Interrupt stack pointer (ISP): 000016
• Static base register (SB): 000016
• Flag register (FLG): 000016
1.6 Internal State after Reset is Cleared
Rev.2.00 Oct 17, 2005 page 9 of 263
REJ09B0001-0200
Page 28
Chapter 1 Overview
1.7 Data Types
1.7 Data Types
There are four data types: integer, decimal, bit, and string.
1.7.1 Integer
An integer can be signed or unsigned. A negative value of a signed integer is represented by two’s
complement.
b7b0
Signed byte (8 bit) integer
Unsigned byte (8 bit) integer
Signed word (16 bit) integer
Unsigned word (16 bit) integer
Signed long word (32 bit) integer
Unsigned long word (32 bit) integer
b15b0
S
b15b0
b31b0
S
b31b0
S
b7b0
S: Sign bit
Figure 1.7.1 Integer Data
Rev.2.00 Oct 17, 2005 page 10 of 263
REJ09B0001-0200
Page 29
Chapter 1 Overview
1.7.2 Decimal
The decimal data type is used by the DADC, DADD, DSBB, and DSUB instructions.
1.7 Data Types
Pack format
(2 digits)
Pack format
(4 digits)
Figure 1.7.2 Decimal Data
b7b0
b15b0
Rev.2.00 Oct 17, 2005 page 11 of 263
REJ09B0001-0200
Page 30
Chapter 1 Overview
1.7 Data Types
1.7.3 Bits
●Register bits
Figure 1.7.3 shows register bit specification.
Register bits can be specified by register directly (bit, Rn or bit, An). Use bit, Rn to specify a bit in a
data register (Rn); use bit, An to specify a bit in an address register (An).
The bits in each register are assigned bit numbers from 0 to 15, from LSB to MSB. Therefore, bit, Rn
and bit, An can be used to specify a bit number from 0 to 15.
b15b0
bit,Rn
(bit: 0 to 15, n: 0 to 3)
Rn
b15b0
bit,An
(bit: 0 to 15, n: 0 to 1)
An
Figure 1.7.3 Register Bit Specification
●Memory bits
Figure 1.7.4 shows the addressing modes used for memory bit specification. Table 1.7.1 lists the address range in which bits can be specified in each addressing mode. Be sure to observe the address
range in Table 1.7.1 when specifying memory bits.
Addressing modes
Absolute addressing
SB-based relative
addressing
FB-based relative
addressing
Address register-based indirect
addressing
Address register-based relative
addressing
bit,base:8
bit,base:16
bit,base:16
bit,base:8[SB]
bit,base:11[SB]
bit,base:16[SB]
bit,base:8[FB]
[An]
base:8[An]
base:16[An]
Figure 1.7.4 Addressing Modes Used for Memory Bit Specification
Table 1.7.1 Bit Specification Address Range
AddressingSpecification range
Lower Limit (Address) Upper Limit (Address)
Remarks
bit,base:16000001601FFF16
bit,base:8[SB][SB][SB]+0001F16The access range is 0000016 to 0FFFF16.
bit,base:11[SB][SB][SB]+000FF16The access range is 0000016 to 0FFFF16.
bit,base:16[SB][SB][SB]+01FFF16The access range is 0000016 to 0FFFF16.
bit,base:8[FB][FB]–0001016[FB]+0000F16The access range is 0000016 to 0FFFF16.
[An]000001601FFF16
base:8[An]base:8base:8+01FFF16The access range is 0000016 to 020FE16.
base:16[An]base:16base:16+01FFF16The access range is 0000016 to 0FFFF16.
Rev.2.00 Oct 17, 2005 page 12 of 263
REJ09B0001-0200
Page 31
Chapter 1 Overview
1.7 Data Types
(1) Bit Specification by Bit, Base
Figure 1.7.5 shows the relationship between the memory map and the bit map.
Memory bits can be handled as an array of consecutive bits. Bits can be specified by a combination of
bit and base. Using bit 0 of the address that is set in base as the reference (= 0), set the desired bit
position in bit. Figure 1.7.6 shows examples of how to specify bit 2 of address 0000A16.
Address
b7b0
0
n-1
n
n+1
nÅ{1nnÅ|10
n+1 n n–1
b7b0b7b0b7b0b7b0
Memory map
Bit map
Figure 1.7.5 Relationship between Memory Map and Bit Map
Address 0000A16
b7b2 b0
BSET2,AH;
Address 0000916
b15b10 b8b7b0
BSET10,9H;
Address 0000816
b23b18 b16b15b8b7b0
BSET18,8H;
b87b82 b80b79b72b7b0
BSET82,0H;
Address 00000
16
These specification examples all
specify bit 2 of
address 0000A
16.
Figure 1.7.6 Examples of How to Specify Bit 2 of Address 0000A16
Rev.2.00 Oct 17, 2005 page 13 of 263
REJ09B0001-0200
Page 32
Chapter 1 Overview
1.7 Data Types
(2) SB/FB Relative Bit Specification
For SB/FB-based relative addressing, use bit 0 of the address that is the sum of the address set in
static base register (SB) or frame base register (FB) plus the address set in base as the reference
(= 0), and set the desired bit position in bit.
(3) Address Register Indirect/Relative Bit Specification
For address register-based indirect addressing, use bit 0 of address 0000016 as the reference (= 0)
and set the desired bit position in the address register (An).
For address register-based relative addressing, use bit 0 of the address set in base as the reference
(= 0) and set the desired bit position in the address register (An).
Rev.2.00 Oct 17, 2005 page 14 of 263
REJ09B0001-0200
Page 33
Chapter 1 Overview
1.7 Data Types
1.7.4 String
String data consists of a given length of consecutive byte (8-bit) or word (16-bit) data.
This data type can be used in three string instructions: character string backward transfer (SMOVB
instruction), character string forward transfer (SMOVF instruction), and specified area initialize (SSTR
instruction).
Byte (8-bit) dataWord (16-bit) data
b7b0
b7b0
b7b0
Figure 1.7.7 String Data
b15b0
b15b0
•
•
•
•
b15b0
•
•
•
•
Rev.2.00 Oct 17, 2005 page 15 of 263
REJ09B0001-0200
Page 34
Chapter 1 Overview
1.8 Data Arrangement
1.8.1 Data Arrangement in Register
Figure 1.8.1 shows the relationship between a register’s data size and bit numbers.
Nibble (4-bit) data
Byte (8-bit) data
b15b0
Word (16-bit) data
b31b0
Long word (32-bit) data
MSBLSB
1.8 Data Arrangement
b3b0
b7b0
Figure 1.8.1 Data Arrangement in Register
Rev.2.00 Oct 17, 2005 page 16 of 263
REJ09B0001-0200
Page 35
Chapter 1 Overview
1.8 Data Arrangement
1.8.2 Data Arrangement in Memory
Figure 1.8.2 shows the data arrangement in memory. Figure 1.8.3 shows some operation examples.
b7b0
NDATA
N+1
N+2
N+3
Byte (8-bit) data
b7b0
NDATA(L)
N+1DATA(M)
N+2DATA(H)
N+3
20-bit (Address) data
Figure 1.8.2 Data Arrangement in Memory
b7b0
NDATA(L)
N+1DATA(H)
N+2
N+3
Word (16-bit) data
b7b0
NDATA(LL)
N+1DATA(LH)
N+2DATA(HL)
N+3DATA(HH)
Long Word (32-bit) data
MOV.BN,R0H
b7b0
NDATA
N+1
N+2
N+3
Byte (8-bit) data
MOV.WN,R0
b7b0
NDATA(L)
N+1DATA(H)
N+2
N+3
Word (16-bit) data
Figure 1.8.3 Operation Examples
R0
R0
Does not change.
b15b0
DATA
HL
b15b0
DATA(H)DATA(L)
HL
Rev.2.00 Oct 17, 2005 page 17 of 263
REJ09B0001-0200
Page 36
Chapter 1 Overview
1.9 Instruction Formats
1.9 Instruction Formats
The instruction formats can be classified into four types: generic, quick, short, and zero. The number of
instruction bytes that can be chosen by a given format is least for the zero format, and increases successively for the short, quick, and generic formats, in that order.
The features of each format are described below.
1.9.1 Generic Format (:G)
The op-code in this format comprises two bytes. This op-code contains information on the operation
and the src*1 and dest*2 addressing modes.
The instruction code is composed of op-code (2 bytes), src code (0 to 3 bytes), and dest code (0 to 3
bytes).
1.9.2 Quick Format (:Q)
The op-code in this format comprises two bytes. This op-code contains information on the operation
and the immediate data and dest addressing modes. Note, however, that the immediate data in the opcode is a numeric value that can be expressed as -7 to +8 or -8 to +7 (depending on the instruction).
The instruction code is composed of op-code (2 bytes) containing immediate data and dest code (0 to 2
bytes).
1.9.3 Short Format (:S)
The op-code in this format comprises one byte. This op-code contains information on the operation and
the src and dest addressing modes. Note, however, that the usable addressing modes are limited.
The instruction code is composed of op-code (1 byte), src code (0 to 2 bytes), and dest code (0 to 2
bytes).
1.9.4 Zero Format (:Z)
The op-code in this format comprises one byte. This op-code contains information on the operation
(plus immediate data) and dest addressing modes. Note, however, that the immediate data is fixed at 0,
and that the usable addressing modes are limited.
The instruction code is composed of op-code (1 byte) and dest code (0 to 2 bytes).
*1 src is an abbreviation of “source.”
*2 dest is an abbreviation of “destination.”
Rev.2.00 Oct 17, 2005 page 18 of 263
REJ09B0001-0200
Page 37
Chapter 1 Overview
1.10 Vector Tables
1.10 Vector Tables
Interrupt vector tables are the only vector tables. There are two types of interrupt vector tables: fixed and
variable.
1.10.1 Fixed Vector Tables
A fixed vector table is an address-fixed vector table. Part of the interrupt vector table is allocated to
addresses 0FFDC16 through 0FFFF16. Figure 1.10.1 shows a fixed vector table.
Interrupt vector tables are composed of four bytes per table. Each vector table must contain the interrupt handler routine’s entry address.
Rev.2.00 Oct 17, 2005 page 19 of 263
REJ09B0001-0200
Page 38
Chapter 1 Overview
1.10 Vector Tables
1.10.2 Variable Vector Tables
A variable vector table is an address-variable vector table. Specifically, this type of vector table is a 256byte interrupt vector table that uses the value indicated by the interrupt table register (INTB) as the entry
address (IntBase). Figure 1.10.2 shows a variable vector table.
Variable vector tables are composed of four bytes per table. Each vector table must contain the interrupt handler routine’s entry address.
Each vector table has software interrupt numbers (0 to 63), which are used by the INT instruction.
Interrupts for the on-chip peripheral functions of each M16C model are allocated to software interrupt
numbers 0 through 31.
b19b0
INTBIntBase
IntBase+4
IntBase+8
IntBase+252
Figure 1.10.2 Variable Vector Table
0
1
31
32
33
63
Vectors accommodat-
ing peripheral I/O
interrupts
Software interrupt
numbers
Rev.2.00 Oct 17, 2005 page 20 of 263
REJ09B0001-0200
Page 39
Addressing Modes
2.1 Addressing Modes
2.2 Guide to This Chapter
2.3 General Instruction Addressing
2.4 Special Instruction Addressing
2.5 Bit Instruction Addressing
Chapter 2
Page 40
Chapter 2 Addressing Modes
2.1 Addressing Modes
2.1 Addressing Modes
This section describes the symbols used to represent addressing modes and operations of each addressing mode. The R8C/Tiny Series has three types of addressing modes as outlined below.
2.1.1 General Instruction Addressing
This addressing mode type accesses the area from address 0000016 through address 0FFFF16.
The names of the general instruction addressing modes are as follows:
• Immediate
• Register direct
• Absolute
• Address register indirect
• Address register relative
• SB relative
• FB relative
• Stack pointer relative
2.1.2 Special Instruction Addressing
This addressing mode type accesses the area from address 0000016 through address FFFFF16 and the
control registers.
The names of the specific instruction addressing modes are as follows:
• 20-bit absolute
• Address register relative with 20-bit displacement
• 32-bit address register indirect
• 32-bit register direct
• Control register direct
• Program counter relative
2.1.3 Bit Instruction Addressing
This addressing mode type accesses the area from address 0000016 through address 0FFFF16.
The names of the bit instruction addressing modes are as follows:
• Register direct
• Absolute
• Address register indirect
• Address register relative
• SB relative
• FB relative
• FLG direct
Rev.2.00 Oct 17, 2005 page 22 of 263
REJ09B0001-0200
Page 41
Chapter 2 Addressing Modes
2.2 Guide to This Chapter
An example illustrating how to read this chapter is shown below.
(1)
Address register relative
2.2 Guide to This Chapter
The value indicated by the displacement (dsp) plus the content of the
address register (A0/A1)—added
without the sign bits—is the effective
address for the operation.
However, if the addition results in a
value exceeding 0FFFF16, bits 17
and above are ignored, and the
address returns to 0000016.
(2)
(3)
(4)
dsp:8[A0]
dsp:8[A1]
dsp:16[A0]
dsp:16[A1]
(1) Name
The name of the addressing mode.
(2) Symbol
The symbol representing the addressing mode.
A0 / A1
Register
address
Memory
dsp
(3) Description
A description of the addressing operation and the effective address range.
(4) Operation diagram
A diagram illustrating the addressing operation.
Rev.2.00 Oct 17, 2005 page 23 of 263
REJ09B0001-0200
Page 42
Chapter 2 Addressing Modes
2.3 General Instruction Addressing
Immediate
#IMM
#IMM8
#IMM16
#IMM20
Register direct
R0L
R0H
R1L
R1H
R0
R1
R2
R3
A0
A1
The immediate data indicated by #IMM
is the object of the operation.
The specified register is the object of
the operation.
2.3 General Instruction Addressing
#IMM8
#IMM16
b19
#IMM20
R0L / R1L
R0H / R1H
R0 / R1 / R2 /
R3 / A0 / A1
b15
b15
Register
b15b8
b15
b8
b8
b8
b7
b7
b7
b7
b0
b0
b0
b0
b0
Absolute
abs16
The value indicated by abs16 is the
effective address for the operation.
The effective address range is 0000016 to
0FFFF16.
Address register indirect
[A0]
[A1]
The value indicated by the content of
the address register (A0/A1) is the
effective address for the operation.
The effective address range is 0000016
to 0FFFF16.
A0 / A1
abs16
Register
Memory
Memory
address
Rev.2.00 Oct 17, 2005 page 24 of 263
REJ09B0001-0200
Page 43
Chapter 2 Addressing Modes
Address register relative
2.3 General Instruction Addressing
dsp:8[A0]
dsp:8[A1]
dsp:16[A0]
dsp:16[A1]
SB relative
dsp:8[SB]
dsp:16[SB]
The value indicated by the displacement (dsp) plus the content of the
address register (A0/A1)—added
without the sign bits—is the effective
address for the operation.
However, if the addition results in a
value exceeding 0FFFF16, bits 17 and
above are ignored, and the address
returns to 0000016.
The address indicated by the content
of the static base register (SB) plus
the value indicated by the displacement (dsp)—added without the sign
bits—is the effective address for the
operation.
However, if the addition results in a
value exceeding 0FFFF16, bits 17 and
above are ignored, and the address
returns to 0000016.
A0 / A1
SB
Register
address
Register
address
Memory
dsp
Memory
address
dsp
FB relative
dsp:8[FB]
Rev.2.00 Oct 17, 2005 page 25 of 263
REJ09B0001-0200
The address indicated by the content
of the frame base register (FB) plus
the value indicated by the displacement (dsp)—added including the sign
bits—is the effective address for the
operation.
However, if the addition results in a
value outside the range 0000016 to
0FFFF16, bits 17 and above are
ignored, and the address returns to
0000016 or 0FFFF16.
If the dsp value is negative
dsp
Register
FB
address
If the dsp value is positive
address
dsp
Memory
Page 44
Chapter 2 Addressing Modes
Stack pointer relative
2.3 General Instruction Addressing
dsp:8[SP]
The address indicated by the content of the
stack pointer (SP) plus the value indicated by
If the dsp value is negative
the displacement (dsp)—added including the
sign bits—is the effective address for the
operation. The stack pointer (SP) here is the
one indicated by the U flag.
However, if the addition results in a value
outside the range 00000
16 to 0FFFF16, bits
SP
17 and above are ignored, and the address
returns to 0000016 or 0FFFF16.
This addressing mode can be used with the
MOV instruction.
If the dsp value is positive
Memory
dsp
Register
address
dsp
Rev.2.00 Oct 17, 2005 page 26 of 263
REJ09B0001-0200
Page 45
Chapter 2 Addressing Modes
2.4 Special Instruction Addressing
20-bit absolute
2.4 Special Instruction Addressing
abs20
The value indicated by abs20 is the
effective address for the operation.
The effective address range is 0000016 to
FFFFF16.
This addressing mode can be used with
the LDE, STE, JSR, and JMP instructions.
Address register relative with 20-bit displacement
dsp:20[A0]
dsp:20[A1]
The address indicated by the displacement
(dsp) plus the content of the address
register (A0/A1)—added without the sign
bits—is the effective address for the
operation.
However, if the addition results in a value
exceeding FFFFF
16, bits 21 and above are
ignored, and the address returns to
0000016.
This addressing mode can be used with
the LDE, STE, JMPI, and JSRI instructions.
abs20
LDE, STE instructions
Register
A0
address
JMPI, JSRI instructions
Register
A0 / A1
address
Memory
Memory
dsp
Memory
dsp
Valid addressing mode and instruction
combinations are as follows.
dsp: 20[A0]
LDE, STE, JMPI, and JSRI
instructions
dsp: 20[A1]
JMPI and JSRI instructions
32-bit address register indirect
[A1A0]
The address indicated by the 32
concatenated bits of the address
registers (A0 and A1) is the effective
address for the operation.
However, if the concatenated register
value exceeds FFFFF16, bits 21 and
above are ignored.
This addressing mode can be used
with the LDE and STE instructions.
A1
b31
address-H
PC
Register
b16 b15b0
address-L
A0
Memory
address
Rev.2.00 Oct 17, 2005 page 27 of 263
REJ09B0001-0200
Page 46
Chapter 2 Addressing Modes
32-bit register direct
R2R0
R3R1
A1A0
The 32-bit concatenated register content of two
specified registers is the object of the operation.
This addressing mode can be used with the
SHL, SHA, JMPI, and JSRI instructions.
Valid register and instruction combinations
are as follows.
2.4 Special Instruction Addressing
SHL, SHA instructions
R2R0
b31
R3R1
JMPI, JSRI instructions
b15b16
b0
R2R0, R3R1
A1A0
JMPI and JSRI instructions
Control register direct
INTBL
The specified control register is the
object of the operation.
INTBH
ISP
SP
This addressing mode can be used
with the LDC, STC, PUSHC, and
POPC instructions.
SB
FB
FLG
If SP is specified, the stack pointer
indicated by the U flag is the object of
the operation.
SHL, SHA, JMPI, and JSRI
instructions
R2R0
R3R1
A1A0
INTBL
INTBH
ISP
USP
b31
PC
b15
b15
b15
b15
b16
Register
b15
b4
b3
b0
b0
b0
b0
b0
Rev.2.00 Oct 17, 2005 page 28 of 263
REJ09B0001-0200
SB
FB
FLG
b15
b15
b15
b0
b0
b0
Page 47
Chapter 2 Addressing Modes
Program counter relative
2.4 Special Instruction Addressing
label
• If the jump length specifier (.length)
is (.S), the base address plus the
value indicated by the displacement
(dsp)—added without the sign bits—is
the effective address.
This addressing mode can be used
with the JMP instruction.
• If the jump length specifier (.length) is
(.B) or (.W), the base address plus the
value indicated by the displacement
(dsp)—added including the sign bits—is
the effective address.
However, if the addition results in a value
outside the range 0000016 to FFFFF16,
bits 21 and above are ignored, and the
address returns to 0000016 or FFFFF16.
Memory
Base address
dsp
label
+0 dsp +7
*1 The base address is (start address of instruction + 2).
Memory
If the dsp value is negative
dsp
Base address
dsp
label
This addressing mode can be used with
the JMP and JSR instructions.
If the dsp value is positive
label
If the specifier is (.B), -128 dsp +127
If the specifier is (.W), -32768 dsp +32767
*2 The base address varies depending on the instruction.
Rev.2.00 Oct 17, 2005 page 29 of 263
REJ09B0001-0200
Page 48
Chapter 2 Addressing Modes
2.5 Bit Instruction Addressing
2.5. Bit Instruction Addressing
This addressing mode type can be used with the following instructions: BCLR, BSET, BNOT, BTST,
BNTST, BAND, BNAND, BOR, BNOR, BXOR, BNXOR, BM
Register direct
Cnd
, BTSTS, BTSTC
bit,R0
bit,R1
bit,R2
bit,R3
bit,A0
bit,A1
Absolute
bit,base:16
The specified register bit is the object
of the operation.
A value of 0 to 15 may be specified
as the bit position (bit).
The bit that is the number of bits
indicated by bit away from bit 0 at the
address indicated by base is the object
of the operation.
Bits at addresses 0000016 through
01FFF16 can be the object of the
operation.
bit,R0
b15
base
R0
Bit position
b7
b0
b0
Address register indirect
[A0]
[A1]
Rev.2.00 Oct 17, 2005 page 30 of 263
REJ09B0001-0200
The bit that is the number of bits
indicated by the address register (A0/
A1) away from bit 0 at address
0000016 is the object of the operation.
Bits at addresses 0000016 through
01FFF16 can be the object of the
operation.
0000016
Bit position
b7
Bit position
b0
Page 49
Chapter 2 Addressing Modes
Address register relative
2.5 Bit Instruction Addressing
base:8[A0]
base:8[A1]
base:16[A0]
base:16[A1]
The bit that is the number of bits
indicated by the address register
(A0/A1) away from bit 0 at the
address indicated by base is the
object of the operation.
However, if the address of the bit
that is the object of the operation
exceeds 0FFFF16, bits 17 and
above are ignored and the
address returns to 0000016.
The address range that can be
specified by the address register
(A0/A1) extends 8,192 bytes
from base.
base
b7
Bit position
b0
SB relative
bit,base:8[SB]
bit,base:11[SB]
bit,base:16[SB]
The bit that is the number of bits
indicated by bit away from bit 0 at
the address indicated by the static
base register (SB) plus the value
indicated by base (added without
the sign bits) is the object of the
operation.
However, if the address of the bit
that is the object of the operation
exceeds 0FFFF16, bits 17 and
above are ignored and the address
returns to 0000016.
The address ranges that can be
specified by bit,base:8, bit,base:11,
and bit,base:16, respectively, extend
32 bytes, 256 bytes, and 8,192
bytes from the static base register
(SB) value.
SB
Register
address
base
address
Memory
b7
Bit position
b0
Rev.2.00 Oct 17, 2005 page 31 of 263
REJ09B0001-0200
Page 50
Chapter 2 Addressing Modes
FB relative
2.5 Bit Instruction Addressing
bit,base:8[FB]
The bit that is the number of bits
indicated by bit away from bit 0 at the
address indicated by the frame base
register (FB) plus the value indicated by
base (added including the sign bit) is the
object of the operation.
However, if the address of the bit that is
the object of the operation is outside the
range 0000016 to 0FFFF16, bits 17 and
above are ignored and the address
returns to 0000016 or 0FFFF16.
The address range that can be specified
by bit, base:8 extends 16 bytes toward
lower addresses or 15 bytes toward
higher addresses from the frame base
register (FB) value.
If the base value is negative
FB
If the base value is positive
Register
address
Memory
(Bit position)
base
address
base
Bit position
FLG direct
U
I
O
B
S
Z
D
C
The specified flag is the object of
the operation.
This addressing mode can be
used with the FCLR and FSET
instructions.
Register
FLG
UI OBS ZDC
b0b7
Rev.2.00 Oct 17, 2005 page 32 of 263
REJ09B0001-0200
Page 51
3.1 Guide to This Chapter
3.2 Functions
Chapter 3
Functions
Page 52
Chapter 3 Functions
3.1 Guide to This Chapter
3.1 Guide to This Chapter
In this chapter each instruction’s syntax, operation, function, selectable src/dest, and flag changes are
listed, and description examples and related instructions are shown.
An example illustrating how to read this chapter is shown below.
(1)
(2)
(3)
(4)
(5)
(6)
Chapter 3 Functions
3.2 Functions
MOV
[ Syntax ]
MOV.size (:format) src,dest
[ Operation ]
Transfer
MOVe
G , Q , Z , S (Can be specified)
B , W
[ Instruction Code/Number of Cycles ]
dest src
[ Function ]
• This instruction transfers
• If
dest
is A0 or A1 and the selected size specifier (.size) is (.B),
is A0 or A1, the 8 low-order bits of A0 or A1 are transferred.
(See next page for src/dest classified by format.)
MOV
Page: 193
(7)
(8)
(9)
Rev.2.00 Oct 17, 2005 page 34 of 263
REJ09B0001-0200
[ Flag Change ]
Flag
Change
Conditions
[ Related Instruction]
UI OBSZDC
S :The flag is set when the transfer results in MSB of dest = 1; otherwise cleared.
Z :The flag is set when the transfer results in 0; otherwise cleared.
[ Description Example ]
MOV.B:S#0ABH,R0L
MOV.W#-1,R2
LDE, STE, XCHG
90
Page 53
Chapter 3 Functions
3.1 Guide to This Chapter
(1) Mnemonic
The mnemonic explained in the page.
(2) Instruction Code/Number of Cycles
The page on which the instruction code and number of cycles is listed.
Refer to this page for information on the instruction code and number of cycles.
(3) Syntax
The syntax of the instruction using symbols. If (:format) is omitted, the assembler chooses the optimum
specifier.
MOV.size (: format) src , dest
G , Q , S , Z (f)B , W (e)
(a) (b) (c) (d)
(a) MnemonicMOV
Shows the mnemonic.
(b) Size specifier.size
Shows the data sizes in which data is handled. The following data sizes may be specified:
.BByte (8 bits)
.WWord (16 bits)
.LLong word (32 bits)
Some instructions do not have a size specifier.
(c) Instruction format specifier(: format)
Shows the instruction format. If (: format) is omitted, the assembler chooses the optimum specifier.
If (: format) is entered, its content is given priority. The following instruction formats may be specified:
:G Generic format
:Q Quick format
:S Short format
:Z Zero format
Some instructions do not have an instruction format specifier.
(d) Operandssrc, dest
Shows the operands.
(e) Shows the data sizes that can be specified in (b).
(f) Shows the instruction formats that can be specified in (c).
Rev.2.00 Oct 17, 2005 page 35 of 263
REJ09B0001-0200
Page 54
Chapter 3 Functions
3.1 Guide to This Chapter
(1)
(2)
(3)
(4)
(5)
(6)
Chapter 3 Functions
3.2 Functions
MOV
[ Syntax ]
MOV.size (:format) src,dest
[ Operation ]
Transfer
MOVe
G , Q , Z , S (Can be specified)
B , W
[ Instruction Code/Number of Cycles ]
dest src
[ Function ]
src
to
dest
• This instruction transfers
• If
dest
is A0 or A1 and the selected size specifier (.size) is (.B),
is A0 or A1, the 8 low-order bits of A0 or A1 are transferred.
]
srcdest
.
src
is zero-expanded to transfer
(See next page for src/dest classified by format.)
MOV
Page: 193
(7)
(8)
(9)
Rev.2.00 Oct 17, 2005 page 36 of 263
REJ09B0001-0200
[ Flag Change ]
Flag
Change
Conditions
UI OBSZDC
S :The flag is set when the transfer results in MSB of dest = 1; otherwise cleared.
Z :The flag is set when the transfer results in 0; otherwise cleared.
[ Description Example ]
MOV.B:S#0ABH,R0L
MOV.W#-1,R2
[ Related Instruction]LDE, STE, XCHG
90
Page 55
Chapter 3 Functions
3.1 Guide to This Chapter
(4) Operation
Explains the operation of the instruction using symbols.
(5) Function
Explains the function of the instruction and precautions to be taken when using the instruction.
(6) Selectable
If the instruction has operands, the valid formats are listed here.
Shown on the left side of the slash (R0H) is the addressing mode when data is handled in bytes (8 bits).
Shown on the right side of the slash (R1) is the addressing mode when data is handled in words (16 bits).
(7) Flag change
Shows a flag change that occurs after the instruction is executed. The symbols in the table mean the
following.
“—” The flag does not change.
“O” The flag changes depending on a condition.
(8) Description example
Description examples for the instruction.
(9)Related instructions
Related instructions that cause an operation similar or opposite to that of the instruction.
Rev.2.00 Oct 17, 2005 page 37 of 263
REJ09B0001-0200
Page 56
Chapter 3 Functions
The syntax of the jump instructions JMP, JPMI, JSR, and JSRI are illustrated below by example .
3.1 Guide to This Chapter
Chapter 3 Functions
(1)
(2)
(3)
JMP
[ Syntax ]
JMP (.length) label
(3) Syntax
Indicates the instruction syntax using symbols.
JMP (.length) label
(a)(b)(c)
(a) MnemonicJMP
Shows the mnemonic.
Unconditional jump
JuMP
S, B, W, A (Can be specified)
S, B, W, A
(d)
3.2 Functions
JMP
[ Instruction Code/Number of Cycles ]
Page: 183
(b) Jump distance specifier.length
Shows the distance of the jump. If (.length) is omitted from the JMP or JSR instruction, the assembler chooses the optimum specifier. If (.length) is entered, its content is given priority.
The following jump distances may be specified:
.S3-bit PC forward relative (+2 to +9)
.B8-bit PC relative
.W16-bit PC relative
.A20-bit absolute
(c) Operandlabel
Shows the operand.
(d) Shows the jump distances that can be specified in (b).
Rev.2.00 Oct 17, 2005 page 38 of 263
REJ09B0001-0200
Rev.2.00 Oct 17, 2005 page 39 of 263
REJ09B0001-0200
UIOBSZDC
O:
The flag is set (= 1) when dest before the operation is –128 (.B) or –32768 (.W); otherwise cleared (= 0).
S :The flag is set when the operation results in MSB = 1; otherwise cleared.
Z :The flag is set when the operation results in 0; otherwise cleared.
C :The flag value is undefined.
ABS.BR0L
ABS.WA0
Page 58
Chapter 3 Functions
Add with carry
ADdition with Carry
3.2 Functions
ADCADC
[ Syntax ]
ADC.sizesrc,dest
B , W
[ Operation ]
dest src + dest + C
[ Function ]
• This instruction adds
• If
dest
is A0 or A1 and the selected size specifier (.size) is (.B),
calculation in 16 bits. If
A1.
is A0 or A1, the operation is performed on the eight low-order bits of A0 or
*1
[ Instruction Code/Number of Cycles ]
dest
.
src
is zero-expanded to perform
*1
A1/A1
[A0][A1]
Page: 138
*1 If (.B) is selected as the size specifier (.size), A0 or A1 cannot be chosen for
neously.
[ Flag Change ]
Flag
Change
Conditions
[ Description Example ]
UIOBSZDC
O :The flag is set when a signed operation results in a value exceeding +32767 (.W) or –32768 (.W)
or +127 (.B) or –128 (.B); otherwise cleared.
S :The flag is set when the operation results in MSB = 1; otherwise cleared.
Z :The flag is set when the operation results in 0; otherwise cleared.
C :The flag is set when an unsigned operation results in a value exceeding +65535 (.W) or +255 (.B);
otherwise cleared.
ADC.B#2,R0L
ADC.WA0,R0
ADC.BA0,R0L
ADC.BR0L,A0
; 8 low-order bits of A0 and R0L are added.
; R0L is zero-expanded and added to A0.
src
and
dest
simulta-
[ Related Instructions ]ADCF, ADD, SBB, SUB
Rev.2.00 Oct 17, 2005 page 40 of 263
REJ09B0001-0200
Rev.2.00 Oct 17, 2005 page 41 of 263
REJ09B0001-0200
UIOBSZDC
O :The flag is set when a signed operation results in a value exceeding +32767 (.W) or –32768 (.W)
or +127 (.B) or –128 (.B); otherwise cleared.
S :The flag is set when the operation results in MSB = 1; otherwise cleared.
Z :The flag is set when the operation results in 0; otherwise cleared.
C :The flag is set when an unsigned operation results in a value exceeding +65535 (.W) or +255 (.B);
otherwise cleared.
ADCF.BR0L
ADCF.WRam:16[A0]
Page 60
Chapter 3 Functions
3.2 Functions
Add without carry
ADDADD
ADDition
[ Syntax ]
ADD.size (:format)src,dest
G , Q , S (Can be specified)
B , W
[ Operation ]
dest dest + src
[ Function ]
• This instruction adds
•
If
dest
is A0 or A1 and the selected size specifier (.size) is (.B),
*1 If (.B) is selected as the size specifier (.size), A0 or A1 cannot be chosen for
src
is a stack pointer and the selected size specifier (.size) is (.B),
*1
A1/A1
dest
and
src
and stores the result in
is A0 or A1, the operation is performed on the eight low-order bits of A0 or A1.
(See next page for
srcdest
[A0][A1]A0/A0
*1
[ Instruction Code/Number of Cycles ]
dest
.
src
is zero-expanded to perform calculation
src
is sign extended to perform
src /dest
A1/A1
classified by format.)
*1
[A0][A1]
src
and
dest
simultaneously.
Page: 140
*2
*2
The operation is performed on the stack pointer indicated by the U flag. Only #IMM can be selected for
[ Flag Change ]
Flag
Change
Conditions
[ Description Example ]
UIOBSZDC
O :The flag is set when a signed operation results in a value exceeding +32767 (.W) or –32768 (.W)
or +127 (.B) or –128 (.B); otherwise cleared.
S :The flag is set when the operation results in MSB = 1; otherwise cleared.
Z :The flag is set when the operation results in 0; otherwise cleared.
C :The flag is set when an unsigned operation results in a value exceeding +65535 (.W) or +255 (.B);
*1 If (.B) is selected as the size specifier (.size), A0 or A1 cannot be chosen for
neously.
A1/A1
*1
src
is A0 or A1, operation is performed on the 8 low-order bits of A0 or A1.
(See next page for
srcdest
[A0][A1]A0/A0
*1
[ Instruction Code/Number of Cycles ]
src
from
dest
src
is zero-expanded to perform
A1/A1
src/dest
*1
classified by format.)
[A0][A1]
src
and
dest
Page: 161
.
simulta-
[ Flag Change ]
Flag
Change
Conditions
[ Description Example ]
Rev.2.00 Oct 17, 2005 page 62 of 263
REJ09B0001-0200
UIOBSZDC
O :The flag is set when a signed operation results in a value exceeding +32767 (.W) or –32768 (.W),
or +127 (.B) or –128 (.B); otherwise cleared.
S :The flag is set when the operation results in MSB = 1; otherwise cleared.
Z :The flag is set when the operation results in 0; otherwise cleared.
C :The flag is set when an unsigned operation results in any value equal to or greater than 0;
, and the C flag as decimal data and stores the result in
[ Instruction Code/Number of Cycles ]
dest
Page: 165
.
[ Flag Change ]
Flag
Change
Conditions
[ Description Example ]
[ Related Instructions ]DADD, DSUB, DSBB
Rev.2.00 Oct 17, 2005 page 64 of 263
REJ09B0001-0200
UIOBSZDC
S :The flag is set when the operation results in MSB = 1; otherwise cleared.
Z :The flag is set when the operation results in 0; otherwise cleared.
C :The flag is set when the operation results in a value exceeding +9999 (.W) or +99 (.B); otherwise
Rev.2.00 Oct 17, 2005 page 65 of 263
REJ09B0001-0200
UIOBSZDC
S :The flag is set when the operation results in MSB = 1; otherwise cleared.
Z :The flag is set when the operation results in 0; otherwise cleared.
C :The flag is set when the operation results in a value exceeding +9999 (.W) or +99 (.B); otherwise
cleared.
DADD.B#3,R0L
DADD.WR1,R0
Page 84
Chapter 3 Functions
3.2 Functions
Decrement
DECDEC
DECrement
[ Syntax ]
DEC.sizedest
[ Operation ]
dest dest – 1
[ Function ]
• This instruction decrements
[ Selectable dest ]
B , W
dest
by 1 and stores the result in
R0L
abs16
*1 Only (.B) can be specified as the size specifier (.size).
[ Instruction Code/Number of Cycles ]
Page: 169
dest
.
dest
*1
*1
R0H
*2
A0
*1
dsp:8[SB]*1dsp:8[FB]
*2
A1
*1
*2 Only (.W) can be specified as the size specifier (.size).
[ Flag Change ]
Flag
Change
UIOBSZDC
Conditions
S :The flag is set when the operation results in MSB = 1; otherwise cleared.
Z :The flag is set when the operation results in 0; otherwise cleared.
[ Description Example ]
DEC.WA0
DEC.BR0L
[ Related Instructions ]INC
Rev.2.00 Oct 17, 2005 page 66 of 263
REJ09B0001-0200
Page 85
Chapter 3 Functions
3.2 Functions
Signed divide
DIVDIV
DIVide
[ Syntax ]
DIV.sizesrc
B , W
[ Operation ]
If the size specifier (.size) is (.B)
R0L (quotient), R0H (remainder) R0 src
If the size specifier (.size) is (.W)
R0 (quotient), R2 (remainder) R2R0 src
[ Function ]
• This instruction divides R2R0 (R0)
and the remainder in R2 (R0H)*1. The remainder has the same sign as the dividend. Items in parentheses and followed by
selected as the size specifier (.size).
• If
src
is A0 or A1 and the selected size specifier (.size) is (.B), the operation is performed on the 8 low-
order bits of A0 or A1.
• If (.B) is selected as the size specifier (.size), the O flag is set when the operation results in a quotient
exceeding 8 bits or the divisor is 0. In this case, R0L and R0H are undefined.
• If (.W) is selected as the size specifier (.size), the O flag is set when the operation results in a quotient
exceeding 16 bits or the divisor is 0. In this case, R0 and R2 are undefined.
“*1”
( )*1 indicate registers that are the object of the operation when (.B) is
O :The flag is set when the operation results in a quotient exceeding 16 bits (.W) or 8 bits (.B) or the
divisor is 0; otherwise cleared.
DIV.BA0;Value of 8 low-order bits of A0 is the divisor.
DIV.B#4
DIV.WR0
[ Related Instructions ]DIVU, DIVX, MUL, MULU
Rev.2.00 Oct 17, 2005 page 67 of 263
REJ09B0001-0200
Page 86
Chapter 3 Functions
3.2 Functions
Unsigned divide
DIVUDIVU
DIVide Unsigned
[ Syntax ]
DIVU.sizesrc
B , W
[ Operation ]
If the size specifier (.size) is (.B)
R0L (quotient), R0H (remainder) R0 src
If the size specifier (.size) is (.W)
R0 (quotient), R2 (remainder) R2R0 src
[ Function ]
• This instruction divides R2R0 (R0)
(R0L)*1 and the remainder in R2 (R0H)*1. Items in parentheses and followed by
registers that are the object of the operation when (.B) is selected as the size specifier (.size).
• If
src
is A0 or A1 and the selected size specifier (.size) is (.B), the operation is performed on the 8 low-
order bits of A0 or A1.
• If (.B) is selected as the size specifier (.size), the O flag is set when the operation results in a quotient
exceeding 8 bits or the divisor is 0. In this case, R0L and R0H are undefined.
• If (.W) is selected as the size specifier (.size), the O flag is set when the operation results in a quotient
exceeding 16 bits or the divisor is 0. In this case, R0 and R2 are undefined.
O :The flag is set when the operation results in a quotient exceeding 16 bits (.W) or 8 bits (.B) or the
divisor is 0; otherwise cleared.
DIVU.BA0;Value of 8 low-order bits of A0 is the divisor.
DIVU.B#4
DIVU.WR0
[ Related Instructions ]DIV, DIVX, MUL, MULU
Rev.2.00 Oct 17, 2005 page 68 of 263
REJ09B0001-0200
Page 87
Chapter 3 Functions
3.2 Functions
Signed divide
DIVXDIVX
DIVide eXtension
[ Syntax ]
DIVX.sizesrc
B , W
[ Operation ]
If the size specifier (.size) is (.B)
R0L (quotient), R0H (remainder) R0 src
If the size specifier (.size) is (.W)
R0 (quotient), R2 (remainder) R2R0 src
[ Function ]
• This instruction divides R2R0 (R0)*1 by the signed value of
remainder in R2 (R0H)*1. The remainder has the same sign as the divisor. Items in parentheses and followed
“*1”
by
( )*1 indicate registers that are the object of the operation when (.B) is selected as the size specifier (.size).
• If
src
is A0 or A1 and the selected size specifier (.size) is (.B), the operation is performed on the 8 low-
order bits of A0 or A1.
• If (.B) is selected as the size specifier (.size), the O flag is set when the operation results in a quotient
exceeding 8 bits or the divisor is 0. At this time, R0L and R0H are undefined.
• If (.W) is selected as the size specifier (.size), the O flag is set when the operation results in a quotient
exceeding 16 bits or the divisor is 0. At this time, R0 and R2 are undefined.
Rev.2.00 Oct 17, 2005 page 70 of 263
REJ09B0001-0200
UIOBSZDC
S :The flag is set when the operation results in MSB = 1; otherwise cleared.
Z :The flag is set when the operation results in 0; otherwise cleared.
C :The flag is set when the operation results in any value equal to or greater than 0; otherwise
S :The flag is set when the operation results in MSB = 1; otherwise cleared.
Z :The flag is set when the operation results in 0; otherwise cleared.
C :The flag is set when the operation results in any value equal to or greater than 0; otherwise
cleared.
[ Description Example ]
DSUB.B#3,R0L
DSUB.WR1,R0
[ Related Instructions ]DADC, DADD, DSBB
Rev.2.00 Oct 17, 2005 page 71 of 263
REJ09B0001-0200
Page 90
Chapter 3 Functions
3.2 Functions
Build stack frame
ENTERENTER
[ Syntax ]
ENTERsrc
[ Operation ]
SP SP – 2
M(SP) FB
FB SP
SP SP – src
[ Function ]
• This instruction generates a stack frame.
• The diagrams below show the stack area status before and after the ENTER instruction is executed at
*1 PC indicates the start address of the instruction.
[ Flag Change ]
Flag
Change
[ Description Example ]
UIOBSZDC
JMPlabel
[ Related Instructions ]JMPI
Rev.2.00 Oct 17, 2005 page 81 of 263
REJ09B0001-0200
Page 100
Chapter 3 Functions
3.2 Functions
Jump indirect
JMPIJMPI
JuMP Indirect
[ Syntax ]
JMPI.lengthsrc
W , A
[ Operation ]
When jump distance specifier (.length) is (.W)When jump distance specifier (.length) is (.A)
PC PC srcPC src
[ Function ]
• This instruction causes control to jump to the address indicated by
memory, specify the address at which the low-order address is stored.
•
If (.W) is selected as the jump distance specifier (.length), control jumps to the start address of the instruction
plus the address indicated by
required memory capacity is 2 bytes.
• If
src
is a location in the memory and (.A) is selected as the jump distance specifier (.length), the
required memory capacity is 3 bytes.
[ Selectable src ]
If (.W) is selected as the jump distance specifier (.length)
src
R0L/R0R0H/R1R1L/R2R1H/R3
A0/A0A1/A1[A0][A1]
dsp:8[A0]dsp:8[A1]dsp:8[SB]dsp:8[FB]
dsp:16[A0] dsp:16[A1]dsp:16[SB]abs16
dsp:20[A0] dsp:20[A1]abs20
R2R0R3R1A1A0
src
(added including the sign bits).
[ Instruction Code/Number of Cycles ]
Page: 185
src
. If
src
is a location in the
If
src
is a location in the memory, the
If (.A) is selected as the jump distance specifier (.length)
src
R0L/R0R0H/R1R1L/R2R1H/R3
A0/A0A1/A1[A0][A1]
dsp:8[A0]dsp:8[A1]dsp:8[SB]dsp:8[FB]
dsp:16[A0] dsp:16[A1]dsp:16[SB]abs16
dsp:20[A0] dsp:20[A1]abs20
R2R0R3R1A1A0
[ Flag Change ]
Flag
Change
[ Description Example ]
[ Related Instructions ]JMP
UIOBSZDC
JMPI.AA1A0
JMPI.WR0
Rev.2.00 Oct 17, 2005 page 82 of 263
REJ09B0001-0200
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.