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 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
• These materials are intended as a reference to assist our customers in the selection of the
Renesas Technology Corporation 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 Corporation or a third party.
• Renesas Technology Corporation 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.
• 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 Corporation without notice
due to product improvements or other reasons. It is therefore recommended that customers contact Renesas Technology Corporation or an authorized Renesas Technology Corporation 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 Corporation 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 Corporation by
various means, including the Renesas Technology Corporation Semiconductor home page
(http://www.renesas.com).
• 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 Corporation assumes no responsibility for any damage, liability or other loss resulting from the information contained herein.
• Renesas Technology Corporation 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 Corporation or an authorized Renesas
Technology Corporation 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.
• The prior written approval of Renesas Technology Corporation is necessary to reprint or
reproduce in whole or in part these materials.
• 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.
• Please contact Renesas Technology Corporation for further details on these materials or
the products contained therein.
REVISION HISTORY
M32R-FPU Software Manual
Rev.DateDescription
PageSummary
1.00 Jan 08, 2003First edition issued –
1.01 Oct 31, 2003Hexadecimal Instruction Code Table corrected (BTST instruction)APPENDICES-3
APPENDICES-8
Appendix Figure 3.1.1 corrected
Incorrect) *The E1 stage of the FDIV instruction requires 13 cycles.
Correct) *The E1 stage of the FDIV instruction requires 14 cycles.
Appendix 7.1 Precautions to be taken when aligning data...........................
Appendix
Appendix
Appendix
Appendix
Appendix
Appendix
Appendix
Appendix
Appendix
Appendix
Appendix
-2
Appendix
-4
Appendix
-8
-8
-10
Appendix
-17
Appendix
-18
-18
-20
-20
Appendix
-23
-23
-23
-23
-28
Appendix
-29
-29
INDEX
(2)
M32R-FPU Software Manual (Rev.1.01)
This page left blank intentionally.
M32R-FPU Software Manual (Rev.1.01)
CHAPTER 1
CPU PROGRAMMIING MODEL
1.1CPU Register
1.2General-purpose Registers
1.3Control Registers
1.4Accumulator
1.5Program Counter
1.6Data Format
1.7Addressing Mode
CPU PROGRAMMING MODEL
1
1.1 CPU Register
The M32R family CPU, with a built-in FPU (herein referred to as M32R-FPU) has 16
general-purpose registers, 6 control registers, an accumulator and a program
counter. The accumulator is of 56-bit configuration, and all other registers are a 32bit configuration.
1.2 General-purpose Registers
The 16 general-purpose registers (R0 – R15) are of 32-bit width and are used to
retain data and base addresses, as well as for integer calculations, floating-point
operations, etc. R14 is used as the link register and R15 as the stack pointer. The link
register is used to store the return address when executing a subroutine call
instruction. The Interrupt Stack Pointer (SPI) and the User Stack Pointer (SPU) are
alternately represented by R15 depending on the value of the Stack Mode (SM) bit in
the Processor Status Word Register (PSW).
At reset release, the value of the general-purpose registers is undefined.
1.1 CPU Register
b0
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
Notes: • CRn (n = 0 - 3, 6 and 7) denotes the control register number.
• The dedicated MVTC and MVFC instructions are used for writing and reading these control registers.
• The SM bit, IE bit and C bit of the PSW can also be set by the SETPSW instruction or the CLRPSW
instruction.
Figure 1.3.1 Control Registers
CR0
CR1
CR2
CR3
CR6
CR7
b0
PSW
CBR
SPI
SPU
BPC
FPSR
b31
Processor Status Register
Condition Bit Register
Interrupt Stack Pointer
User Stack Pointer
Backup PC
Floating-point Status Register
1-3M32R-FPU Software Manual (Rev.1.01)
1
1.3.1 Processor Status Word Register: PSW (CR0)
7654321891011121314b15b0
CPU PROGRAMMING MODEL
1.3 Control Registers
00000000000000
BIEBSM
??00000?00000000
bBit NameFunctionRW
0-15No function assigned. Fix to "0".00
16BSMSaves value of SM bit when EIT occursRW
Backup SM Bit
17BIESaves value of IE bit when EIT occursRW
Backup IE Bit
18-22 No function assigned. Fix to "0".00
23BCSaves value of C bit when EIT occursRW
Backup C Bit
24SM0: Uses R15 as the interrupt stack pointerRW
Stack Mode Bit1: Uses R15 as the user stack pointer
25IE0: Does not accept interruptRW
Interrupt Enable Bit1: Accepts interrupt
26-30 No function assigned. Fix to "0".00
31CIndicates carry, borrow and overflow resultingRW
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".
1-4
M32R-FPU Software Manual (Rev.1.01)
1
1.3.2 Condition Bit Register: CBR (CR1)
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".
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.
CPU PROGRAMMING MODEL
1.3 Control Registers
b31
C
b0
SPI
b0
SPU
SPI
SPU
1.3.4 Backup PC: BPC (CR6)
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
BPC
BPC
b31
b31
b31
0
1-5M32R-FPU Software Manual (Rev.1.01)
CPU PROGRAMMING MODEL
1
1.3.5 Floating-point Status Register: FPSR (CR7)
234567891011121314b151b0
FSFXFUFZ
00000000000000
18192021222324252627282930b3117b16
EZEO
EUEX
0000000100000000
bBit NameFunctionRW
0FSReflects the logical sum of FU, FZ, FO and FV.R–
Floating-point Exception
Summary Bit
1FXSet to "1" when an inexact exception occursRW
Inexact Exception Flag(if EIT processing is unexecuted (Note 1)).
2FUSet to "1" when an underflow exception occursRW
Underflow Exception Flag(if EIT processing is unexecuted (Note 1)).
3FZSet to "1" when a zero divide exception occursRW
Zero Divide Exception Flag(if EIT processing is unexecuted (Note 1)).
4FOSet to "1" when an overflow exception occursRW
Overflow Exception Flag(if EIT processing is unexecuted (Note 1)).
5FVSet to "1" when an invalid operation exception RW
Invalid Operation Exceptionoccurs (if EIT processing is unexecuted (Note 1)).
FlagOnce set, the flag retains the value "1" until
6–16No function assigned. Fix to "0". 0 0
17EX0: Mask EIT processing to be executed when anRW
Inexact Exception Enable inexact exception occurs
Bit1: Execute EIT processing when an inexact
18EU0: Mask EIT processing to be executed when anRW
Underflow Exception Enable underflow exception occurs
Bit1: Execute EIT processing when an underflow
19EZ0: Mask EIT processing to be executed when aRW
Zero Divide Exception zero divide exception occurs
Enable Bit1: Execute EIT processing when a zero divide
20EO0: Mask EIT processing to be executed when anRW
Overflow Exception overflow exception occurs
Enable Bit1: Execute EIT processing when an overflow
0FO0
FV
EV
DNCECXCUCZCOCVRM
Once set, the flag retains the value "1" until
it is cleared to "0" in software.
Once set, the flag retains the value "1" until
it is cleared to "0" in software.
Once set, the flag retains the value "1" until
it is cleared to "0" in software.
Once set, the flag retains the value "1" until
it is cleared to "0" in software.
it is cleared to "0" in software.
exception occurs
exception occurs
exception occurs
exception occurs
<At reset release: H0000 0100>
1.3 Control Registers
1-6
M32R-FPU Software Manual (Rev.1.01)
CPU PROGRAMMING MODEL
1
21EV0: Mask EIT processing to be executed when anRW
Invalid Operation Exception invalid operation exception occurs
Enable Bit1: Execute EIT processing when an invalid
operation exception occurs
22No function assigned. Fix to "0".00
23DN0: Handle the denormalized number as aRW
Denormalized Number Zero denormalized number
Flash Bit (Note 2)1: Handle the denormalized number as zero
24CE0: No unimplemented operation exception occurred .R (Note 3)
Unimplemented Operation1: An unimplemented operation exception occurred.
Exception Cause Bit When the bit is set to "1", the execution of an
FPU operation instruction will clear it to "0".
25CX0: No inexact exception occurred.R (Note 3)
Inexact Exception Cause1: An inexact exception occurred.
Bit When the bit is set to "1", the execution of an
FPU operation instruction will clear it to "0".
26CU0: No underflow exception occurred.R (Note 3)
Underflow Exception Cause1: An underflow exception occurred.
Bit When the bit is set to "1", the execution of an
FPU operation instruction will clear it to "0".
27CZ0: No zero divide exception occurred.R (Note 3)
Zero Divide Exception1: A zero divide exception occurred.
Cause Bit When the bit is set to "1", the execution of an
FPU operation instruction will clear it to "0".
28CO0: No overflow exception occurred.R (Note 3)
Overflow Exception1: An overflow exception occurred.
Cause Bit When the bit is set to "1", the execution of an
FPU operation instruction will clear it to "0".
29CV0: No invalid operation exception occurred.R (Note 3)
Invalid Operation Exception1: An invalid operation exception occurred.
Cause Bit When the bit is set to "1", the execution of an
FPU operation instruction will clear it to "0".
30, 31RM00: Round to NearestRW
Rounding Mode Selection Bit 01: Round toward Zero
10: Round toward +Infinity
11: Round toward -Infinity
Note 1: ‘If EIT processing is unexecuted’ means whenever one of the exceptions occurs, enable bits
17 to 21 are set to "0" which masks the EIT processing so that it cannot be executed. If two
exceptions occur at the same time and their corresponding exception enable bits are
set differently (one enabled, and the other masked), EIT processing is executed. In this
case, these two flags do not change state regardless of the enable bit settings.
Note 2: If a denormalized number is given to the operand when DN = "0", an unimplemented
exception occurs.
Note 3: This bit is cleared by writing "0". Writing "1" has no effect (the bit retains the value it had
before the write).
1.3 Control Registers
1-7M32R-FPU Software Manual (Rev.1.01)
CPU PROGRAMMING MODEL
1
1.3.6 Floating-point Exceptions (FPE)
Floating-point Exception (FPE) occurs when Unimplemented Exception (UIPL) or
one of the five exceptions specified in the IEEE754 standard (OVF/UDF/IXCT/
DIV0/IVLD) is detected. Each exception processing is outlined below.
(1) Overflow Exception (OVF)
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.
Operation Result (Content of the Destination Register)
Rounding Mode Sign of the ResultWhen the OVF EIT processingWhen the OVF EIT processing
is masked (Note 1)is executed (Note 2)
–infinity++MAX
––infinity
+infinity++infinity
––MAXNo change
0++MAX
––MAX
Nearest++infinity
––infinity
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
1.3 Control Registers
(2) Underflow Exception (UDF)
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.
Operation Result (Content of the Destination Register)
When UDF EIT processing is masked (Note 1)When UDF EIT processing is executed (Note 2)
DN = 0: An unimplemented exception occurs No change
DN = 1: 0 is returned
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"
1-8
M32R-FPU Software Manual (Rev.1.01)
CPU PROGRAMMING MODEL
1
(3) Inexact Exception (IXCT)
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.
Operation Result (Content of the Destination Register)
Occurrence ConditionWhen the IXCT EIT processing isWhen the IXCT EIT processing is
masked (Note 1)executed (Note 2)
Overflow occurs in OVFReference OVF operation resultsNo change
masked condition
Rounding occursRounded valueNo change
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"
(4) Zero Division Exception (DIV0)
The exception occurs when a finite nonzero value is divided by zero. The following
table shows the operation results when a DIV0 occurs.
1.3 Control Registers
Operation Result (Content of the Destination Register)
DividendWhen the DIV0 EIT processing is When the DIV0 EIT processing is
masked (Note 1) executed (Note 2)
Nonzero finite value±infinity (Sign is derived by exclusive- No change
ORing the signs of divisor and dividend)
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.
DividendBehavior
0An invalid operation exception occurs
infinityNo exception occur (with the result "infinity")
1-9M32R-FPU Software Manual (Rev.1.01)
CPU PROGRAMMING MODEL
1
(5) Invalid Operation Exception (IVLD)
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.
Occurrence ConditionOperation Result (Content of the Destination Register)
When the IVLD EIT processing When the IVLD EIT
is masked (Note 1)processing isexecuted
instructionpre-conversion signed bit is:
When an integer conversionwas executed"0" = H’7FFF FFFFNo change
overflowed"1" = H’8000 0000
When NaN or Infinity wasWhen FTOSReturn value when
converted into an integerinstructionpre-conversion signed bit is:
was executed"0" = H’0000 7FFF
"1" = H’FFF 8000
When < or > comparison wasComparison results
performed on NaN(comparison invalid)
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.
1.3 Control Registers
(Note 2)
(6) Unimplemented Exception (UIPL)
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.
Note: • A UDF occurs when the intermediate result of an operation is a denormalized
number, in which case if the DN bit (FPSR register bit 23) = "0", an UIPL occurs.
1-10
M32R-FPU Software Manual (Rev.1.01)
CPU PROGRAMMING MODEL
1
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.
1.4 Accumulator
(Note 1)
ACC
read/write range with
MVTACHI or MVFACHI instruction
Note 1: When read, bits 0 to 7 always show the sign-extended value of bit 8. Writing to this bit field is
ignored.
read range with MVFACMI instruction
3248b63311615b04778
read/write range with
MVTACLO or MVFACLO instruction
1.5 Program Counter
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 evennumbered addresses, the LSB (bit 31) is always "0".
At reset release, the value of the PC is "H’0000 0000."
b0
PC
PC
b31
0
1-11M32R-FPU Software Manual (Rev.1.01)
1
1.6 Data Format
1.6.1 Data Type
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.
CPU PROGRAMMING MODEL
1.6 Data Format
signed byte (8-bit) integer
unsigned byte (8-bit) integer
signed halfword (16-bit) integer
unsigned halfword (16-bit) integer
signed word (32-bit) integer
unsigned word (32-bit) integer
floating-point single precision values
Figure 1.6.1 Data Type
b0
S
b0
S
b0
b0
S
b0
b08 9b31
SEF
b7
b7b0
b15
b15
S: Sign bitE: Exponent fieldF: Fraction field
b31
b31
1-12
M32R-FPU Software Manual (Rev.1.01)
1
1.6.2 Data Format
(1) Data format in a register
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.
CPU PROGRAMMING MODEL
1.6 Data Format
< load >
b0b31
Rn
sign-extention (LDH instruction) or
zero-extention (LDUH instruction)
b0b31
Rn
b0b31
Rn
< store >
b0b31
Rn
b0b31
Rn
b0b31
Rn
sign-extention (LDB instruction) or
zero-extention (LDUB
instruction)
16
from memory (LD instruction
word
16
word
from memory (LDH, LDUH
(LDB, LDUB instruction)
halfword
)
to memory (STB instruction)
halfword
to memory (STH instruction)
from memory
24
byte
instruction)
24
byte
Figure 1.6.2 Data Format in a Register
to memory (ST
instruction)
1-13M32R-FPU Software Manual (Rev.1.01)
1
(2) Data format in memory
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.
CPU PROGRAMMING MODEL
1.6 Data Format
Address
+0 address+1 address+2 address+3 address
b0b31
byte
byte
half
word
word
Figure 1.6.3 Data Format in Memory
7 815 1623 24
byte
byte
byte
halfword
halfword
word
1-14
M32R-FPU Software Manual (Rev.1.01)
1
1.7 Addressing Mode
M32R-FPU supports the following addressing modes.
(1) Register direct [R or CR]
The general-purpose register or the control register to be processed is
specified.
(2) Register indirect [@R]
The contents of the register specify the address of the memory. This mode
can be used by all load/store instructions.
(3) Register relative indirect [@(disp, R)]
(The contents of the register) + (16-bit immediate value which is signextended to 32 bits) specify the address of the memory.
(4) Register indirect and register update
CPU PROGRAMMING MODEL
1.7 Addressing Mode
• Adds 4 to register contents [@R+]
The contents of the register specify the memory address, then 4 is added to
the register contents.
(Can only be specified with LD instruction).
• Add 2 to register contents [@R+] [M32R-FPU extended addressing mode]
The contents of the register specify the memory address, then 2 is added to
the register contents.
(Can only be specified with STH instruction).
• Add 4 to register contents [@+R]
The contents of the register is added by 4, the register contents specify the
memory address.
(Can only be specified with ST instruction).
• Subtract 4 to register contents [@–R]
The content of the register is decreased by 4, then the register contents
specify the memory address.
(Can only be specified with ST instruction).
(5) immediate [#imm]
The 4-, 5-, 8-, 16- or 24-bit immediate value.
(6) PC relative [pcdisp]
(The contents of PC) + (8, 16, or 24-bit displacement which is sign-extended
to 32 bits and 2 bits left-shifted) specify the address of memory.
1-15M32R-FPU Software Manual (Rev.1.01)
1
CPU PROGRAMMING MODEL
1.7 Addressing Mode
This page left blank intentionally.
1-16
M32R-FPU Software Manual (Rev.1.01)
CHAPTER 2
INSTRUCTION SET
2.1 Instruction set overview
2.2 Instruction format
INSTRUCTION SET
2
2.1 Instruction set overview
2.1 Instruction set overview
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.
2.1.1 Load/store instructions
The load/store instructions carry out data transfers between a register and a memory.
Three types of addressing modes can be specified for load/store instructions.
(1) Register indirect
The contents of the register specify the address. This mode can be used by all load/
store instructions.
(2) Register relative indirect
(The contents of the register) + (32-bit sign-extended 16-bit immediate value)
specifies the address. This mode can be used by all except LOCK and UNLOCK
instructions.
(3) Register indirect and register update
• Adds 4 to register contents [@R+]
The contents of the register specify the memory address, then 4 is added to the
register contents.
(Can only be specified with LD instruction).
• Add 2 to register contents [@R+] [M32R-FPU extended addressing mode]
The contents of the register specify the memory address, then 2 is added to the
register contents.
(Can only be specified with STH instruction).
2.1 Instruction set overview
• Add 4 to register contents [@+R]
The contents of the register is added by 4, the register contents specity the
memory address.
(Can only be specified with ST instruction).
• Subtract 4 to register contents [@–R]
The content of the register is decreased by 4, then the register contents specify
the memory address.
(Can only be specified with ST instruction).
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 loworder 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.
2-3M32R-FPU Software Manual (Rev.1.01)
INSTRUCTION SET
2
2.1.2 Transfer instructions
The transfer instructions carry out data transfers between registers or a register and an
immediate value.
LD24Load 24-bit immediate
LDILoad immediate
MVMove register
MVFCMove from control register
MVTCMove to control register
SETHSet high-order 16-bit
2.1.3 Operation instructions
Compare, arithmetic/logic operation, multiply and divide, and shift are carried out
between registers.
SLLShift left logical
SLL3Shift left logical 3-operand
SLLIShift left logical immediate
SRAShift right arithmetic
SRA3Shift right arithmetic 3-operand
SRAIShift right arithmetic immediate
SRLShift right logical
SRL3Shift right logical 3-operand
SRLIShift right logical immediate
INSTRUCTION SET
2.1 Instruction set overview
2-5M32R-FPU Software Manual (Rev.1.01)
2
2.1.4 Branch instructions
The branch instructions are used to change the program flow.
BCBranch on C-bit
BEQBranch on equal to
BEQZBranch on equal to zero
BGEZBranch on greater than or equal to zero
BGTZBranch on greater than zero
BLBranch and link
BLEZBranch on less than or equal to zero
BLTZBranch on less than zero
BNCBranch on not C-bit
BNEBranch on not equal to
BNEZBranch on not equal to zero
BRABranch
JLJump and link
JMPJump
NOPNo operation
INSTRUCTION SET
2.1 Instruction set overview
Only a word-aligned (word boundary) address can be specified for the branch address.
2-6
M32R-FPU Software Manual (Rev.1.01)
INSTRUCTION SET
2
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.
2.1 Instruction set overview
address
branch instruction
Fig. 2.1.1 Branch addresses of branch instruction
H'00
H'04
H'08
H'0C
H'10
+0+1+2+3
1 word (32 bits)
instruction Ainstruction B
instruction Cinstruction D
instruction E
instruction F
instruction Ginstruction H
2-7M32R-FPU Software Manual (Rev.1.01)
INSTRUCTION SET
2
2.1.5 EIT-related instructions
The EIT-related instructions carry out the EIT events (Exception, Interrupt and Trap).
Trap initiation and return from EIT are EIT-related instructions.
TRAPTrap
RTEReturn from EIT
2.1.6 DSP function instructions
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 generalpurpose register.
2.1 Instruction set overview
MACHIMultiply-accumulate high-order halfwords
MACLOMultiply-accumulate low-order halfwords
MACWHIMultiply-accumulate word and high-order halfword
MACWLOMultiply-accumulate word and low-order halfword
MULHIMultiply high-order halfwords
MULLOMultiply low-order halfwords
MULWHIMultiply word and high-order halfword
MULWLOMultiply word and low-order halfword
MVFACHIMove high-order word from accumulator
MVFACLOMove low-order word from accumulator
MVFACMIMove middle-order word from accumulator
MVTACHIMove high-order word to accumulator
MVTACLOMove low-order word to accumulator
RACRound accumulator
RACHRound accumulator halfword
2-8
M32R-FPU Software Manual (Rev.1.01)
Loading...
+ 162 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.