M32R-FPU: Software Manual
M32R-FPU: Software Manual
M32R-FPU
32 Software Manual
Before using this material, please visit our website to confirm that this is the most
current document available.
Rev. 1.01
Revision date: Oct 31, 2003 www.renesas.com
Keep safety first in your circuit designs!
Renesas Technology Corporation puts the maximum effort into making semiconductor prod-
ucts 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 ap-
propriate measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of non-
flammable material or (iii) prevention against any malfunction or mishap.
APPENDIX
INDEX
(2)
M32R-FPU Software Manual (Rev.1.01)
This page left blank intentionally.
b0 b31 b0 b31
R0 R8
R1 R9
R2 R10
R3 R11
R4 R12
R5 R13
R6 R14 (Link register)
R7 R15 (Stack pointer) (Note 1)
Note 1: The stack pointer functions as either the SPI or the SPU depending on the value of the SM bit in the PSW.
There are 6 control registers which are the Processor Status Word Register (PSW),
the Condition Bit Register (CBR), the Interrupt Stack Pointer (SPI), the User Stack
Pointer (SPU), the Backup PC (BPC) and the Floating-point Status Register (FPSR).
The dedicated MVTC and MVFC instructions are used for writing and reading these
control registers.
In addition, the SM bit, IE bit and C bit of the PSW can also be set by the SETPSW
instruction or the CLRPSW instruction.
CRn
b0 b31
CR0 PSW Processor Status Register
CR1 CBR Condition Bit Register
CR2 SPI Interrupt Stack Pointer
CR3 SPU User Stack Pointer
b0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 b15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
b16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 b31
BSM BIE BC SM IE C
? ? 0 0 0 0 0 ? 0 0 0 0 0 0 0 0
< At reset release: "B'0000 0000 0000 0000 ??00 000? 0000 0000 >
The Processor Status Word Register (PSW) indicates the M32R-FPU status. It
consists of the current PSW field which is regularly used, and the BPSW field where
a copy of the PSW field is saved when EIT occurs.
The PSW field consists of the Stack Mode (SM) bit, the Interrupt Enable (IE) bit and
the Condition (C) bit.
The BPSW field consists of the Backup Stack Mode (BSM) bit, the Backup Interrupt
Enable (BIE) bit and the Backup Condition (BC) bit.
At reset release, BSM, BIE and BC are undefined. All other bits are "0".
The Condition Bit Register (CBR) is derived from the PSW register by extracting its
Condition (C) bit. The value written to the PSW register's C bit is reflected in this
register. The register can only be read. (Writing to the register with the MVTC
instruction is ignored.)
At reset release, the value of CBR is "H'0000 0000".
b0
b31
CBR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 C
The Interrupt Stack Pointer (SPI) and the User Stack Pointer (SPU) retain the
address of the current stack pointer. These registers can be accessed as the
general-purpose register R15. R15 switches between representing the SPI and
SPU depending on the value of the Stack Mode (SM) bit in the PSW.
At reset release, the value of the SPI and SPU are undefined.
b0 b31
SPI SPI
b0 b31
SPU SPU
The Backup PC (BPC) is used to save the value of the Program Counter (PC) when
an EIT occurs. Bit 31 is fixed to "0".
When an EIT occurs, the register sets either the PC value when the EIT occurred or
the PC value for the next instruction depending on the type of EIT. The BPC value
is loaded to the PC when the RTE instruction is executed. However, the values of
the lower 2 bits of the PC are always "00" when returned (PC always returns to the
word-aligned address).
At reset release, the value of the BPC is undefined.
b0 b31
BPC BPC 0
b16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 b31
EX EU EZ EO EV DN CE CX CU CZ CO CV RM
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
The exception occurs when the absolute value of the operation result exceeds the
largest describable precision in the floating-point format. The following table shows
the operation results when an OVF occurs.
Note 1: When the Overflow Exception Enable (EO) bit (FPSR register bit 20) = "0"
Note 2: When the Overflow Exception Enable (EO) bit (FPSR register bit 20) = "1"
Note: If an OVF occurs while EIT processing for OVF is masked, an IXCT occurs at the same time.
+MAX = H'7F7F FFFF, MAX = H'FF7F FFFF
The exception occurs when the absolute value of the operation result is less than
the largest describable precision in the floating-point format. The following table
shows the operation results when a UDF occurs.
Note 1: When the Underflow Exception Enable (EU) bit (FPSR register bit 18) = "0"
Note 2: When the Underflow Exception Enable (EU) bit (FPSR register bit 18) = "1"
The exception occurs when the operation result differs from a result led out with an
infinite range of precision. The following table shows the operation results and the
respective conditions in which each IXCT occurs.
Note 1: When the Inexact Exception Enable (EX) bit (FPSR register bit 17) = "0"
Note 2: When the Inexact Exception Enable (EX) bit (FPSR register bit 17) = "1"
The exception occurs when a finite nonzero value is divided by zero. The following
table shows the operation results when a DIV0 occurs.
Note 1: When the Zero Division Exception Enable (EZ) bit (FPSR register bit 19) = "0"
Note 2: When the Zero Division Exception Enable (EZ) bit (FPSR register bit 19) = "1"
Please note that the DIV0 EIT processing does not occur in the following conditions.
Dividend Behavior
0 An invalid operation exception occurs
infinity No exception occur (with the result "infinity")
The exception occurs when an invalid operation is executed. The following table shows
the operation results and the respective conditions in which each IVLD occurs.
Note 1: When the Invalid Operation Exception Enable (EV) bit (FPSR register bit 21) = "0"
Note 2: When the Invalid Operation Exception Enable (EV) bit (FPSR register bit 21) = "1"
Notes: NaN (Not a Number)
SNaN (Signaling NaN): a NaN in which the MSB of the decimal fraction is 0. When
SNaN is used as the source operand in an operation, an IVLD occurs. SNaNs are useful
in identifying program bugs when used as the initial value in a variable. However,
SNaNs cannot be generated by hardware.
QNaN (Quiet NaN): a NaN in which the MSB of the decimal fraction is "1". Even when
QNaN is used as the source operand in an operation, an IVLD will not occur (excluding
comparison and format conversion). Because a result can be checked by the arithmetic
operations, QNaN allows the user to debug without executing an EIT processing.
QNaNs are created by hardware.
The exception occurs when the Denormalized Number Zero Flash (DN) bit (FPSR
register bit 23) = "0" and a denormalized number is given as an operation operand
(Note 1).
Because the UIPL has no enable bits available, it cannot be masked when they
occur. The destination register remains unchanged.
1.4 Accumulator
The Accumulator (ACC) is a 56-bit register used for DSP function instructions.
The accumulator is handled as a 64-bit register when accessed for read or write.
When reading data from the accumulator, the value of bit 8 is sign-extended. When
writing data to the accumulator, bits 0 to 7 are ignored. The accumulator is also used
for the multiply instruction "MUL", in which case the accumulator value is destroyed
by instruction execution.
Use the MVTACHI and MVTACLO instructions for writing to the accumulator. The
MVTACHI and MVTACLO instructions write data to the high-order 32 bits (bits 0-31)
and the low-order 32 bits (bits 32-63), respectively.
Use the MVFACHI, MVFACLO, and MVFACMI instructions for reading data from the
accumulator. The MVFACHI, MVFACLO and MVFACMI instructions read data from
the high-order 32 bits (bits 0-31), the low-order 32 bits (bits 32-63) and the middle 32
bits (bits 16-47), respectively.
At reset release, the value of accumulator is undefined.
b0 78 15 16 31 32 47 48 b63
ACC
Note 1: When read, bits 0 to 7 always show the sign-extended value of bit 8. Writing to this bit field is
ignored.
The Program Counter (PC) is a 32-bit counter that retains the address of the
instruction being executed. Since the M32R CPU instruction starts with even-
numbered addresses, the LSB (bit 31) is always "0".
At reset release, the value of the PC is "H0000 0000."
b0 b31
PC PC 0
The data types that can be handled by the M32R-FPU instruction set are signed or
unsigned 8, 16, and 32-bit integers and single-precision floating-point numbers.
The signed integers are represented by 2's complements.
b0 b7
b0 b7
b0 b15
b0 b15
b0 b31
b0 b31
b0 8 9 b31
The data sizes in the M32R-FPU registers are always words (32 bits).
When loading byte (8-bit) or halfword (16-bit) data from memory into a register, the
data is sign-extended (LDB, LDH instructions) or zero-extended (LDUB, LDUH
instructions) to a word (32-bit) quantity before being loaded into the register.
When storing data from a register into a memory, the 32-bit data, the 16-bit data on
the LSB side and the 8-bit data on the LSB side of the register are stored into
memory by the ST, STH and STB instructions, respectively.
from memory
< load > (LDB, LDUB instruction)
sign-extention (LDB instruction) or
b0 zero-extention (LDUB instruction) 24 b31
Rn byte
Rn halfword
Rn word
Rn byte
Rn halfword
Rn word
The data sizes in memory can be byte (8 bits), halfword (16 bits) or word (32 bits).
Although byte data can be located at any address, halfword and word data must be
located at the addresses aligned with a halfword boundary (least significant
address bit = "0") or a word boundary (two low-order address bits = "00"),
respectively. If an attempt is made to access memory data that overlaps the
halfword or word boundary, an address exception occurs.
Address
+0 address +1 address +2 address +3 address
b0 7 8 15 16 23 24 b31
byte
byte
byte
byte
byte
halfword
half
word halfword
word word
The contents of the register specify the address of the memory. This mode
can be used by all load/store instructions.
The M32R-FPU has a total of 100 instructions. The M32R-FPU has a RISC architecture.
Memory is accessed by using the load/store instructions and other operations are
executed by using register-to-register operation instructions.
M32R CPU supports compound instructions such as " load & address update" and "store
& address update" which are useful for high-speed data transfer.
The load/store instructions carry out data transfers between a register and a memory.
LD Load
LDB Load byte
LDUB Load unsigned byte
LDH Load halfword
LDUH Load unsigned halfword
LOCK Load locked
ST Store
STB Store byte
STH Store halfword
UNLOCK Store unlocked
The contents of the register specify the address. This mode can be used by all load/
store instructions.
When accessing halfword and word size data, it is necessary to specify the address on
the halfword boundary or the word boundary (Halfword size should be such that the low-
order 2 bits of the address are "00" or "10", and word size should be such that the low
order 2 bits of the address are "00"). If an unaligned address is specified, an address
exception occurs.
When accessing byte data or halfword data with load instructions, the high-order bits are
sign-extended or zero-extended to 32 bits, and loaded to a register.
The transfer instructions carry out data transfers between registers or a register and an
immediate value.
Compare, arithmetic/logic operation, multiply and divide, and shift are carried out
between registers.
compare instructions
CMP Compare
CMPI Compare immediate
CMPU Compare unsigned
CMPUI Compare unsigned immediate
multiply/divide instructions
DIV Divide
DIVU Divide unsigned
MUL Multiply
REM Remainder
REMU Remainder unsigned
shift instructions
SLL Shift left logical
SLL3 Shift left logical 3-operand
SLLI Shift left logical immediate
SRA Shift right arithmetic
SRA3 Shift right arithmetic 3-operand
SRAI Shift right arithmetic immediate
SRL Shift right logical
SRL3 Shift right logical 3-operand
SRLI Shift right logical immediate
BC Branch on C-bit
BEQ Branch on equal to
BEQZ Branch on equal to zero
BGEZ Branch on greater than or equal to zero
BGTZ Branch on greater than zero
BL Branch and link
BLEZ Branch on less than or equal to zero
BLTZ Branch on less than zero
BNC Branch on not C-bit
BNE Branch on not equal to
BNEZ Branch on not equal to zero
BRA Branch
JL Jump and link
JMP Jump
NOP No operation
Only a word-aligned (word boundary) address can be specified for the branch address.
The addressing mode of the BRA, BL, BC and BNC instructions can specify an 8-bit or
24-bit immediate value. The addressing mode of the BEQ, BNE, BEQZ, BNEZ, BLTZ,
BGEZ, BLEZ, and BGTZ instructions can specify a 16-bit immediate value.
In the JMP and JL instructions, the register value becomes the branch address.
However, the low-order 2-bit value of the register is ignored. In other branch
instructions, (PC value of branch instruction) + (sign-extended and 2 bits left-shifted
immediate value) becomes the branch address. However, the low order 2-bit value of the
address becomes "00" when addition is carried out. For example, refer to Figure 2.1.1.
When instruction A or B is a branch instruction, branching to instruction G, the
immediate value of either instruction A or B becomes 4.
Simultaneous with execution of branching by the JL or BL instructions for subroutine
calls, the PC value of the return address is stored in R14. The low-order 2-bit value of
the address stored in R14 (PC value of the branch instruction + 4 ) is always cleared to
"0". For example, refer to Figure 2.1.1. If an instruction A or B is a JL or BL instruction,
the return address becomes that of the instruction C.
address +0 +1 +2 +3
H'08 instruction E
H'0C instruction F
The EIT-related instructions carry out the EIT events (Exception, Interrupt and Trap).
Trap initiation and return from EIT are EIT-related instructions.
TRAP Trap
RTE Return from EIT
The DSP function instructions carry out multiplication of 32 bits x 16 bits and 16 bits x 16
bits or multiply and add operation; there are also instructions to round off data in the
accumulator and carry out transfer of data between the accumulator and a general-
purpose register.
Rsrc1 Rsrc2
0 15 16 31 0 15 16 31
H L H L
x
x
MULHI instruction MULLO instruction
0 63
ACC
Rsrc1 Rsrc2
0 31 0 15 16 31
32 bits H L
x
x
MULWHI instruction MULWLO instruction
0 63
ACC
Rsrc1 Rsrc2
0 15 16 31 0 15 16 31 0 63
H L H L ACC
x
x
+
+
MACHI instruction MACLO instruction
0 63
ACC
Rsrc1 Rsrc2
0 31 0 15 16 31 0 63
32 bits H L ACC
x
x
+
+
MACWHI instruction MACWLO instruction
0 63
ACC
Note: The location in the accumulator of the result and the appropriate sign extension are performed
in the execution of the DSP function instruction. Refer to Chapter 3 for details.
Fig. 2.1.2 DSP function instruction operation 1 (multiply, multiply and accumulate)
< word size round off > < halfword size round off >
0 63 0 63
ACC ACC
MVFACMI instruction
0 15 16 31 32 47 48 63 0 31
ACC Rsrc
MVFACHI MVFACLO
instruction instruction
MVTACHI MVTACLO
instruction instruction
0 31 0 31 32 63
Rdest ACC
Fig. 2.1.4 DSP function instruction operation 3 (transfer between accumulator and register)
These instructions determine the operation of the bit specified by the register or
memory.
There are two major instruction formats: two 16-bit instructions packed together within a
word boundary, and a single 32-bit instruction (see Figure 2.2.1). Figure 2.2.2 shows
the instruction format of M32R CPU.
1 word
address +0 +1 +2 +3
1 word
address +0 +1 +2 +3
32-bit instruction
op1 R1 op2 R2 R1 = R1 op R2
op1 R1 c R1 = R1 op c
op1 R1 op2 R2 c R1 = R2 op c
op1 R1 c R1 = R1 op c
Floating-point 3-operand
op1 Rs1 op2 Rs2 op3 Rd op4 0000
(Rd=Rs1 op Rs2)
The MSB (Most Significant Bit) of a 32-bit instruction is always "1". The MSB of a 16-bit
instruction in the high-order halfword is always "0" (instruction A in Figure 2.2.3),
however the processing of the following 16-bit instruction depends on the MSB of the
instruction.
In Figure 2.2.3, if the MSB of the instruction B is "0", instructions A and B are executed
sequentially; B is executed after A. If the MSB of the instruction B is "1", instructions A
and B are executed in parallel.
The current implementation allows only the NOP instruction as instruction B for parallel
execution. The MSB of the NOP instruction used for word arraignment adjustment is
changed to "1" automatically by a standard Mitsubishi assembler, then the M32R-FPU
can execute this instruction without requiring any clock cycles.
MSB MSB
< instruction execution sequence >
1 32-bit instruction
NOP instruction
inserted by assembler
0111 0000 0000 0000
0 16-bit instruction A 1111 0000 0000 0000 [instruction A] & [NOP] parallel
1 32-bit instruction
[Mnemonic]
Shows the mnemonic and possible operands (operation target) using assembly
language notation.
[Function]
[Description]
Describes the operation performed by the instruction and any condition bit change.
[EIT occurrence]
Shows possible EIT events (Exception, Interrupt, Trap) which may occur as the result of
the instruction's execution. Only address exception (AE), floating-point exception (FPE)
and trap (TRAP) may result from an instruction execution.
[Instruction format]
Shows the bit level instruction pattern (16 bits or 32 bits). Source and/or destination
register numbers are put in the src and dest fields as appropriate. Any immediate or
displacement value is put in the imm or disp field, its maximum size being determined by
the width of the field provided for the particular instruction. Refer to 2.2 Instruction
format for detail.
This section lists M32R-FPU instructions in alphabetical order. Each page is laid out
as shown below.
3
arithmetic oper
instruction name
(instruction type and ADD Add
full name are in center)
Add Rdest,Rsrc
arithmetic/logic operation
ADD Add ADD
[Mnemonic]
ADD Rdest,Rsrc
[Function]
Add
Rdest = Rdest + Rsrc;
[Description]
[EIT occurrence]
None
[Encoding]
[Mnemonic]
ADD3 Rdest,Rsrc,#imm16
[Function]
Add
Rdest = Rsrc + ( signed short ) imm16;
[Description]
ADD3 adds the 16-bit immediate value to Rsrc and puts the result in Rdest. The immediate
value is sign-extended to 32 bits before the operation.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
ADD3 Rdest,Rsrc,#imm16
[Mnemonic]
ADDI Rdest,#imm8
[Function]
Add
Rdest = Rdest + ( signed char ) imm8;
[Description]
ADDI adds the 8-bit immediate value to Rdest and puts the result in Rdest.
The immediate value is sign-extended to 32 bits before the operation.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
[Mnemonic]
ADDV Rdest,Rsrc
[Function]
Add
Rdest = ( signed ) Rdest + ( signed ) Rsrc;
C = overflow ? 1 : 0;
[Description]
[EIT occurrence]
None
[Encoding]
[Mnemonic]
ADDV3 Rdest,Rsrc,#imm16
[Function]
Add
Rdest = ( signed ) Rsrc + ( signed ) ( ( signed short ) imm16 );
C = overflow ? 1 : 0;
[Description]
ADDV3 adds the 16-bit immediate value to Rsrc and puts the result in Rdest. The immediate
value is sign-extended to 32 bits before it is added to Rsrc.
The condition bit (C) is set when the addition results in overflow; otherwise it is cleared.
[EIT occurrence]
None
[Encoding]
ADDV3 Rdest,Rsrc,#imm16
[Mnemonic]
ADDX Rdest,Rsrc
[Function]
Add
Rdest = ( unsigned ) Rdest + ( unsigned ) Rsrc + C;
C = carry_out ? 1 : 0;
[Description]
ADDX adds Rsrc and C to Rdest, and puts the result in Rdest.
The condition bit (C) is set when the addition result cannot be represented by a 32-bit unsigned
integer; otherwise it is cleared.
[EIT occurrence]
None
[Encoding]
[Mnemonic]
AND Rdest,Rsrc
[Function]
Logical AND
Rdest = Rdest & Rsrc;
[Description]
AND computes the logical AND of the corresponding bits of Rdest and Rsrc and puts the result
in Rdest.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
[Mnemonic]
AND3 Rdest,Rsrc,#imm16
[Function]
Logical AND
Rdest = Rsrc & ( unsigned short ) imm16;
[Description]
AND3 computes the logical AND of the corresponding bits of Rsrc and the 16-bit immediate
value, which is zero-extended to 32 bits, and puts the result in Rdest.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
AND3 Rdest,Rsrc,#imm16
branch instruction
BC Bit clear BC
M32R-FPU Extended Instruction
[Mnemonic]
(1) BC pcdisp8
(2) BC pcdisp24
[Function]
Branch
(1) if ( C==1 ) PC = ( PC & 0xfffffffc ) + ( ( ( signed char ) pcdisp8 ) << 2 );
(2) if ( C==1 ) PC = ( PC & 0xfffffffc ) + ( sign_extend ( pcdisp24 ) << 2 );
where
#define sign_extend(x) ( ( ( signed ) ( (x)<< 8 ) ) >>8 )
[Description]
BC causes a branch to the specified label when the condition bit (C) is 1.
There are two instruction formats; which allows software, such as an assembler, to decide on
the better format.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
bit operation
BCLR Bit clear BCLR
[M32R-FPU Extended Instruction]
[Mnemonic]
BCLR #bitpos,@(disp16,Rsrc)
[Function]
[Description]
BCLR reads the byte data in the memory at the address specified by the Rsrc combined with
the 16-bit displacement, and then stores the value of the bit that was specified by bitpos to be set
to 0. The displacement is sign-extended before the address calculation. bitpos becomes 0 to 7;
MSB becomes 0 and LSB becomes 7. The memory is accessed in bytes. The LOCK bit is on
while the BCLR instruction is executed, and is cleared when the execution is completed. The
LOCK bit is internal to the CPU and cannot be directly read or written to by the user.
Condition bit C remains unchanged.
The LOCK bit is internal to the CPU and is the control bit for receiving all bus right requests
from circuits other than the CPU.
Refer to the Users Manual for non-CPU bus right requests, as the handling differs according to
the type of MCU.
[EIT occurrence]
None
[Encoding]
BCLR #bitpos,@(disp16,Rsrc)
branch instruction
BEQ Branch on equal to BEQ
[Mnemonic]
BEQ Rsrc1,Rsrc2,pcdisp16
[Function]
Branch
if ( Rsrc1 == Rsrc2 ) PC = ( PC & 0xfffffffc ) + ( ( ( signed short ) pcdisp16 ) << 2);
[Description]
BEQ causes a branch to the specified label when Rsrc1 is equal to Rsrc2.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
BEQ Rsrc1,Rsrc2,pcdisp16
branch instruction
BEQZ Branch on equal to zero BEQZ
[Mnemonic]
BEQZ Rsrc,pcdisp16
[Function]
Branch
if ( Rsrc == 0 ) PC = ( PC & 0xfffffffc ) + ( ( ( signed short ) pcdisp16 ) << 2);
[Description]
BEQZ causes a branch to the specified label when Rsrc is equal to zero.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
BEQZ Rsrc,pcdisp16
branch instruction
BGEZ Branch on greater than or equal to zero BGEZ
[Mnemonic]
BGEZ Rsrc,pcdisp16
[Function]
Branch
if ( (signed) Rsrc >= 0 ) PC = ( PC & 0xfffffffc ) + ( ( ( signed short ) pcdisp16 ) << 2);
[Description]
BGEZ causes a branch to the specified label when Rsrc treated as a signed 32-bit value is
greater than or equal to zero.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
BGEZ Rsrc,pcdisp16
branch instruction
BGTZ Branch on greater than zero BGTZ
[Mnemonic]
BGTZ Rsrc,pcdisp16
[Function]
Branch
if ((signed) Rsrc > 0) PC = (PC & 0xfffffffc) + ( ( (signed short) pcdisp16 ) << 2);
[Description]
BGTZ causes a branch to the specified label when Rsrc treated as a signed 32-bit value is
greater than zero.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
BGTZ Rsrc,pcdisp16
branch instruction
BL Branch and link BL
[Mnemonic]
(1) BL pcdisp8
(2) BL pcdisp24
[Function]
[Description]
BL causes an unconditional branch to the address specified by the label and puts the return
address in R14.
There are two instruction formats; this allows software, such as an assembler, to decide on the
better format.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
branch instruction
BLEZ Branch on less than or equal to zero BLEZ
[Mnemonic]
BLEZ Rsrc,pcdisp16
[Function]
Branch
if ((signed) Rsrc <= 0) PC = (PC & 0xfffffffc) + (((signed short) pcdisp16) << 2);
[Description]
BLEZ causes a branch to the specified label when the contents of Rsrc treated as a signed 32-
bit value, is less than or equal to zero.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
BLEZ Rsrc,pcdisp16
branch instruction
BLTZ Branch on less than zero BLTZ
[Mnemonic]
BLTZ Rsrc,pcdisp16
[Function]
Branch
if ((signed) Rsrc < 0) PC = (PC & 0xfffffffc) + (((signed short) pcdisp16) << 2);
[Description]
BLTZ causes a branch to the specified label when Rsrc treated as a signed 32-bit value is less
than zero.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
BLTZ Rsrc,pcdisp16
branch instruction
BNC Branch on not C-bit BNC
[Mnemonic]
[Function]
Branch
(1) if (C==0) PC = ( PC & 0xfffffffc ) + ( ( ( signed char ) pcdisp8 ) << 2 );
(2) if (C==0) PC = ( PC & 0xfffffffc ) + ( sign_extend ( pcdisp24 ) << 2 );
where
#define sign_extend(x) ( ( ( signed ) ( (x)<< 8 ) ) >>8 )
[Description]
BNC branches to the specified label when the condition bit (C) is 0.
There are two instruction formats; this allows software, such as an assembler, to decide on the
better format.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
branch instruction
BNE Branch on not equal to BNE
[Mnemonic]
BNE Rsrc1,Rsrc2,pcdisp16
[Function]
Branch
if ( Rsrc1 != Rsrc2 ) PC = ( PC & 0xfffffffc ) + ((( signed short ) pcdisp16) << 2);
[Description]
BNE causes a branch to the specified label when Rsrc1 is not equal to Rsrc2.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
BNE Rsrc1,Rsrc2,pcdisp16
branch instruction
BNEZ Branch on not equal to zero BNEZ
[Mnemonic]
BNEZ Rsrc,pcdisp16
[Function]
Branch
if ( Rsrc != 0 ) PC = ( PC & 0xfffffffc ) + ( ( ( signed short ) pcdisp16 ) << 2);
[Description]
BNEZ causes a branch to the specified label when Rsrc is not equal to zero.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
BNEZ Rsrc,pcdisp16
branch instruction
BRA Branch BRA
[Mnemonic]
[Function]
Branch
(1) PC = ( PC & 0xfffffffc ) + ( ( ( signed char ) pcdisp8 ) << 2 );
(2) PC = ( PC & 0xfffffffc ) + ( sign_extend ( pcdisp24 ) << 2 );
where
#define sign_extend(x) ( ( ( signed ) ( (x)<< 8 ) ) >>8 )
[Description]
[EIT occurrence]
None
[Encoding]
[Mnemonic]
BSET #bitpos,@(disp16,Rsrc)
[Function]
[Description]
BSET reads the byte data in the memory at the address specified by the Rsrc combined with
the 16-bit displacement, and then stores the value of the bit that was specified by bitpos to be set
to 1. The displacement is sign-extended before the address calculation. bitpos becomes 0 to 7;
MSB becomes 0 and LSB becomes 7. The memory is accessed in bytes. The LOCK bit is on
while the BSET instruction is executed, and is cleared when the execution is completed. The
LOCK bit is internal to the CPU and cannot be directly read or written to by the user.
Condition bit C remains unchanged.
The LOCK bit is internal to the CPU and is the control bit for receiving all bus right requests
from circuits other than the CPU.
Refer to the Users Manual for non-CPU bus right requests, as the handling differs according to
the type of MCU.
[EIT occurrence]
None
[Encoding]
BSET #bitpos,@(disp16,Rsrc)
[Mnemonic]
BTST #bitpos,Rsrc
[Function]
[Description]
Take out the bit specified as bitpos within the Rsrc lower eight bits and sets it in the condition
bit (C). bitpos becomes 0 to 7, MSB becomes 0 and LSB becomes 7.
[EIT occurrence]
None
[Encoding]
[Mnemonic]
CLRPSW #imm8
[Function]
[Description]
Set the AND result s of the reverse value of b0 (MSB), b1, and b7 (LSB) of the 8-bit immediate
value and bits SM, IE, and C of PSW to the corresponding SM, IE, and C bits. When b7 (LSB) or
#imm8 is 1, the condition bit (C) goes to 0. All other bits remain unchanged.
[EIT occurrence]
None
[Encoding]
compare instruction
CMP Compare CMP
[Mnemonic]
CMP Rsrc1,Rsrc2
[Function]
Compare
C = ( ( signed ) Rsrc1 < ( signed ) Rsrc2 ) ? 1:0;
[Description]
The condition bit (C) is set to 1 when Rsrc1 is less than Rsrc2. The operands are treated as
signed 32-bit values.
[EIT occurrence]
None
[Encoding]
compare instruction
CMPI Compare immediate CMPI
[Mnemonic]
CMPI Rsrc,#imm16
[Function]
Compare
C = ( ( signed ) Rsrc < ( signed short ) imm16 ) ? 1:0;
[Description]
The condition bit (C) is set when Rsrc is less than 16-bit immediate value. The operands are
treated as signed 32-bit values. The immediate value is sign-extended to 32-bit before the opera-
tion.
[EIT occurrence]
None
[Encoding]
CMPI Rsrc,#imm16
compare instruction
CMPU Compare unsigned CMPU
[Mnemonic]
CMPU Rsrc1,Rsrc2
[Function]
Compare
C = ( ( unsigned ) Rsrc1 < ( unsigned ) Rsrc2 ) ? 1:0;
[Description]
The condition bit (C) is set when Rsrc1 is less than Rsrc2. The operands are treated as un-
signed 32-bit values.
[EIT occurrence]
None
[Encoding]
compare instruction
CMPUI Compare unsigned immediate CMPUI
[Mnemonic]
CMPUI Rsrc,#imm16
[Function]
Compare
C = ( ( unsigned ) Rsrc < ( unsigned ) ( ( signed short ) imm16 ) ) ? 1:0;
[Description]
The condition bit (C) is set when Rsrc is less than the 16-bit immediate value. The operands
are treated as unsigned 32-bit values. The immediate value is sign-extended to 32-bit before the
operation.
[EIT occurrence]
None
[Encoding]
CMPUI Rsrc,#imm16
[Mnemonic]
DIV Rdest,Rsrc
[Function]
Signed division
Rdest = ( signed ) Rdest / ( signed ) Rsrc;
[Description]
[EIT occurrence]
None
[Encoding]
DIV Rdest,Rsrc
[Mnemonic]
DIVU Rdest,Rsrc
[Function]
Unsigned division
Rdest = ( unsigned ) Rdest / ( unsigned ) Rsrc;
[Description]
[EIT occurrence]
None
[Encoding]
DIVU Rdest,Rsrc
floating-point Instructions
FADD Floating-point add FADD
[M32R-FPU Extended Instruction]
[Mnemonic]
FADD Rdest,Rsrc1,Rsrc2
[Function]
Floating-point add
Rdest = Rsrc1 + Rsrc2 ;
[Description]
Add the floating-point single precision values stored in Rsrc1 and Rsrc2 and store the result in
Rdest. The result is rounded according to the RM field of FPSR. The DN bit of FPSR handles the
modification of denormalized numbers. The condition bit (C) remains unchanged.
[EIT occurrence]
[Encoding]
FADD Rdest,Rsrc1,Rsrc2
The following shows the values of Rsrc1 and Rsrc2 and the operation results when DN = 0 and
DN = 1.
DN = 0
Rsrc2
Normalized Denormalized
Number +0 -0 +Infinity -Infinity Number QNaN SNaN
Normalized
Number add
+0 +0 (Note) -Infinity
-0 (Note) -0
+Infinity +Infinity IVLD
Rsrc1
-Infinity -Infinity IVLD -Infinity
Denormalized
Number UIPL
QNaN QNaN
SNaN IVLD
DN = 1
Rsrc2
Normalized
Number +0, + Denormalized
Number -0, - Denormalized
Number +Infinity -Infinity QNaN SNaN
Normalized Number Normalized
add Number
+0, + Denormalized
Number Normalized
+0 (Note) -Infinity
Number
-0, - Denormalized
Number (Note) -0
Rsrc1 +Infinity +Infinity IVLD
-Infinity -Infinity IVLD -Infinity
QNaN QNaN
SNaN IVLD
Note: The rounding mode is -0 when rounding toward -Infinity, and +0 when rounding
toward any other direction.
[Mnemonic]
FCMP Rdest,Rsrc1,Rsrc2
[Function]
Floating-point compare
Rdest = (comparison results of Rsrc1 and Rsrc2);
When at least one value, either Rsrc1 or Rsrc2, is SNaN, a floating-point exception (other than
Invalid Operation Exception) occurs.
[Description]
Compare the floating-point single precision values stored in Rsrc1 and Rsrc2 and store the
result in Rdest. The results of the comparison can be determined y the following methods.
The DN bit of FPSR handles the conversion of denormalized numbers. The condition bit (C)
remains unchanged.
[EIT occurrence]
[Encoding]
FCMP Rdest,Rsrc1,Rsrc2
The following shows the values of Rsrc1 and Rsrc2 and the operation results when DN = 0 and
DN = 1.
DN = 0
Rsrc2
Normalized Denormalized
Number +0 -0 +Infinity -Infinity Number QNaN SNaN
Normalized
Number comparison
+0 -Infinity
00000000 +Infinity
-0
+Infinity +Infinity 00000000
Rsrc1
-Infinity -Infinity 00000000
Denormalized
Number UIPL
comparison
QNaN invalid
SNaN IVLD
DN = 1
Rsrc2
Normalized
Number
+0, + Denormalized
Number -0, - Denormalized
Number +Infinity -Infinity QNaN SNaN
Normalized Number
comparison
+0, + Denormalized
Number
-Infinity
00000000 +Infinity
-0, - Denormalized
Number
floating-point Instructions
FCMPE Floating-point compare with exception FCMPE
if unordered
[M32R-FPU Extended Instruction]
[Mnemonic]
FCMPE Rdest,Rsrc1,Rsrc2
[Function]
Floating-point compare
Rdest = (comparison results of Rsrc1 and Rsrc2);
When at least one value, either Rsrc1 or Rsrc2, is QNaN or SNaN, a floating-point exception
(other than Invalid Operation Exception) occurs.
[Description]
Compare the floating-point single precision values stored in Rsrc1 and Rsrc2 and store the
result in Rdest. The results of the comparison can be determined y the following methods.
The DN bit of FPSR handles the conversion of denormalized numbers. The condition bit (C)
remains unchanged.
[EIT occurrence]
[Encoding]
FCMPE Rdest,Rsrc1,Rsrc2
The following shows the values of Rsrc1 and Rsrc2 and the operation results when DN = 0 and
DN = 1.
DN = 0
Rsrc2
Normalized Denormalized
Number +0 -0 +Infinity -Infinity Number QNaN SNaN
Normalized
Number comparison
+0 -Infinity
00000000 +Infinity
-0
+Infinity +Infinity 00000000
Rsrc1
-Infinity -Infinity 00000000
Denormalized
Number UIPL
QNaN
IVLD
SNaN
DN = 1
Rsrc2
Normalized
Number
+0, + Denormalized
Number -0, - Denormalized
Number +Infinity -Infinity QNaN SNaN
Normalized Number comparison
+0, + Denormalized
Number
-Infinity
Denormalized
00000000 +Infinity
-0, - Number
floating-point Instructions
FDIV Floating-point divide FDIV
[M32R-FPU Extended Instruction]
[Mnemonic]
FDIV Rdest,Rsrc1,Rsrc2
[Function]
Floating-point divide
Rdest = Rsrc1 / Rsrc2 ;
[Description]
Divide the floating-point single precision value stored in Rsrc1 by the floating-point single pre-
cision value stored in Rsrc1 and store the result in Rdest. The result is rounded according to the
RM field of FPSR. The DN bit of FPSR handles the modification of denormalized numbers. The
condition bit (C) remains unchanged.
[EIT occurrence]
[Encoding]
FDIV Rdest,Rsrc1,Rsrc2
The following shows the values of Rsrc1 and Rsrc2 and the operation results when DN = 0 and
DN = 1.
DN = 0
Rsrc2
Normalized Denormalized
Number +0 -0 +Infinity -Infinity Number QNaN SNaN
Normalized
Number divide DIV0 0
+0 +0 -0
0 IVLD
-0 -0 +0
+Infinity +Infinity -Infinity
Rsrc1 Infinity IVLD
-Infinity -Infinity +Infinity
Denormalized
Number UIPL
QNaN QNaN
SNaN IVLD
DN = 1
Rsrc2
Normalized +0, + Denormalized -0, - Denormalized +Infinity -Infinity QNaN SNaN
Number Number Number
Normalized Number
divide DIV0 0
+0, + Denormalized
Number +0 -0
0 IVLD
-0, - Denormalized
Number -0 +0
Rsrc1 +Infinity +Infinity -Infinity
Infinity IVLD
-Infinity -Infinity +Infinity
QNaN QNaN
SNaN IVLD
floating-point Instructions
FMADD Floating-point multiply and add FMADD
[M32R-FPU Extended Instruction]
[Mnemonic]
FMADD Rdest,Rsrc1,Rsrc2
[Function]
[Description]
Step 2
Add the result of Step 1 (the rounded value) and the floating-point single precision value stored
in Rdest. The result is rounded according to the RM field of FPSR.
The result of this operation is stored in Rdest. Exceptions are determined in both Step 1 and
Step 2. The DN bit of FPSR handles the conversion of denormalized numbers. The condition bit
(C) remains unchanged.
[EIT occurrence]
[Encoding]
FMADD Rdest,Rsrc1,Rsrc2
The following shows the values of Rsrc1, Rsrc2 and Rdest and the operation results when DN
= 0 and DN = 1.
DN=0
Note: The rounding mode is -0 when rounding toward -Infinity, and +0 when rounding
toward any other direction.
DN=1
Note: The rounding mode is -0 when rounding toward -Infinity, and +0 when rounding
toward any other direction.
floating-point Instructions
FMSUB Floating-point multiply and subtract FMSUB
[M32R-FPU Extended Instruction]
[Mnemonic]
FMSUB Rdest,Rsrc1,Rsrc2
[Function]
[Description]
Step 2
Subtract the result (rounded value) of Step 1 from the floating-point single precision value
stored in Rdest.
The subtraction result is rounded according to the RM field of FPSR.
The result of this operation is stored in Rdest. Exceptions are determined in both Step 1 and
Step 2. The DN bit of FPSR handles the conversion of denormalized numbers. The condition bit
(C) remains unchanged.
[EIT occurrence]
[Encoding]
1101 src1 0000 src2 0011 dest 0100 0000
FMSUB Rdest,Rsrc1,Rsrc2
The following shows the values of Rsrc1, Rsrc2 and Rdest and the operation results when DN
= 0 and DN = 1.
DN=0
Note: The rounding mode is -0 when rounding toward -Infinity, and +0 when rounding
toward any other direction.
DN=1
-0 -0 (Note)
Rdest +Infinity +Infinity IVLD
-Infinity -Infinity IVLD
QNaN QNaN
SNaN IVLD
Note: The rounding mode is -0 when rounding toward -Infinity, and +0 when rounding
toward any other direction.
floating-point Instructions
FMUL Floating-point multiply FMUL
[M32R-FPU Extended Instruction]
[Mnemonic]
FMUL Rdest,Rsrc1,Rsrc2
[Function]
Floating-point multiply
Rdest = Rsrc1 * Rsrc2 ;
[Description]
Multiply the floating-point single precision value stored in Rsrc1 by the floating-point single
precision value stored in Rsrc2 and store the results in Rdest. The result is rounded according to
the RM field of FPSR. The DN bit of FPSR handles the modification of denormalized numbers.
The condition bit (C) remains unchanged.
[EIT occurrence]
[Encoding]
FMUL Rdest,Rsrc1,Rsrc2
The following shows the values of Rsrc1 and Rsrc2 and the operation results when DN = 0 and
DN = 1.
DN=0
Rsrc2
Normalized Denormalized
Number +0 -0 +Infinity -Infinity Number QNaN SNaN
Normalized
Number Multiplication Infinity
+0 +0 -0
IVLD
-0 -0 +0
+Infinity +Infinity -Infinity
Rsrc1 Infinity IVLD
-Infinity -Infinity +Infinity
Denormalized
Number UIPL
QNaN QNaN
SNaN IVLD
DN=1
Rsrc2
Normalized
Number +0, +Denormalized
Number -0, - Denormalized
Number +Infinity -Infinity QNaN SNaN
Normalized
Number Multiplication Infinity
+0, + Denormalized
Number +0 -0
IVLD
-0, - Denormalized
Number -0 +0
Rsrc1 +Infinity +Infinity -Infinity
Infinity IVLD
-Infinity -Infinity +Infinity
QNaN QNaN
SNaN IVLD
floating-point Instructions
FSUB Floating-point subtract FSUB
[M32R-FPU Extended Instruction]
[Mnemonic]
FSUB Rdest,Rsrc1,Rsrc2
[Function]
Floating-point subtract
Rdest = Rsrc1 - Rsrc2 ;
[Description]
Subtract the floating-point single precision value stored in Rsrc2 from the floating-point single
precision value stored in Rsrc1 and store the results in Rdest. The result is rounded according to
the RM field of FPSR. The DN bit of FPSR handles the modification of denormalized numbers.
The condition bit (C) remains unchanged.
[EIT occurrence]
[Encoding]
FSUB Rdest,Rsrc1,Rsrc2
The following shows the values of Rsrc1 and Rsrc2 and the operation results when DN = 0 and
DN = 1.
DN = 0
Rsrc2
Normalized Denormalized
Number +0 -0 +Infinity -Infinity Number QNaN SNaN
Normalized
Number Subtraction
+0 (Note) +0 -Infinity +Infinity
-0 -0 (Note)
+Infinity +Infinity IVLD
Rsrc1
-Infinity -Infinity IVLD
Denormalized
Number UIPL
QNaN QNaN
SNaN IVLD
DN = 1
Rsrc2
Normalized +0, + Denormalized -0, - Denormalized
Number Number Number +Infinity -Infinity QNaN SNaN
Normalized Number Subtraction
+0, + Denormalized
Number (Note) +0 -Infinity
+Infinity
-0, - Denormalized
Number -0 (Note)
Rsrc1 +Infinity +Infinity IVLD
-Infinity -Infinity IVLD
QNaN QNaN
SNaN IVLD
Note: The rounding mode is -0 when rounding toward -Infinity, and +0 when rounding
toward any other direction.
floating-point Instructions
FTOI Float to Integer FTOI
[M32R-FPU Extended Instruction]
[Mnemonic]
FTOI Rdest,Rsrc
[Function]
[Description]
Convert the floating-point single precision value stored in Rsrc to a 32-bit integer and store the
result in Rdest.
The result is rounded toward 0 regardless of the value in the RM field of FPSR. The condition
bit (C) remains unchanged.
[EIT occurrence]
[Encoding]
FTOI Rdest,Rsrc
The results of the FTOI instruction executed based on the Rsrc value, both when DN = 0 and DN = 1,
are shown in below.
DN = 0
Rsrc Value (exponent with no bias) Rdest Exception
Rsrc 0 +Infinity When EIT occurs: no change Invalid Operation Exception
127 exp 31 Other EIT: H'7FFF FFFF
30 exp -126 H'0000 0000 to H'7FFF FF80 No change (Note 1)
+Denormalized value No change Unimplemented Exception
+0 H'0000 0000 No change
Rsrc < 0 -0
-Denormalized value No change Unimplemented Exception
30 exp -126 H'0000 0000 to H'8000 0080 No change (Note 1)
127 exp 31 When EIT occurs: no change Invalid Operation Exception
-Infinity Other EIT: H'8000 0080 (Note 2)
NaN QNaN When EIT occurs: no change Invalid Operation Exception
Other EIT:
SNaN Signed bit = 0:H7FFF FFFF
Signed bit = 1:H8000 0000
Note 1: Inexact Exception occurs when rounding is performed.
2: Inexact Exception does not occur when Rsrc = HCF00 0000.
DN = 1
Rsrc Value (exponent with no bias) Rdest Exception
Rsrc 0 +Infinity When EIT occurs: no change Invalid Operation Exception
127 exp 31 Other EIT: H'7FFF FFFF
30 exp -126 H'0000 0000 to H'7FFF FF80 No change (Note 1)
+0, +Denormalized value H'0000 0000 No change
Rsrc < 0 -0, -Denormalized value
30 exp -126 H'0000 0000 to H'8000 0080 No change (Note 1)
127 exp 31 When EIT occurs: no change Invalid Operation Exception
-Infinity Other EIT: H'8000 0000 (Note 2)
NaN QNaN When EIT occurs: no change Invalid Operation Exception
Other EIT:
SNaN Signed bit = 0:H7FFF FFFF
Signed bit = 1:H8000 0000
Note 1: Inexact Exception occurs when rounding is performed.
2: Inexact Exception does not occur when Rsrc = HCF00 0000.
floating-point Instructions
FTOS Float to short FTOS
[M32R-FPU Extended Instruction]
[Mnemonic]
FTOS Rdest,Rsrc
[Function]
[Description]
Convert the floating-point single precision value stored in Rsrc to a 16-bit integer and store the
result in Rdest.
The result is rounded toward 0 regardless of the value in the RM field of FPSR. The condition
bit (C) remains unchanged.
[EIT occurrence]
[Encoding]
FTOS Rdest,Rsrc
DN = 0
Rsrc Value (exponent with no bias) Rdest Exception
Rsrc 0 +Infinity When EIT occurs: no change Invalid Operation Exception
127 exp 15 Other EIT: H'0000 7FFFF
14 exp -126 H'0000 0000 to H'0000 7FFF No change (Note 1)
+Denormalized value No change Unimplemented Exception
+0 H'0000 0000 No change
Rsrc < 0 -0
-Denormalized value No change Unimplemented Exception
14 exp -126 H'0000 0000 to H'FFFF 8001 No change (Note 1)
127 exp 15 When EIT occurs: no change Invalid Operation Exception
-Infinity Other EIT: HFFFF 8000 (Note 2)
NaN QNaN When EIT occurs: no change Invalid Operation Exception
Other EIT:
SNaN Signed bit = 0:H0000 7FFF
Signed bit = 1:HFFFF 8000
Note 1: Inexact Exception occurs when rounding is performed.
2: Inexact Exception does not occur when Rsrc = HCF00 0000.
DN = 1
Rsrc Value (exponent with no bias) Rdest Exception
Rsrc 0 +Infinity When EIT occurs: no change Invalid Operation Exception
127 exp 15 Other EIT: H'0000 7FFF
14 exp -126 H'0000 0000 to H'0000 7FFF No change (Note 1)
+0, +Denormalized value H'0000 0000 No change
Rsrc < 0 -0, -Denormalized value
14 exp -126 H'0000 0000 to H'FFFF 8001 No change (Note 1)
127 exp 15 When EIT occurs: no change Invalid Operation Exception
-Infinity Other EIT: H'FFFF 8000 (Note 2)
NaN QNaN When EIT occurs: no change Invalid Operation Exception
Other EIT:
SNaN Signed bit = 0:H0000 7FFF
Signed bit = 1:HFFFF 8000
Note 1: Inexact Exception occurs when rounding is performed.
2: No Exceptions occur when Rsrc = HC700 0000. When Rsrc = HC700 0001 to HC700 00FF,
the Inexact Exception occurs and the Invalid Operation Exception does not occur.
floating-point Instructions
ITOF Integer to float ITOF
[M32R-FPU Extended Instruction]
[Mnemonic]
ITOF Rdest,Rsrc
[Function]
[Description]
Converts the 32-bit integer stored in Rsrc to a floating-point single precision value and stores
the result in Rdest. The result is rounded according to the RM field of FPSR. The condition bit (C)
remains unchanged. H0000 0000 is handled as +0 regardless of the Rounding Mode.
[EIT occurrence]
[Encoding]
ITOF Rdest,Rsrc
branch instruction
JL Jump and link JL
[Mnemonic]
JL Rsrc
[Function]
[Description]
JL causes an unconditional jump to the address specified by Rsrc and puts the return address
in R14.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
branch instruction
JMP Jump JMP
[Mnemonic]
JMP Rsrc
[Function]
Jump
PC = Rsrc & 0xfffffffc;
[Description]
[EIT occurrence]
None
[Encoding]
load/store instruction
LD Load LD
[Mnemonic]
(1) LD Rdest,@Rsrc
(2) LD Rdest,@Rsrc+
(3) LD Rdest,@(disp16,Rsrc)
[Function]
[Description]
(1) The contents of the memory at the address specified by Rsrc are loaded into Rdest.
(2) The contents of the memory at the address specified by Rsrc are loaded into Rdest.
Rsrc is post incremented by 4.
(3) The contents of the memory at the address specified by Rsrc combined with the 16-
bit displacement are loaded into Rdest.
The displacement value is sign-extended to 32 bits before the address calculation.
The condition bit (C) is unchanged.
[EIT occurrence]
[Encoding]
LD Rdest,@(disp16,Rsrc)
load/store instruction
LD24 Load 24-bit immediate LD24
[Mnemonic]
LD24 Rdest,#imm24
[Function]
[Description]
LD24 loads the 24-bit immediate value into Rdest. The immediate value is zero-extended to 32
bits.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
LD24 Rdest,#imm24
load/store instruction
LDB Load byte LDB
[Mnemonic]
[Function]
[Description]
(1) LDB sign-extends the byte data of the memory at the address specified by Rsrc and loads
it into Rdest.
(2) LDB sign-extends the byte data of the memory at the address specified by Rsrc combined
with the 16-bit displacement, and loads it into Rdest.
The displacement value is sign-extended to 32 bits before the address calculation.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
LDB Rdest,@(disp16,Rsrc)
load/store instruction
LDH Load halfword LDH
[Mnemonic]
[Function]
[Description]
(1) LDH sign-extends the halfword data of the memory at the address specified by Rsrc and
loads it into Rdest.
(2) LDH sign-extends the halfword data of the memory at the address specified by Rsrc
combined with the 16-bit displacement, and loads it into Rdest.
The displacement value is sign-extended to 32 bits before the address calculation.
The condition bit (C) is unchanged.
[EIT occurrence]
[Encoding]
LDH Rdest,@(disp16,Rsrc)
transfer instruction
LDI Load immediate LDI
[Mnemonic]
[Function]
[Description]
[EIT occurrence]
None
[Encoding]
LDI Rdest,#imm16
load/store instruction
LDUB Load unsigned byte LDUB
[Mnemonic]
[Function]
[Description]
(1) LDUB zero-extends the byte data from the memory at the address specified by Rsrc and
loads it into Rdest.
(2) LDUB zero-extends the byte data of the memory at the address specified by Rsrc com-
bined
with the 16-bit displacement, and loads it into Rdest.
The displacement value is sign-extended to 32 bits before address calculation.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
LDUB Rdest,@(disp16,Rsrc)
load/store instruction
LDUH Load unsigned halfword LDUH
[Mnemonic]
[Function]
[Description]
(1) LDUH zero-extends the halfword data from the memory at the address specified by Rsrc
and loads it into Rdest.
(2) LDUH zero-extends the halfword data in memory at the address specified by Rsrc com-
bined
with the 16-bit displacement, and loads it into Rdest.
The displacement value is sign-extended to 32 bits before the address calculation.
The condition bit (C) is unchanged.
[EIT occurrence]
[Encoding]
LDUH Rdest,@(disp16,Rsrc)
load/store instruction
LOCK Load locked LOCK
[Mnemonic]
LOCK Rdest,@Rsrc
[Function]
Load locked
LOCK = 1, Rdest = *( int *) Rsrc;
[Description]
The contents of the word at the memory location specified by Rsrc are loaded into Rdest. The
condition bit (C) is unchanged.
This instruction sets the LOCK bit in addition to simple loading.
When the LOCK bit is 1, external bus master access is not accepted.
The LOCK bit is cleared by executing the UNLOCK instruction.
The LOCK bit is located in the CPU and operates based on the LOCK and UNLOCK instruc-
tions. The user cannot directly read or write to this bit.
The LOCK bit is internal to the CPU and is the control bit for receiving all bus right requests
from circuits other than the CPU.
Refer to the Users Manual for non-CPU bus right requests, as the handling differs according to
the type of MCU.
[EIT occurrence]
[Encoding]
[Mnemonic]
MACHI Rsrc1,Rsrc2
[Function]
[Description]
MACHI multiplies the high-order 16 bits of Rsrc1 and the high-order 16 bits of Rsrc2, then adds
the result to the low-order 56 bits in the accumulator.
The LSB of the multiplication result is aligned with bit 47 in the accumulator, and the portion
corresponding to bits 8 through 15 of the accumulator is sign-extended before addition. The
result of the addition is stored in the accumulator. The high-order 16 bits of Rsrc1 and Rsrc2 are
treated as signed values.
The condition bit (C) is unchanged.
0 15 16 31
high-order 16 bits Rsrc1
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MACLO Rsrc1,Rsrc2
[Function]
[Description]
MACLO multiplies the low-order 16 bits of Rsrc1 and the low-order 16 bits of Rsrc2, then adds
the result to the low order 56 bits in the accumulator.
The LSB of the multiplication result is aligned with bit 47 in the accumulator, and the portion
corresponding to bits 8 through 15 of the accumulator is sign-extended before addition. The
result of the addition is stored in the accumulator. The low-order 16 bits of Rsrc1 and Rsrc2 are
treated as signed values.
The condition bit (C) is unchanged.
0 15 16 31
low-order 16 bits Rsrc1
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MACWHI Rsrc1,Rsrc2
[Function]
[Description]
MACWHI multiplies the 32 bits of Rsrc1 and the high-order 16 bits of Rsrc2, then adds the
result to the low-order 56 bits in the accumulator.
The LSB of the multiplication result is aligned with the LSB of the accumulator, and the portion
corresponding to bits 8 through 15 of the accumulator is sign extended before addition. The
result of addition is stored in the accumulator. The 32 bits of Rsrc1 and the high-order 16 bits of
Rsrc2 are treated as signed values.
The condition bit (C) is unchanged.
0 15 16 31
32 bits Rsrc1
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MACWLO Rsrc1,Rsrc2
[Function]
[Description]
MACWLO multiplies the 32 bits of Rsrc1 and the low-order 16 bits of Rsrc2, then adds the
result to the low-order 56 bits in the accumulator.
The LSB of the multiplication result is aligned with the LSB of the accumulator, and the portion
corresponding to bits 8 through 15 of the accumulator is sign-extended before the addition. The
result of the addition is stored in the accumulator. The 32 bits Rsrc1 and the low-order 16 bits of
Rsrc2 are treated as signed values.
The condition bit (C) is unchanged.
0 15 16 31
32 bits Rsrc1
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MUL Rdest,Rsrc
[Function]
Multiply
{ signed64bit tmp;
tmp = ( signed64bit ) Rdest * ( signed64bit ) Rsrc;
Rdest = ( int ) tmp;}
[Description]
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MULHI Rsrc1,Rsrc2
[Function]
Multiply
accumulator = (( signed) (Rsrc1 & 0xffff000 ) * (signed short) (Rsrc2 >> 16));
[Description]
MULHI multiplies the high-order 16 bits of Rsrc1 and the high-order 16 bits of Rsrc2, and
stores the result in the accumulator.
However, the LSB of the multiplication result is aligned with bit 47 in the accumulator, and the
portion corresponding to bits 0 through 15 of the accumulator is sign-extended. Bits 48 through
63 of the accumulator are cleared to 0. The high-order 16 bits of Rsrc1 and Rsrc2 are treated as
signed values.
The condition bit (C) is unchanged.
0 15 16 31
high-order 16 bits Rsrc1
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MULLO Rsrc1,Rsrc2
[Function]
Multiply
accumulator = ( ( signed ) ( Rsrc1 << 16 ) * ( signed short ) Rsrc2 );
[Description]
MULLO multiplies the low-order 16 bits of Rsrc1 and the low-order 16 bits of Rsrc2, and stores
the result in the accumulator.
The LSB of the multiplication result is aligned with bit 47 in the accumulator, and the portion
corresponding to bits 0 through 15 of the accumulator is sign extended. Bits 48 through 63 of the
accumulator are cleared to 0. The low-order 16 bits of Rsrc1 and Rsrc2 are treated as signed
values.
The condition bit (C) is unchanged.
0 15 16 31
low-order 16 bits Rsrc1
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MULWHI Rsrc1,Rsrc2
[Function]
Multiply
accumulator = ( ( signed ) Rsrc1 * ( signed short ) ( Rsrc2 >> 16 ) );
[Description]
MULWHI multiplies the 32 bits of Rsrc1 and the high-order 16 bits of Rsrc2, and stores the
result in the accumulator.
The LSB of the multiplication result is aligned with the LSB of the accumulator, and the portion
corresponding to bits 0 through 15 of the accumulator is sign-extended. The 32 bits of Rsrc1 and
high-order 16 bits of Rsrc2 are treated as signed values.
The condition bit (C) is unchanged.
0 15 16 31
32 bits Rsrc1
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MULWLO Rsrc1,Rsrc2
[Function]
Multiply
accumulator = ( ( signed ) Rsrc1 * ( signed short ) Rsrc2 );
[Description]
MULWLO multiplies the 32 bits of Rsrc1 and the low-order 16 bits of Rsrc2, and stores the
result in the accumulator.
The LSB of the multiplication result is aligned with the LSB of the accumulator, and the portion
corresponding to bits 0 through 15 of the accumulator is sign extended. The 32 bits of Rsrc1 and
low-order 16 bits of Rsrc2 are treated as signed values.
The condition bit (C) is unchanged.
0 15 16 31
32 bits Rsrc1
[EIT occurrence]
None
[Encoding]
transfer instruction
MV Move register MV
[Mnemonic]
MV Rdest,Rsrc
[Function]
Transfer
Rdest = Rsrc;
[Description]
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MVFACHI Rdest
[Function]
[Description]
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MVFACLO Rdest
[Function]
[Description]
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MVFACMI Rdest
[Function]
[Description]
[EIT occurrence]
None
[Encoding]
transfer instruction
MVFC Move from control register MVFC
[Mnemonic]
MVFC Rdest,CRsrc
[Function]
[Description]
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MVTACHI Rsrc
[Function]
[Description]
[EIT occurrence]
None
[Encoding]
[Mnemonic]
MVTACLO Rsrc
[Function]
[Description]
[EIT occurrence]
None
[Encoding]
transfer instruction
MVTC Move to control register MVTC
[Mnemonic]
MVTC Rsrc,CRdest
[Function]
[Description]
[EIT occurrence]
None
[Encoding]
[Mnemonic]
NEG Rdest,Rsrc
[Function]
Negate
Rdest = 0 Rsrc ;
[Description]
NEG negates (changes the sign of) Rsrc treated as a signed 32-bit value, and puts the result
in Rdest.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
branch instruction
NOP No operation NOP
[Mnemonic]
NOP
[Function]
No operation
/* */
[Description]
[EIT occurrence]
None
[Encoding]
[Mnemonic]
NOT Rdest,Rsrc
[Function]
Logical NOT
Rdest = ~ Rsrc ;
[Description]
NOT inverts each of the bits of Rsrc and puts the result in Rdest.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
[Mnemonic]
OR Rdest,Rsrc
[Function]
Logical OR
Rdest = Rdest | Rsrc ;
[Description]
OR computes the logical OR of the corresponding bits of Rdest and Rsrc, and puts the result
in Rdest.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
[Mnemonic]
OR3 Rdest,Rsrc,#imm16
[Function]
Logical OR
Rdest = Rsrc | ( unsigned short ) imm16 ;
[Description]
OR3 computes the logical OR of the corresponding bits of Rsrc and the 16-bit immediate
value, which is zero-extended to 32 bits, and puts the result in Rdest.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
OR3 Rdest,Rsrc,#imm16
[Mnemonic]
RAC
[Function]
Saturation Process
{ signed64bit tmp;
tmp = ( signed64bit ) accumulator << 1;
tmp = tmp + 0x0000 0000 0000 8000;
if( 0x0000 7fff ffff 0000 < tmp )
accumulator = 0x0000 7fff ffff 0000;
else if( tmp < 0xffff 8000 0000 0000 )
accumulator = 0xffff 8000 0000 0000;
else
accumulator = tmp & 0xffff ffff ffff 0000; }
[Description]
RAC rounds the contents in the accumulator to word size and stores the result in the accumu-
lator.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
[Supplement]
<step 1>
0 8 16 32 48 63
0
0 8 16 32 47 48 63
<step 2>
The value in the accumulator is altered depending on the supposed bit 80 through 7 after
left-shift operation and bit 8 through bit 63 after shift operation.
8 16 32 48 63
Value in Adest after the
execution of the RAC instruction
0 8 63
00 00 7FFF FFFF 0000
positive 47 48
0000 7FFF FFFF 8000 8 63
value 0000 7FFF FFFF 7FFF 0
if bit 48 is 0 , there is no carry.
0000 0000 0000 0000 if bit 48 is 1 , the bit is carried.
Bits 48 to 63 are cleared to zero.
8 48 63
FFFF 8000 0000 8000
0
FFFF 8000 0000 7FFF
negative
value
0 8 63
FF FF 8000 0000 0000
[Mnemonic]
RACH
[Function]
Saturation Process
{ signed64bit tmp;
tmp = ( signed64bit ) accumulator << 1;
tmp = tmp + 0x0000 0000 8000 0000;
if( 0x0000 7fff 0000 0000 < tmp )
accumulator = 0x0000 7fff 0000 0000;
else if( tmp < 0xffff 8000 0000 0000 )
accumulator = 0xffff 8000 0000 0000;
else
accumulator = tmp & 0xffff ffff 0000 0000; }
[Description]
RACH rounds the contents in the accumulator to halfword size and stores the result in the
accumulator.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
[Supplement]
<proccess 1>
0 8 16 32 48 63
0
0 8 16 32 47 48 63
<proccess 2>
The value in the accumulator is altered depending on the supposed bit 80 through 7 after
left-shift operation and bit 8 through bit 63 after shift operation.
8 16 32 48 63
Value in Adest after the
execution of the RAC instruction
0 8 63
00 00 7FFF FFFF 0000
positive 31 32
0000 7FFE 8000 0000 8 63
value 0000 7FFE 7FFF 7FFF 0 0
if bit 32 is 0 , there is no carry.
0000 0000 0000 0000 if bit 32 is 1 , the bit is carried.
sign extension Bits 32 to 63 are cleared to zero.
0 8 48 63
FFFF 8000 8000 0000
0 0
FFFF 8000 7FFF FFFF
negative
value
0 8 63
FF FF 8000 0000 0000
[Mnemonic]
REM Rdest,Rsrc
[Function]
Signed remainder
Rdest = ( signed ) Rdest % ( signed ) Rsrc ;
[Description]
REM divides Rdest by Rsrc and puts the quotient in Rdest. The operands are treated as
signed 32-bit values.
The quotient is rounded toward zero and the quotient takes the same sign as the dividend.
The condition bit (C) is unchanged.
When Rsrc is zero, Rdest is unchanged.
[EIT occurrence]
None
[Encoding]
REM Rdest,Rsrc
[Mnemonic]
REMU Rdest,Rsrc
[Function]
Unsigned remainder
Rdest = ( unsigned ) Rdest % ( unsigned ) Rsrc ;
[Description]
[EIT occurrence]
None
[Encoding]
REMU Rdest,Rsrc
EIT-related instruction
RTE Return from EIT RTE
[Mnemonic]
RTE
[Function]
[Description]
RTE restores the SM, IE and C bits of the PSW from the BSM, BIE and BC bits, and jumps to
the address specified by BPC.
At this time, because the BSM, BIE, and BC bits in the PSW register are undefined, the BPC is
also undefined.
[EIT occurrence]
None
[Encoding]
Transfer instructions
SETH Set high-order 16-bit SETH
[Mnemonic]
SETH Rdest,#imm16
[Function]
Transfer instructions
Rdest = ( signed short ) imm16 << 16 ;
[Description]
SETH load the immediate value into the 16 most significant bits of Rdest.
The 16 least significant bits become zero.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
SETH Rdest,#imm16
[Mnemonic]
SETPSW #imm8
[Function]
[Description]
Set the AND result of the value of b0 (MSB), b1, and b7 (LSB) of the 8-bit immediate value and
bits SM, IE, and C of PSW to the corresponding SM, IE, and C bits. When b7 (LSB) or #imm8 is
1, the condition bit (C) goes to 0. All other bits remain unchanged.
[EIT occurrence]
None
[Encoding]
[Note]
shift instruction
SLL Shift left logical SLL
[Mnemonic]
SLL Rdest,Rsrc
[Function]
[Description]
SLL left logical-shifts the contents of Rdest by the number specified by Rsrc, shifting zeroes
into the least significant bits.
Only the five least significant bits of Rsrc are used.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
shift instruction
SLL3 Shift left logical 3-operand SLL3
[Mnemonic]
SLL3 Rdest,Rsrc,#imm16
[Function]
[Description]
SLL3 left logical-shifts the contents of Rsrc into Rdest by the number specified by the 16-bit
immediate value, shifting zeroes into the least significant bits.
Only the five least significant bits of the 16-bit immediate value are used.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
SLL3 Rdest,Rsrc,#imm16
shift instruction
SLLI Shift left logical immediate SLLI
[Mnemonic]
SLLI Rdest,#imm5
[Function]
[Description]
SLLI left logical-shifts the contents of Rdest by the number specified by the 5-bit immediate
value, shifting zeroes into the least significant bits.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
shift instruction
SRA Shift right arithmetic SRA
[Mnemonic]
SRA Rdest,Rsrc
[Function]
[Description]
SRA right arithmetic-shifts the contents of Rdest by the number specified by Rsrc, replicates
the sign bit in the MSB of Rdest and puts the result in Rdest.
Only the five least significant bits are used.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
shift instruction
SRA3 Shift right arithmetic 3-operand SRA3
[Mnemonic]
SRA3 Rdest,Rsrc,#imm16
[Function]
[Description]
SRA3 right arithmetic-shifts the contents of Rsrc into Rdest by the number specified by the 16-
bit immediate value, replicates the sign bit in Rsrc and puts the result in Rdest.
Only the five least significant bits are used.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
SRA3 Rdest,Rsrc,#imm16
shift instruction
SRAI Shift right arithmetic immediate SRAI
[Mnemonic]
SRAI Rdest,#imm5
[Function]
[Description]
SRAI right arithmetic-shifts the contents of Rdest by the number specified by the 5-bit immedi-
ate value, replicates the sign bit in MSB of Rdest and puts the result in Rdest.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
shift instruction
SRL Shift right logical SRL
[Mnemonic]
SRL Rdest,Rsrc
[Function]
[Description]
SRL right logical-shifts the contents of Rdest by the number specified by Rsrc, shifts zeroes
into the most significant bits and puts the result in Rdest.
Only the five least significant bits of Rsrc are used.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
shift instruction
SRL3 Shift right logical 3-operand SRL3
[Mnemonic]
SRL3 Rdest,Rsrc,#imm16
[Function]
[Description]
SRL3 right logical-shifts the contents of Rsrc into Rdest by the number specified by the 16-bit
immediate value, shifts zeroes into the most significant bits. Only the five least significant bits of
the immediate value are valid.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
SRL3 Rdest,Rsrc,#imm16
shift instruction
SRLI Shift right logical immediate SRLI
[Mnemonic]
SRLI Rdest,#imm5
[Function]
[Description]
SRLI right arithmetic-shifts Rdest by the number specified by the 5-bit immediate value, shift-
ing zeroes into the most significant bits.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
load/store instruction
ST Store ST
[Mnemonic]
(1) ST Rsrc1,@Rsrc2
(2) ST Rsrc1,@+Rsrc2
(3) ST Rsrc1,@-Rsrc2
(4) ST Rsrc1,@(disp16,Rsrc2)
[Function]
Store
(1) * ( int *) Rsrc2 = Rsrc1;
(2) Rsrc2 += 4, * ( int *) Rsrc2 = Rsrc1;
(3) Rsrc2 -= 4, * ( int *) Rsrc2 = Rsrc1;
(4) * ( int *) ( Rsrc2 + ( signed short ) disp16 ) = Rsrc1;
[Description]
[EIT occurrence]
load/store instruction
ST Store
ST
[Encoding]
ST Rsrc1,@(disp16,Rsrc2)
load/store instruction
STB Store byte STB
[Mnemonic]
[Function]
Store
(1) * ( char *) Rsrc2 = Rsrc1;
(2) * ( char *) ( Rsrc2 + ( signed short ) disp16 ) = Rsrc1;
[Description]
(1) STB stores the least significant byte of Rsrc1 in the memory at the address specified by
Rsrc2.
(2) STB stores the least significant byte of Rsrc1 in the memory at the address specified by
Rsrc
combined with the 16-bit displacement.
The displacement value is sign-extended to 32 bits before the address calculation.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
STB Rsrc1,@(disp16,Rsrc2)
load/store instruction
STH Store halfword STH
[M32R-FPU Extended Mnemonic]
[Mnemonic]
[Function]
Store
(1) * ( signed short *) Rsrc2 = Rsrc1;
(2) * ( signed short *) Rsrc2 = Rsrc1, Rsrc2 + = 2 ;
(3) * ( signed short *) ( Rsrc2 + ( signed short ) disp16 ) = Rsrc1;
[Description]
(1) STH stores the least significant halfword of Rsrc1 in the memory at the address specified
by Rsrc2.
(2) STH stores the LSB halfword of Rsrc1 to the memory of the address specified by Rsrc2,
and then increments Rsrc2 by 2.
(3) STH stores the least significant halfword of Rsrc1 in the memory at the address specified
by Rsrc combined with the 16-bit displacement. The displacement value is sign-ex-
tended to 32 bits before the address calculation.
[EIT occurrence]
[Encoding]
STH Rsrc1,@(disp16,Rsrc2)
[Mnemonic]
SUB Rdest,Rsrc
[Function]
Subtract
Rdest = Rdest - Rsrc;
[Description]
SUB subtracts Rsrc from Rdest and puts the result in Rdest.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
[Mnemonic]
SUBV Rdest,Rsrc
[Function]
Subtract
Rdest = Rdest - Rsrc;
C = overflow ? 1 : 0;
[Description]
SUBV subtracts Rsrc from Rdest and puts the result in Rdest.
The condition bit (C) is set when the subtraction results in overflow; otherwise, it is cleared.
[EIT occurrence]
None
[Encoding]
[Mnemonic]
SUBX Rdest,Rsrc
[Function]
Subtract
Rdest = ( unsigned ) Rdest - ( unsigned ) Rsrc - C;
C = borrow ? 1 : 0;
[Description]
SUBX subtracts Rsrc and C from Rdest and puts the result in Rdest.
The condition bit (C) is set when the subtraction result cannot be represented by a 32-bit
unsigned integer; otherwise it is cleared.
[EIT occurrence]
None
[Encoding]
EIT-related instruction
TRAP Trap TRAP
[Mnemonic]
TRAP #imm4
[Function]
Trap occurrence
BPC = PC + 4;
BSM = SM;
BIE = IE;
BC = C ;
IE = 0;
C = 0;
call_trap_handler( imm4 );
[Description]
TRAP generates a trap with the trap number specified by the 4-bit immediate value.
IE and C bits are cleared to "0".
[EIT occurrence]
Trap (TRAP)
[Encoding]
load/store instruction
UNLOCK Store unlocked UNLOCK
[Mnemonic]
UNLOCK Rsrc1,@Rsrc2
[Function]
Store unlocked
if ( LOCK == 1 ) { * ( int *) Rsrc2 = Rsrc1; }
LOCK = 0;
[Description]
When the LOCK bit is 1, the contents of Rsrc1 are stored at the memory location specified by
Rsrc2. When the LOCK bit is 0, store operation is not executed. The condition bit (C) is un-
changed.
This instruction clears the LOCK bit to 0 in addition to the simple storage operation.
The LOCK bit is internal to the CPU and cannot be accessed except by using the LOCK and
UNLOCK instructions.
The user cannot directly read or write to this bit.
The LOCK bit is internal to the CPU and is the control bit for receiving all bus right requests
from circuits other than the CPU.
Refer to the Users Manual for non-CPU bus right requests, as the handling differs according to
the type of M
[EIT occurrence]
[Encoding]
[Mnemonic]
UTOF Rdest,Rsrc
[Function]
[Description]
UTOF converts the 32-bit unsigned integer stored in Rsrc to a floating-point single precision
value, and the result is stored in Rdest. The result is rounded according to the RM field in FPSR.
The condition bit (C) remains unchanged.
H0000 0000 is treated as +0 regardless of the Rounding Mode.
[EIT occurrence]
[Encoding]
UTOF Rdest,Rsrc
[Mnemonic]
XOR Rdest,Rsrc
[Function]
Exclusive OR
Rdest = ( unsigned ) Rdest ^ ( unsigned ) Rsrc;
[Description]
XOR computes the logical XOR of the corresponding bits of Rdest and Rsrc, and puts the
result in Rdest.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
[Mnemonic]
XOR3 Rdest,Rsrc,#imm16
[Function]
Exclusive OR
Rdest = ( unsigned ) Rsrc ^ ( unsigned short ) imm16;
[Description]
XOR3 computes the logical XOR of the corresponding bits of Rsrc and the 16-bit immediate
value, which is zero-extended to 32 bits, and puts the result in Rdest.
The condition bit (C) is unchanged.
[EIT occurrence]
None
[Encoding]
XOR3 Rdest,Rsrc,#imm16
The bit pattern of each instruction and correspondence of mnemonic are shown below.
The instructions enclosed in the bold lines are M32R-FPU extended instructions.
0100 4 ADDI
Rdest,#imm8
SRLI SRAI SLLI MVTACHI,
0101 5 Rdest,#imm5 Rdest,#imm5 Rdest,#imm5 MVTACLO (2)
LDI
0110 6 Rdest,#imm8
NOP ( 1)
0111 7 BC, BNC, BL, BRA, SETPSW, CLRPSW ( 1)
CMPI CMPUI
1000 8 Rsrc,#imm16 Rsrc,#imm16
DIV DIVU REM REMU
1001 9 Rdest,Rsrc Rdest,Rsrc Rdest,Rsrc Rdest,Rsrc
STB STH ST BSET BCLR
32-bit instruction
1100 C
FPU
1101 D externded instruction
E LD24
1110 Rdest,#imm24
0001 1 FMUL
0010 2 FDIV
32-bit instruction
0101 5
0110 6
0111 7
b0 3 4 7 8 11 12 b15
b 0-b 3 b 8-b 11
16-bit instruction
b 0-b 3 b 8-b 11
32-bit instruction
32-bit instruction
16-bit instruction
Rdest,@Rsrc Rdest,@Rsrc Rdest,@Rsrc Rdest,@Rsrc Rdest,@Rsrc Rdest,@Rsrc Rdest,@Rsrc+
3 0011
ADDI
Rdest,#imm8 4 0100
RACH RAC MVFACHI,
MVFACLO, 5 0101
MVFACMI (2)
LDI
Rdest,#imm8 6 0110
32-bit instruction
Rdest,@(disp16,Rsrc) Rdest,@(disp16,Rsrc) Rdest,@(disp16,Rsrc) Rdest,@(disp16,Rsrc) Rdest,@(disp16,Rsrc)
A 1010
BEQZ BNEZ BLTZ BGEZ BLEZ BGTZ
Rsrc,pcdisp16 Rsrc,pcdisp16 Rsrc,pcdisp16 Rsrc,pcdisp16 Rsrc,pcdisp16 Rsrc,pcdisp16 B 1011
C 1100
SETH
Rdest,#imm16 D 1101
LD24
Rdest,#imm24
E 1110
1 0001
2 0010
32-bit instruction
3 0011
5 0101
6 0110
7 0111
Note. In addition to b0-b3, b8-b11, instructions shown the above 1, 2 in the table are
decided by the following bit patterns.
As for details of bit patterns of each instruction, refer to "3.2 Instruction description."
1: b4-b7, 2: b12-b15
where:
typedef singed int s; /* 32 bit signed integer (word)*/
typedef unsigned int u; /* 32 bit unsigned integer (word)*/
typedef signed short sh; /* 16 bit signed integer (halfword)*/
typedef unsigned short uh; /* 16 bit unsigned integer (halfword)*/
typedef signed char sb; /* 8 bit signed integer (byte)*/
typedef unsigned char ub; /* 8 bit unsigned integer (byte)*/
Appendix Figure 3.1.1 shows each instruction type and the pipeline process.
Load/Store instruction
6 stages
*The number of cycles required by the MEM1 stage varies according to the access,
but the MEM2 stage is normally executed in 1 cycle.
4 stages
Pipeline Stage IF D E WB
Pipeline Stage IF D E E WB
5 stages
Pipeline Stage IF D E1 E2 WB
*The E1 and E2 stages cannot be executed at the same time as the E stage.
*The E1 stage of the FDIV instruction requires 14 cycles.
6 stages
Pipeline Stage IF D EM EA E2 WB
* The EM and EA stages cannot be executed at the same time as the E or E1 stage.
*Operation stages with the same name cannot be executed at the same time. In general, stages with
different names can be executed in parallel, but the following combinations are not acceptable.
*Bypass process: When using the result of one instruction in a subsequent instruction, the first result
may bypass the register file and be sent on to the execution stage of the subsequent instruction.
The following is an example of a bypass process:
The following diagram shows an ideal pipeline flow that has no stall and executes each
instruction in 1 clock cycle. (Since this is just an ideal case, all instructions may not be
piplined in.)
LDI R0,#1 IF D E WB
ADD R0,R1 IF D E WB
OR R0,R2 IF D E WB
CMP R0,R3 IF D E WB
<Case 3> Register-register instructions are executed with no register dependency following
a load/store instruction (out-of-order-completion)
LDI R1,#1 IF D E WB
ADD R1,R3 IF D E WB
OR R1,R4 IF D E WB
<Case 4> Three FPU instructions continue consecutively with no register dependency
FADD R0,R5,R6 IF D E1 E2 WB
FSUB R1,R6,R7 IF D E1 E2 WB
FMUL R2,R7,R8 IF D E1 E2 WB
FCMP R0,R0,R3 IF D E1 E2 WB
<Case 5> Four FMADD or FMSUB instructions continue consecutively with no register dependency
FMADD R0,R5,R6 IF D EM EA E2 WB
FMADD R1,R6,R7 IF D EM EA E2 WB
FMADD R2,R7,R8 IF D EM EA E2 WB
FMADD R3,R80,R9 IF D EM EA E2 WB
DIV R1,R2 IF D E E E WB
<Case 2> An instruction which requires more than 1 cycle for its operand access is executed
<Case 3> A branch instruction is executed (except for the case in which no branch occurs
at a conditional branch instruction)
Branch Instruction IF D E WB
IF D stall IF D E WB
IF stall stall IF D E WB
<Case 4> The subsequent instruction uses an operand read from the memory
ADD R4,R5 IF D E WB
ADD R4,R5 IF D E WB
ADD R6,R7 IF D E WB
ADD R3,R1 IF D E WB
ADD R4,R5 IF D E WB
FMADD R1,R6,R7 IF D EM EA E2 WB
<Case 5> The PSW is written by an MVTC, SETPSW, or CLRPSW instruction and
the subsequent instruction reads R15
MVTC R1,PSW IF D E WB
<Case 6> FPSR is accessed by an MVFC instruction after the FPU instruction is executed
FADD R0,R1,R2 IF D E1 E2 WB
<Case 7> The operation result of the FPU instruction is used by the subsequent instruction
FADD R0,R1,R2 IF D E1 E2 WB
FMADD R0,R1,R2 IF D EM EA E2 WB
FMADD R0,R1,R2 IF D EM EA E2 WB
<Case 8> The FPU and integer instructions run consecutively (with no register dependency)
ADD R0,R1 IF D E WB
FADD R2,R3,R4 IF D E1 E2 WB
<Case 9> The FPU and integer instructions run consecutively (with register dependency)
ADD R0,R1 IF D E WB
Bypass process
FADD R0,R0,R4 IF D E1 E2 WB
IF stall stall D E1 E2 WB
FADD R0,R0,R9
<Case 10> The FMADD/FMSUB instructions run consecutively with the integer instruction
(with no register dependency)
ADD R0,R1 IF D E WB
FMADD R2,R3,R4 IF D EM EA E2 WB
<Case 11> The FMADD/FMSUB instructions run consecutively with the integer instruction
(with register dependency)
ADD R0,R1 IF D E WB
Bypass process
FMADD R0,R0,R4 IF D EM EA E2 WB
<Case 12> The FPU and FMADD/FMSUB instructions run consecutively (with no register dependency)
FADD R0,R1,R10 IF D E1 E2 WB
FMADD R2,R3,R4 IF D EM EA E2 WB
<Case 13> The FPU and FMADD/FMSUB instructions run consecutively (with register dependency)
FADD R0,R1,R10 IF D E1 E2 WB
Appendix Table 4.1.1 Instruction Execution Cycles per Pipeline Stage [excluding FPU instructions]
the number of execution cycles in each stage
load instruction (LD, LDB, LDUB, LDH, LDUH, LOCK) R (note 1) 1 1 R (note 1) 1 1
store instruction (ST, STB, STH, UNLOCK) R (note 1) 1 1 W (note 1) 1 (1) (note 2)
Appendix Table 4.1.2 Instruction Execution Cycles per Pipeline Stage [FPU instructions]
the number of execution cycles in each stage
instruction IF D E1 EM EA E2 WB
The following is a basic overview of the IEEE754 specification. M32R-FPU fulfills the
IEEE754 requirements through a combination of software and hardware features.
0 1 8 9 31
Single Precision e (8 bit) f (23 bit)
s (1 bit)
0 1 11 12 63
Double Precision e (11 bit) f (52 bit)
s (1 bit)
Using these symbols, the floating-point values (normalized numbers) can be described
by the following expressions:
Certain values do not fit into the above expressions, such as , 0, NaN (Not a
Number), denormalized numbers, etc.
Other formats, such as expanded double precision, can also be used.
M32R-FPU only supports the single-precision format. The double precision format is
supported in the software library.
SNaN (Signaling NaN): a NaN in which the MSB of the decimal fraction field is "0".
When SNaN is used as the source operand in an operation, an IVLD occurs. SNaNs
are useful in identifying program bugs when used as the initial value in a variable.
However, SNaNs cannot be generated by hardware.
QNaN (Quiet NaN): a NaN in which the MSB of the decimal fraction field is "1". Even
when QNaN is used as the source operand in an operation, an IVLD will not occur
(excluding comparison and format conversion). Because a result can be checked by
the arithmetic operations, QNaN allows the user to debug without executing an EIT
processing. QNaNs are created by hardware.
Round to Nearest is the default mode and produces the most accurate value.
Round toward Infinity, Round toward +Infinity and Round toward Zero are used
for interval arithmetic to insure precision
IEEE754 allows the following 5 exceptions. The floating-point status register is used to
determine whether the EIT process will be executed when an Exception occurs.
The exception occurs when the absolute value of the operation result exceeds the
largest describable precision in the floating-point format. Appendix Table 5.3.1 shows
the operation results when an OVF occurs.
Note : When the Underflow Exception Enable (EU) bit (FPSR register bit 18) = "0"
When the Underflow Exception Enable (EU) bit (FPSR register bit 18) = "1"
The exception occurs when the absolute value of the operation result is less then the
largest describable precision in the floating-point format. Appendix Table 5.3.2 shows
the operation results when a UDF occurs.
The exception occurs when the operation result differs from a result led out with an
infinite range of precision. Appendix Table 5.3.3 shows operation results and the
respective conditions in which each IXCT occurs.
Appendix Table 5.3.3 Operation Results and Respective Conditions for IXCT Exception
Result
Occurrence Condition when the IXCT EIT when the IXCT EIT
processing is masked processing is executed
Overflow occurs in OVF Exception Reference OVF Exception Same as left
masked condition table
Rounding occurs Rounded value Same as left
The exception occurs when a finite, nonzero value is divided by zero. Appendix Table
5.3.4 shows the operation result when a DIV0 occurs.
Please note that the DIV0 EIT operation does not occur in the following factors.
Dividend Operation
0 Invalid Operation Exception occurs
The exception occurs when an invalid operation is executed. Appendix Table 5.3.5
shows operation results and the respective conditions in which each IVLD occurs.
Definition of Terms
Exception
EIT Processing
The value resulting from calculations of infinite and unbounded exponent and mantissa
bits. In actual implementation, the number of exponent and mantissa bits is finite and
the intermediate result is rounded so that the final operation result can be determined.
Appendix 6.1 Operation Comparision: Using 1 instruction (FMADD or FMSBU) vs. two
instructions (FMUL and FADD)
The following is an explanation of the differences between an operation using just one
instruction (FMADD or FMSUB) and an operation using 2 instructions (FMUL and
FADD).
The rounding mode for an operation using both FMUL and FADD rounds both FMUL
and FADD according to the setting of the FPSR RM field. However, the result of the
FMADD or FMSUB instruction in Step 1 (multiply stage) is not rounded according to
the setting of FPSR RM field, rather it is rounded toward zero.
FMUL + FADD:
FMUL R3, R1, R2 (R3 = R1 * R2)
FADD R0, R3, R0 (R0 = R3 + R0)
FMADD or FMSUB:
FMADD R0, R1, R2 (R0 = R0 +R1 * R2)
Note: If the register supports different operations than those described above, the
operations may differ in some ways to those shown below.
[Important Note]
This rule does not apply when the data that is sent to Rdest, the results of the FCMP or
FCMPE comparison, comprise a NaN bit pattern.
<FMADD, FMSUB>
Source Operand Rdest
Rdest Rsrc1, Rsrc2
Appendix 7 Precautions
When aligning or allocating the data area following the code area in a program, the
alignment must be done from an address that has an adjusted word alignment.
If the data area is aligned or allocated without adjusting the word alignment, a 16-bit
instruction may exist in the high-order halfword of the word, and data with MSB of 1
may be aligned to the following halfword. In this case, the M32R family upward-
compatible CPU recognizes the 16-bit instruction and the data as a pair of parallel
executable instructions and executes the instructions as such.
1 word
+0 +1 +2 +3
MSB MSB
data
B D
Data format 1-13, 1-14
Backup PC(BPC) 1-5
Data format in a register 1-13
Bit operation instructions 2-11
Data format in memory 1-14
BCLR 3-15
Data type 1-12, 3-3
BSET 3-27
DSP function instructions 2-8
BTST 3-28
MACHI 3-69
CLRPSW 3-29
MACLO 3-70
SETPSW 3-99
MACWHI 3-71
Branch instructions 2-6
MACWLO 3-72
BC 3-14
MULHI 3-74
BEQ 3-16
MULLO 3-75
BEQZ 3-17
MULWHI 3-76
BGEZ 3-18
MULWLO 3-77
BGTZ 3-19
MVFACHI 3-79
BL 3-20
MVFACLO 3-80
BLEZ 3-21
MVFACMI 3-81
BLTZ 3-22
MVTACHI 3-83
BNC 3-23
MVTACLO 3-84
BNE 3-24
RAC 3-91
RACH 3-93
E L
EIT-related instructions 2-8 Load/store instructions 2-2
RTE 3-97 LD 3-61
TRAP 3-116 LDB 3-63
LDH 3-64
LDUB 3-66
F LDUH 3-67
LOCK 3-68
Floating-point instruction 2-11 ST 3-109
FADD 3-36 STB 3-111
FCMP 3-38 STH 3-112
FCMPE 3-40 UNLOCK 3-117
FDIV 3-42 Logic operation instructions 2-5
FMADD 3-44 AND 3-12
FMSUB 3-47 AND3 3-13
FMUL 3-50 NOT 3-88
FSUB 3-52 OR 3-89
FTOI 3-54 OR3 3-90
FTOI 3-54 XOR 3-119
ITOF 3-58 XOR3 3-120
UTOF 3-118
Floating-point Status Register 1-6
M
G Multiply/divide instructions 2-5
DIV 3-34
General-purpose Registers 1-2 DIVU 3-35
MUL 3-73
REM 3-95
H REMU 3-96
R
R 1-15, 3-2
Register direct(R or CR) 1-15, 3-2
Register indirect(@R) 1-15, 3-2
Register indirect and register update 1-15, 3-2
Register relative indirect(@(disp, R)) 1-15, 3-2
S
Shift instructions 2-5
SLL 3-100
SLL3 3-101
SLLI 3-102
SRA 3-103
SRA3 3-104
SRAI 3-105
SRL 3-106
SRL3 3-107
SRLI 3-108
Stack pointer 1-2, 1-5
T
Transfer instructions 2-4
LD24 3-62
LDI 3-65
MV 3-78
MVFC 3-82
MVTC 3-85
SETH 3-98
U
User Stack Pointer(SPU) 1-2, 1-3, 1-5