Page 3
Cautions 1. Hitachi neither warrants nor grants licenses of any rights of Hitachi’s or any third party’s patent, copyright, trademark, or other intellectual property rights for information contained in this document. Hitachi bears no responsibility for problems that may arise with third party’s rights, including intellectual property rights, in connection with use of the information contained in this document.
Page 5
Preface The SH-4 (SH7750) has been developed as the top-end model in the SuperH™ RISC engine family, featuring a 128-bit graphic engine for multimedia applications and 360 MIPS performance. The SH7750 CPU has a RISC type instruction set, and features upward-compatibility at the object code level with SH-1, SH-2, SH-3, and SH-3E microcomputers.
MMU (memory management unit) with a 64-entry fully-associative unified TLB (translation lookaside buffer). The SH7750 has an on-chip bus state controller (BSC) that allows direct connection to DRAM and synchronous DRAM without external circuitry. Its 16-bit fixed-length instruction set enables program code size to be reduced by almost 50% compared with 32-bit instructions.
Page 16
External buses Separate 26-bit address and 64-bit data buses External bus frequency of 1/2, 1/3, 1/4, 1/6, or 1/8 times internal bus frequency • Original Hitachi SH architecture • 32-bit internal data bus • General register file: Sixteen 32-bit general registers (and eight 32-bit shadow registers) ...
Page 17
Table 1.1 SH7750 Features (cont) Item Features • On-chip floating-point coprocessor • Supports single-precision (32 bits) and double-precision (64 bits) • Supports IEEE754-compliant data types and exceptions • Two rounding modes: Round to Nearest and Round to Zero • Handling of denormalized numbers: Truncation to zero or interrupt generation for compliance with IEEE754 •...
Page 18
Table 1.1 SH7750 Features (cont) Item Features • Clock pulse Choice of main clock: 1/2, 1, 3, or 6 times EXTAL generator (CPG) • Clock modes: CPU frequency: 1, 1/2, 1/3, 1/4, 1/6, or 1/8 times main clock: maximum 200 MHz ...
Page 19
Table 1.1 SH7750 Features (cont) Item Features • Cache memory Instruction cache (IC) 8 kbytes, direct mapping 256 entries, 32-byte block length Normal mode (8-kbyte cache) Index mode • Operand cache (OC) 16 kbytes, direct mapping ...
Page 20
Table 1.1 SH7750 Features (cont) Item Features • Bus state Supports external memory access controller (BSC) 64/32/16/8-bit external data bus • External memory space divided into seven areas, each of up to 64 Mbytes, with the following parameters settable for each area: ...
Page 21
Table 1.1 SH7750 Features (cont) Item Features • Serial Two full-duplex communication channels (SCI, SCIF) communication • Channel 1 (SCI): interface Choice of asynchronous mode or synchronous mode (SCI, SCIF) Supports smart card interface • Channel 2 (SCIF): ...
Block Diagram Figure 1.1 shows an internal block diagram of the SH7750. Lower 32-bit data Lower 32-bit data I cache O cache ITLB UTLB (8 kB) (16 kB) INTC DMAC (SCIF) External bus interface 26-bit 64-bit address data CCN: Cache and TLB controller...
Section 2 Programming Model Data Formats The data formats handled by the SH7750 are shown in figure 2.1. Byte (8 bits) Word (16 bits) Longword (32 bits) 31 30 Single-precision floating-point (32 bits) fraction 63 62 Double-precision floating-point (64 bits) fraction Figure 2.1 Data Formats...
2.2.1 Privileged Mode and Banks Processor Modes: The SH7750 has two processor modes, user mode and privileged mode. The SH7750 normally operates in user mode, and switches to privileged mode when an exception occurs or an interrupt is accepted. There are four kinds of registers—general registers, system registers, control registers, and floating-point registers—and the registers that can be accessed...
Page 25
Floating-Point Registers: There are thirty-two floating-point registers, FR0–FR15 and XF0– XF15. FR0–FR15 and XF0–XF15 can be assigned to either of two banks (FPR0_BANK0– FPR15_BANK0 or FPR0_BANK1–FPR15_BANK1). FR0–FR15 can be used as the eight registers DR0/2/4/6/8/10/12/14 (double-precision floating- point registers, or pair registers) or the four registers FV0/4/8/12 (register vectors), while XF0– XF15 can be used as the eight registers XD0/2/4/6/8/10/12/14 (register pairs) or register matrix XMTRX.
32-bit general registers (R0_BANK0–R7_BANK0, R0_BANK1–R7_BANK1, and R8–R15). However, only 16 of these can be accessed as general registers R0–R15 in one processor mode. The SH7750 has two processor modes, user mode and privileged mode, in which R0–R7 are assigned as shown below.
2.2.3 Floating-Point Registers Figure 2.4 shows the floating-point registers. There are thirty-two 32-bit floating-point registers, divided into two banks (FPR0_BANK0–FPR15_BANK0 and FPR0_BANK1–FPR15_BANK1). These 32 registers are referenced as FR0–FR15, DR0/2/4/6/8/10/12/14, FV0/4/8/12, XF0–XF15, XD0/2/4/6/8/10/12/14, or XMTRX. The correspondence between FPRn_BANKi and the reference name is determined by the FR bit in FPSCR (see figure 2.4).
Programming Note: After a reset, the values of FPR0_BANK0–FPR15_BANK0 and FPR0_BANK1–FPR15_BANK1 are undefined. 2.2.4 Control Registers Status register, SR (32 bits, privilege protection, initial value = 0111 0000 0000 0000 0000 00XX 1111 00XX) 31 30 29 28 27 16 15 14 —...
Saved status register, SSR (32 bits, privilege protection, initial value undefined): The current contents of SR are saved to SSR in the event of an exception or interrupt. Saved program counter, SPC (32 bits, privilege protection, initial value undefined): The address of an instruction at which an interrupt or exception occurs is saved to SPC.
Page 33
Floating-point status/control register, FPSCR (32 bits, initial value = H’0004 0001) 22 21 20 19 18 17 12 11 — FR SZ PR DN Cause Enable Flag Note: —: Reserved. These bits are always read as 0, and should only be written with 0. •...
This area must be accessed in address translation mode using the TLB. Since external memory is defined as a 29-bit address space in the SH7750 architecture, the TLB’s physical page numbers do not cover a 32-bit address space. In address translation, the page numbers of this area can be set in the corresponding field of the TLB by accessing a memory-mapped register.
Data Format in Registers Register operands are always longwords (32 bits). When a memory operand is only a byte (8 bits) or a word (16 bits), it is sign-extended into a longword when loaded into a register. Longword Data Formats in Memory Memory data formats are classified into bytes, words, and longwords.
Note: The SH7750 does not support endian conversion for the 64-bit data format. Therefore, if double-precision floating-point format (64-bit) access is performed in little endian mode, the upper and lower 32 bits will be reversed. Processor States The SH7750 has five processor states: the reset state, exception-handling state, bus-released state, program execution state, and power-down state.
From any state when From any state when = 0 and = 0 and Power-on reset state Manual reset state = 0, Reset state = 1, = 1, Exception-handling state Bus request Bus request clearance Interrupt Interrupt Exception End of exception Bus-released state interrupt transition...
3.1.1 Features The SH7750 can handle 29-bit external memory space from an 8-bit address space identifier and 32-bit logical (virtual) address space. Address translation from virtual address to physical address is performed using the memory management unit (MMU) built into the SH7750. The MMU performs high-speed address translation by caching user-created address translation table information in an address translation buffer (translation lookaside buffer: TLB).
Page 40
(usually from 1 to 64 kbytes in size). In the following descriptions, the address space in virtual memory in the SH7750 is referred to as virtual address space, and the address space in physical memory as physical address space.
Page 41
Virtual memory Physical Process 1 memory Physical Physical Process 1 memory memory Process 1 Virtual Physical Process 1 Process 1 memory memory Physical memory Process 2 Process 2 Process 3 Process 3 Figure 3.1 Role of the MMU Rev.
Register Descriptions There are six MMU-related registers. 1. PTEH 10 9 — — ASID 2. PTEL 31 30 29 28 10 9 — — — — V SZ SZ C D SH WT 3. PTEA 4. TTB 5. TEA Virtual address at which MMU exception or address error occurred 6.
Page 44
1. Page table entry high register (PTEH): Longword access to PTEH can be performed from H’FF00 0000 in the P4 area and H’1F00 0000 in area 7. PTEH consists of the virtual page number (VPN) and address space identifier (ASID). When an MMU exception or address error exception occurs, the VPN of the virtual address at which the exception occurred is set in the VPN field by hardware.
Page 45
P3, or U0 area should be located at least eight instructions after the MMUCR update instruction. MMUCR contents can be changed by software. The LRUI bits and URC bits may also be updated by hardware. • LRUI: The LRU (least recently used) method is used to decide the ITLB entry to be replaced in the event of an ITLB miss.
3.3.1 Physical Memory Space The SH7750 supports a 32-bit physical memory space, and can access a 4-Gbyte address space. When the MMUCR.AT bit is cleared to 0 and the MMU is disabled, the address space is this physical memory space. The physical memory space is divided into a number of areas, as shown in figure 3.3.
Page 47
P4 Area: The P4 area is mapped onto SH7750 on-chip I/O channels. This area cannot be accessed using the cache. The P4 area is shown in detail in figure 3.4.
Page 48
H'E000 0000 Store queue H'E400 0000 Reserved area H'F000 0000 Instruction cache address array H'F100 0000 Instruction cache data array H'F200 0000 Instruction TLB address array H'F300 0000 Instruction TLB data arrays 1 and 2 H'F400 0000 Operand cache address array H'F500 0000 Operand cache data array H'F600 0000...
3.3.2 External Memory Space The SH7750 supports a 29-bit external memory space. The external memory space is divided into eight areas as shown in figure 3.5. Areas 0 to 6 relate to memory, such as SRAM, synchronous DRAM, DRAM, and PCMCIA. Area 7 is a reserved area. For details, see section 13, Bus State Controller (BSC), in the Hardware Manual.
Setting the MMUCR.AT bit to 1 enables the P0, P3, and U0 areas of the physical memory space in the SH7750 to be mapped onto any external memory space in 1-, 4-, or 64-kbyte, or 1-Mbyte, page units. By using an 8-bit address space identifier, the P0, U0, P3, and store queue areas can be increased to a maximum of 256.
3.3.4 On-Chip RAM Space In the SH7750, half (8 kbytes) of the instruction cache (16 kbytes) can be used as on-chip RAM. This can be done by changing the CCR settings. When the operand cache is used as on-chip RAM (CCR.ORA = 1), P0 area addresses H’7C00 0000 to H’7FFF FFFF are an on-chip RAM area.
3.3.6 Single Virtual Memory Mode and Multiple Virtual Memory Mode There are two virtual memory systems, single virtual memory and multiple virtual memory, either of which can be selected with the MMUCR.SV bit. In the single virtual memory system, a number of processes run simultaneously, using virtual address space on an exclusive basis, and the physical address corresponding to a particular virtual address is uniquely determined.
Page 54
• ASID: Address space identifier Indicates the process that can access a virtual page. In single virtual memory mode and user mode, or in multiple virtual memory mode, if the SH bit is 0, this identifier is compared with the ASID in PTEH when address comparison is performed.
Page 55
• C: Cacheability bit Indicates whether a page is cacheable. 0: Not cacheable 1: Cacheable When control register space is mapped, this bit must be cleared to 0. When performing PCMCIA space mapping in the cache enabled state, either clear this bit to 0 or set the WT bit to 1.
3.4.2 Instruction TLB (ITLB) Configuration The ITLB is used to translate a virtual address to a physical address in an instruction access. Information in the address translation table located in the UTLB is cached into the ITLB. Figure 3.9 shows the overall configuration of the ITLB. The ITLB consists of 4 fully-associative type entries.
Page 57
Data access to virtual address (VA) VA is VA is VA is VA is in P0, U0, in P4 area in P2 area in P1 area or P3 area On-chip I/O access CCR.OCE? MMUCR.AT = 1 CCR.CB? CCR.WT? SH = 0 and (MMUCR.SV = 0 or SR.MD = 0) VPNs match...
Page 58
Instruction access to virtual address (VA) VA is VA is VA is VA is in P0, U0, in P4 area in P2 area in P1 area or P3 area Access prohibited CCR.ICE? MMUCR.AT = 1 SH = 0 and (MMUCR.SV = 0 or SR.MD = 0) VPNs match VPNs match...
A TLB load instruction (LDTLB) is provided for recording UTLB entries. When an LDTLB instruction is issued, the SH7750 copies the contents of PTEH, PTEL, and PTEA to the UTLB entry indicated by MMUCR.URC. ITLB entries are not updated by the LDTLB instruction, and therefore address translation information purged from the UTLB entry may still remain in the ITLB entry.
3.5.4 Hardware ITLB Miss Handling In an instruction access, the SH7750 searches the ITLB. If it cannot find the necessary address translation information (i.e. in the event of an ITLB miss), the UTLB is searched by hardware, and if the necessary address translation information is present, it is recorded in the ITLB. This procedure is known as hardware ITLB miss handling.
This problem does not occur with the instruction TLB or instruction cache . In the SH7750, entry specification is performed using bits [13:5] of the virtual address in order to achieve fast operand cache operation. However, bits [13:10] of the virtual address in the case of a 1-kbyte page, and bits [13:12] of the virtual address in the case of a 4-kbyte page, are subject to address translation.
MMU Exceptions There are seven MMU exceptions: the instruction TLB multiple hit exception, instruction TLB miss exception, instruction TLB protection violation exception, data TLB multiple hit exception, data TLB miss exception, data TLB protection violation exception, and initial page write exception.
3.6.2 Instruction TLB Miss Exception An instruction TLB miss exception occurs when address translation information for the virtual address to which an instruction access is made is not found in the UTLB entries by the hardware ITLB miss handling procedure. The instruction TLB miss exception processing carried out by hardware and software is shown below.
3.6.3 Instruction TLB Protection Violation Exception An instruction TLB protection violation exception occurs when, even though an ITLB entry contains address translation information matching the virtual address to which an instruction access is made, the actual access type is not permitted by the access right specified by the PR bit. The instruction TLB protection violation exception processing carried out by hardware and software is shown below.
3.6.4 Data TLB Multiple Hit Exception A data TLB multiple hit exception occurs when more than one UTLB entry matches the virtual address to which a data access has been made. A data TLB multiple hit exception is also generated if multiple hits occur when the UTLB is searched in hardware ITLB miss handling.
Software Processing (Data TLB Miss Exception Handling Routine): Software is responsible for searching the external memory page table and assigning the necessary page table entry. Software should carry out the following processing in order to find and assign the necessary page table entry.
Software Processing (Data TLB Protection Violation Exception Handling Routine): Resolve the data TLB protection violation, execute the exception handling return instruction (RTE), terminate the exception handling routine, and return control to the normal flow. The RTE instruction should be issued at least one instruction after the LDTLB instruction. 3.6.7 Initial Page Write Exception An initial page write exception occurs when the D bit is 0 even though a UTLB entry contains...
Software Processing (Initial Page Write Exception Handling Routine): The following processing should be carried out as the responsibility of software: 1. Retrieve the necessary page table entry from external memory. 2. Write 1 to the D bit in the external memory page table entry. 3.
3.7.1 ITLB Address Array The ITLB address array is allocated to addresses H’F200 0000 to H’F2FF FFFF in the P4 area. An address array access requires a 32-bit address field specification (when reading or writing) and a 32-bit data field specification (when writing). Information for selecting the entry to be accessed is specified in the address field, and VPN, V, and ASID to be written to the address array are specified in the data field.
3.7.2 ITLB Data Array 1 ITLB data array 1 is allocated to addresses H’F300 0000 to H’F37F FFFF in the P4 area. A data array access requires a 32-bit address field specification (when reading or writing) and a 32-bit data field specification (when writing). Information for selecting the entry to be accessed is specified in the address field, and PPN, V, SZ, PR, C, and SH to be written to the data array are specified in the data field.
3.7.3 ITLB Data Array 2 ITLB data array 2 is allocated to addresses H’F380 0000 to H’F3FF FFFF in the P4 area. A data array access requires a 32-bit address field specification (when reading or writing) and a 32-bit data field specification (when writing). Information for selecting the entry to be accessed is specified in the address field, and SA and TC to be written to data array 2 are specified in the data field.
Page 72
In the address field, bits [31:24] have the value H’F6 indicating the UTLB address array, and the entry is selected by bits [13:8]. The address array bit [7] association bit (A bit) specifies whether or not address comparison is performed when writing to the UTLB address array. In the data field, VPN is indicated by bits [31:10], D by bit [9], V by bit [8], and ASID by bits [7:0].
3.7.5 UTLB Data Array 1 UTLB data array 1 is allocated to addresses H’F700 0000 to H’F77F FFFF in the P4 area. A data array access requires a 32-bit address field specification (when reading or writing) and a 32-bit data field specification (when writing). Information for selecting the entry to be accessed is specified in the address field, and PPN, V, SZ, PR, C, D, SH, and WT to be written to the data array are specified in the data field.
3.7.6 UTLB Data Array 2 UTLB data array 2 is allocated to addresses H’F780 0000 to H’F7FF FFFF in the P4 area. A data array access requires a 32-bit address field specification (when reading or writing) and a 32-bit data field specification (when writing). Information for selecting the entry to be accessed is specified in the address field, and SA and TC to be written to data array 2 are specified in the data field.
4.1.1 Features The SH7750 has an on-chip 8-kbyte instruction cache (IC) for instructions and 16-kbyte operand cache (OC) for data. Half of the memory of the operand cache (8 kbytes) can also be used as on- chip RAM. The features of these caches are summarized in table 4.1.
4.1.2 Register Configuration Table 4.2 shows the cache control registers. Table 4.2 Cache Control Registers Initial Area 7 Access Name Abbreviation R/W Value* Address* Address* Size Cache control H’0000 0000 H’FF00 001C H’1F00 001C register Queue address QACR0 Undefined H’FF00 0038 H’1F00 0038 control register 0 Queue address...
Page 77
(1) Cache Control Register (CCR): CCR contains the following bits: IIX: IC index enable ICI: IC invalidation ICE: IC enable OIX: OC index enable ORA: OC RAM enable OCI: OC invalidation Copy-back enable Write-through enable OCE: OC enable Longword access to CCR can be performed from H’FF00 001C in the P4 area and H’1F00 001C in area 7.
Page 78
• OCI: OC invalidation bit When 1 is written to this bit, the V and U bits of all OC entries are cleared to 0. This bit always returns 0 when read. • CB: Copy-back bit Indicates the P1 area cache write mode. 0: Write-through mode 1: Copy-back mode •...
The operand cache consists of 512 cache lines, each composed of a 19-bit tag, V bit, U bit, and 32- byte data. • Tag Stores the upper 19 bits of the 29-bit external memory address of the data line to be cached. The tag is not initialized by a power-on or manual reset.
3a. Cache hit The data indexed by effective address bits [4:0] is read from the data field of the cache line indexed by effective address bits [13:5] in accordance with the access size (quadword/longword/word/byte). 3b. Cache miss (no write-back) Data is read into the cache line from the external memory space corresponding to the effective address.
Page 82
3a. Cache hit (copy-back) A data write in accordance with the access size (quadword/longword/word/byte) is performed for the data indexed by bits [4:0] of the effective address of the data field of the cache line indexed by effective address bits [13:5]. Then 1 is set in the U bit. 3b.
4.3.4 Write-Back Buffer In order to give priority to data reads to the cache and improve performance, the SH7750 has a write-back buffer which holds the relevant cache entry when it becomes necessary to purge a dirty cache entry into external memory as the result of a cache miss. The write-back buffer contains one cache line of data and the physical address of the purge destination.
• When OC index mode is off (CCR.OIX = 0) H’7C00 0000 to H’7C00 0FFF (4 kB): Corresponds to RAM area 1 H’7C00 1000 to H’7C00 1FFF (4 kB): Corresponds to RAM area 1 H’7C00 2000 to H’7C00 2FFF (4 kB): Corresponds to RAM area 2 H’7C00 3000 to H’7C00 3FFF (4 kB): Corresponds to RAM area 2 H’7C00 4000 to H’7C00 4FFF (4 kB): Corresponds to RAM area 1 RAM areas 1 and 2 then repeat every 8 kbytes up to H’7FFF FFFF.
Prefetch Operation The SH7750 supports a prefetch instruction to reduce the cache fill penalty incurred as the result of a cache miss. If it is known that a cache miss will result from a read or write operation, it is possible to fill the cache with data beforehand by means of the prefetch instruction to prevent a cache miss due to the read or write operation, and so improve software performance.
The instruction cache consists of 256 cache lines, each composed of a 19-bit tag, V bit, and 32- byte data (16 instructions). • Tag Stores the upper 19 bits of the 29-bit external memory address of the data line to be cached. The tag is not initialized by a power-on or manual reset.
4.4.3 IC Index Mode Setting CCR.IIX to 1 enables IC indexing to be performed using bit [25] of the effective address. This is called IC index mode. In normal mode, with CCR.IIX cleared to 0, IC indexing is performed using bits [12:5] of the effective address; therefore, when 8 kbytes or more of consecutive program instructions are handled, the IC is fully used by this program.
2. IC address array write (non-associative) The tag and V bit specified in the data field are written to the IC entry corresponding to the entry set in the address field. The A bit in the address field should be cleared to 0. 3.
1. IC data array read Longword data is read into the data field from the data specified by the longword specification bits in the address field in the IC entry corresponding to the entry set in the address field. 2. IC data array write The longword data specified in the data field is written for the data specified by the longword specification bits in the address field in the IC entry corresponding to the entry set in the address field.
Page 91
The following three kinds of operation can be used on the OC address array: 1. OC address array read The tag, U bit, and V bit are read into the data field from the OC entry corresponding to the entry set in the address field. In a read, associative operation is not performed regardless of whether the association bit specified in the address field is 1 or 0.
4.5.4 OC Data Array The OC data array is allocated to addresses H’F500 0000 to H’F5FF FFFF in the P4 area. A data array access requires a 32-bit address field specification (when reading or writing) and a 32-bit data field specification. The entry to be accessed is specified in the address field, and the longword data to be written is specified in the data field.
Store Queues Two 32-byte store queues (SQs) are supported to perform high-speed writes to external memory. 4.6.1 SQ Configuration There are two 32-byte store queues, SQ0 and SQ1, as shown in figure 4.10. These two store queues can be set independently. SQ0[0] SQ0[1] SQ0[2]...
Page 94
• When MMU is on The SQ area (H’E000 0000 to H’E3FF FFFF) is set in VPN of the UTLB, and the transfer destination external memory address in PPN. The ASID, V, SZ, SH, PR, and D bits have the same meaning as for normal address translation, but the C and WT bits have no meaning with regard to this page.
4.6.4 SQ Protection It is possible to set protection against SQ writes and transfers to external memory. If an SQ write violates the protection setting, an exception will be generated but the SQ contents will be corrupted. If a transfer from the SQs to external memory (prefetch instruction) violates the protection setting, the transfer to external memory will be inhibited and an exception will be generated.
SH7750 exception handling is of three kinds: for resets, general exceptions, and interrupts. 5.1.2 Register Configuration The registers used in exception handling are shown in table 5.1.
Register Descriptions There are three registers related to exception handling. These are allocated to memory, and can be accessed by specifying the P4 address or area 7 address. 1. The exception event register (EXPEVT) resides at P4 address H’FF00 0024, and contains a 12- bit exception code.
Exception Handling Functions 5.3.1 Exception Handling Flow In exception handling, the contents of the program counter (PC) and status register (SR) are saved in the saved program counter (SPC) and saved status register (SSR), and the CPU starts execution of the appropriate exception handling routine according to the vector address. An exception handling routine is a program written by the user to handle a specific exception.
Reset requested? Execute next instruction Is highest- General priority exception exception requested? re-exception type? Cancel instruction execution result Interrupt requested? SSR ← SR EXPEVT ← exception code SPC ← PC SR. {MD, RB, BL, FD, IMASK} ← 11101111 SGR ← R15 PC ←...
Page 104
Pipeline flow: TLB miss (data access) Instruction n Instruction n+1 General illegal instruction exception TLB miss (instruction access) Instruction n+2 Instruction fetch ID: Instruction decode EX: Instruction execution Instruction n+3 MA: Memory access WB: Write-back Order of detection: General illegal instruction exception (instruction n+1) and TLB miss (instruction n+2) are detected simultaneously TLB miss (instruction n) Order of exception handling:...
5.5.3 Exception Requests and BL Bit When the BL bit in SR is 0, exceptions and interrupts are accepted. When the BL bit in SR is 1 and an exception other than a user break is generated, the CPU’s internal registers are set to their post-reset state, the registers of the other modules retain their contents prior to the exception, and the CPU branches to the same address as in a reset (H'A000 0000).
Description of Exceptions The various exception handling operations are described here, covering exception sources, transition addresses, and processor operation when a transition is made. 5.6.1 Resets (1) Power-On Reset • Sources: SCK2 pin high level and pin low level ...
Page 107
(2) Manual Reset • Sources: SCK2 pin low level and pin low level When a general exception other than a user break occurs while the BL bit is set to 1 in SR When the watchdog timer overflows while the RSTS bit is set to 1 in WTCSR. For details, see section 10, Clock Oscillation Circuits.
Page 108
(3) Hitachi-UDI Reset • Source: SDIR.TI3–TI0 = B'0110 (negation) or B'0111 (assertion) • Transition address: H'A000 0000 • Transition operations: Exception code H'000 is set in EXPEVT, initialization of VBR and SR is performed, and a branch is made to PC = H'A000 0000.
Page 109
(4) Instruction TLB Multiple-Hit Exception • Source: Multiple ITLB address matches • Transition address: H’A000 0000 • Transition operations: The virtual address (32 bits) at which this exception occurred is set in TEA, and the corresponding virtual page number (22 bits) is set in PTEH [31:10]. ASID in PTEH indicates the ASID when this exception occurred.
Page 110
(5) Operand TLB Multiple-Hit Exception • Source: Multiple UTLB address matches • Transition address: H’A000 0000 • Transition operations: The virtual address (32 bits) at which this exception occurred is set in TEA, and the corresponding virtual page number (22 bits) is set in PTEH [31:10]. ASID in PTEH indicates the ASID when this exception occurred.
5.6.2 General Exceptions (1) Data TLB Miss Exception • Source: Address mismatch in UTLB address comparison • Transition address: VBR + H’0000 0400 • Transition operations: The virtual address (32 bits) at which this exception occurred is set in TEA, and the corresponding virtual page number (22 bits) is set in PTEH [31:10].
Page 112
(2) Instruction TLB Miss Exception • Source: Address mismatch in ITLB address comparison • Transition address: VBR + H’0000 0400 • Transition operations: The virtual address (32 bits) at which this exception occurred is set in TEA, and the corresponding virtual page number (22 bits) is set in PTEH [31:10]. ASID in PTEH indicates the ASID when this exception occurred.
Page 113
(3) Initial Page Write Exception • Source: TLB is hit in a store access, but dirty bit D = 0 • Transition address: VBR + H’0000 0100 • Transition operations: The virtual address (32 bits) at which this exception occurred is set in TEA, and the corresponding virtual page number (22 bits) is set in PTEH [31:10].
Page 114
(4) Data TLB Protection Violation Exception • Source: The access does not accord with the UTLB protection information (PR bits) shown below. Privileged Mode User Mode Only read access possible Access not possible Read/write access possible Access not possible Only read access possible Only read access possible Read/write access possible Read/write access possible...
Page 115
(5) Instruction TLB Protection Violation Exception • Source: The access does not accord with the ITLB protection information (PR bits) shown below. Privileged Mode User Mode Access possible Access not possible Access possible Access possible • Transition address: VBR + H’0000 0100 •...
Page 116
(6) Data Address Error • Sources: Word data access from other than a word boundary (2n +1) Longword data access from other than a longword data boundary (4n +1, 4n + 2, or 4n +3) Quadword data access from other than a quadword data boundary (8n +1, 8n + 2, 8n +3, 8n + 4, 8n + 5, 8n + 6, or 8n + 7) ...
Page 117
(7) Instruction Address Error • Sources: Instruction fetch from other than a word boundary (2n +1) Instruction fetch from area H'8000 0000–H'FFFF FFFF in user mode • Transition address: VBR + H'0000 0100 • Transition operations: The virtual address (32 bits) at which this exception occurred is set in TEA, and the corresponding virtual page number (22 bits) is set in PTEH [31:10].
Page 118
(8) Unconditional Trap • Source: Execution of TRAPA instruction • Transition address: VBR + H’0000 0100 • Transition operations: As this is a processing-completion-type exception, the PC contents for the instruction following the TRAPA instruction are saved in SPC. The value of SR when the TRAPA instruction is executed are saved in SSR.
Page 119
(9) General Illegal Instruction Exception • Sources: Decoding of an undefined instruction not in a delay slot Delayed branch instructions: JMP, JSR, BRA, BRAF, BSR, BSRF, RTS, RTE, BT/S, BF/S Undefined instruction: H’FFFD Decoding in user mode of a privileged instruction not in a delay slot Privileged instructions: LDC, STC, RTE, LDTLB, SLEEP, but excluding LDC/STC instructions that access GBR •...
Page 120
(10) Slot Illegal Instruction Exception • Sources: Decoding of an undefined instruction in a delay slot Delayed branch instructions: JMP, JSR, BRA, BRAF, BSR, BSRF, RTS, RTE, BT/S, BF/S Undefined instruction: H’FFFD Decoding of an instruction that modifies PC in a delay slot Instructions that modify PC: JMP, JSR, BRA, BRAF, BSR, BSRF, RTS, RTE, BT, BF, BT/S, BF/S, TRAPA, LDC Rm, SR, LDC.L @Rm+, SR ...
Page 121
(11) General FPU Disable Exception • Source: Decoding of an FPU instruction* not in a delay slot with SR.FD =1 • Transition address: VBR + H’0000 0100 • Transition operations: The PC and SR contents for the instruction at which this exception occurred are saved in SPC and SSR.
Page 122
(12) Slot FPU Disable Exception • Source: Decoding of an FPU instruction in a delay slot with SR.FD =1 • Transition address: VBR + H’0000 0100 • Transition operations: The PC contents for the preceding delayed branch instruction are saved in SPC. The SR contents when this exception occurred are saved in SSR.
Page 123
(13) User Breakpoint Trap • Source: Fulfilling of a break condition set in the user break controller • Transition address: VBR + H’0000 0100, or DBR • Transition operations: In the case of a post-execution break, the PC contents for the instruction following the instruction at which the breakpoint is set are set in SPC.
Page 124
(14) FPU Exception • Source: Exception due to execution of a floating-point operation • Transition address: VBR + H’0000 0100 • Transition operations: The PC and SR contents for the instruction at which this exception occurred are saved in SPC and SSR.
5.6.3 Interrupts (1) NMI • Source: NMI pin edge detection • Transition address: VBR + H’0000 0600 • Transition operations: The PC and SR contents for the instruction at which this exception is accepted are saved in SPC and SSR. Exception code H’1C0 is set in INTEVT.
Page 126
(2) IRL Interrupts • Source: The interrupt mask bit setting in SR is smaller than the IRL (3–0) level, and the BL bit in SR is 0 (accepted at instruction boundary). • Transition address: VBR + H'0000 0600 • Transition operations: The PC contents immediately after the instruction at which the interrupt is accepted are set in SPC.
Page 127
(3) Peripheral Module Interrupts • Source: The interrupt mask bit setting in SR is smaller than the peripheral module (Hitachi- UDI, GPIO, DMAC, TMU, RTC, SCI, SCIF, WDT, or REF) interrupt level, and the BL bit in SR is 0 (accepted at instruction boundary).
5.6.4 Priority Order with Multiple Exceptions With some instructions, such as instructions that make two accesses to memory, and the indivisible pair comprising a delayed branch instruction and delay slot instruction, multiple exceptions occur. Care is required in these cases, as the exception priority order differs from the normal order.
Usage Notes 1. Return from exception handling a. Check the BL bit in SR with software. If SPC and SSR have been saved to external memory, set the BL bit in SR to 1 before restoring them. b. Issue an RTE instruction. When RTE is executed, the SPC contents are set in PC, the SSR contents are set in SR, and branch is made to the SPC address to return from the exception handling routine.
Page 130
• When the UBDE bit in the BRCR register is set to 1 and the user break debug support function* is used, do not locate a BT, BF, BT/S, BF/S, BRA, or BSR instruction at the address indicated by the DBR register. Note: * See section 20.4 in the SH-4 Hardware manual.
A floating-point number consists of the following three fields: • Sign (s) • Exponent (e) • Fraction (f) The SH7750 can handle single-precision and double-precision floating-point numbers, using the formats shown in figures 6.1 and 6.2. 23 22 Figure 6.1 Format of Single-Precision Floating-Point Number...
Page 132
52 51 Figure 6.2 Format of Double-Precision Floating-Point Number The exponent is expressed in biased form, as follows: e = E + bias The range of unbiased exponent E is E – 1 to E + 1. The two values E –...
EN.V bit in the FPSCR register. An exception will not be generated in this case. The qNAN values generated by the SH7750 as operation results are as follows: • Single-precision qNaN: H’7FBFFFFF •...
6.3.2 Floating-Point Status/Control Register (FPSCR) Floating-point status/control register, FPSCR (32 bits, initial value = H’0004 0001) • FR: Floating-point register bank FR = 0: FPR0_BANK0–FPR15_BANK0 are assigned to FR0–FR15; FPR0_BANK1– FPR15_BANK1 are assigned to XF0–XF15. FR = 1: FPR0_BANK0–FPR15_BANK0 are assigned to XF0–XF15; FPR0_BANK1– FPR15_BANK1 are assigned to FR0–FR15.
• Bits 22 to 31: Reserved These bits are always read as 0, and should only be written with 0. Notes: The following functions have been added to the FPU of the SH7750 (not provided in the FPU of the SH7718): 1.
0, but the corresponding bit in the flag field remains unchanged. • Enable/disable exception handling The SH7750 supports enable exception handling and disable exception handling. Enable exception handling is initiated in the following cases: FPU error (E): FPSCR.DN = 0 and a denormalized number is input ...
Geometric Operation Instructions Geometric operation instructions perform approximate-value computations. To enable high-speed computation with a minimum of hardware, the SH7750 ignores comparatively small values in the partial computation results of four multiplications. Consequently, the error shown below is produced in the result of the computation:...
Page 141
The number of significant digits is 24 for a normalized number and 23 for a denormalized number (number of leading zeros in the fractional part). In future version of SH series, the above error is guaranteed, but the same result as SH7750 is not guaranteed.
In addition to the powerful new geometric operation instructions, the SH7750 also supports high- speed data transfer instructions. When FPSCR.SZ = 1, the SH7750 can perform data transfer by means of pair single-precision data transfer instructions. • FMOV DRm/XDm, DRn/XDRn (m, n: 0, 2, 4, 6, 8, 10, 12, 14) •...
When a double-precision floating- point operation is specified (FPSCR.PR = 1), the result of an operation using quadword access will be undefined. When the SH7750 moves byte-size or word-size data from memory to a register, the data is sign-extended.
Page 144
In an RTE delay slot, status register (SR) bits are referenced as follows. In instruction access, the MD bit is used before modification, and in data access, the MD bit is accessed after modification. The other bits—S, T, M, Q, FD, BL, and RB—after modification are used for delay slot instruction execution.
Addressing Modes Addressing modes and effective address calculation methods are shown in table 7.1. When a location in virtual memory space is accessed (MMUCR.AT = 1), the effective address is translated into a physical memory address. If multiple virtual memory space systems are selected (MMUCR.SV = 0), the least significant bit of PTEH is also referenced as the access ASID.
Page 146
Table 7.1 Addressing Modes and Effective Addresses (cont) Addressing Instruction Calculation Mode Format Effective Address Calculation Method Formula Register @(disp:4, Rn) Effective address is register Rn contents with Byte: Rn + disp → EA indirect with 4-bit displacement disp added. After disp is displacement zero-extended, it is multiplied by 1 (byte), 2 (word), Word: Rn +...
Page 147
Table 7.1 Addressing Modes and Effective Addresses (cont) Addressing Instruction Calculation Mode Format Effective Address Calculation Method Formula PC-relative @(disp:8, PC) Effective address is PC+4 with 8-bit displacement Word: PC + 4 + disp × 2 → with disp added. After disp is zero-extended, it is displacement multiplied by 2 (word), or 4 (longword), according to the operand size.
Page 148
Table 7.1 Addressing Modes and Effective Addresses (cont) Addressing Instruction Calculation Mode Format Effective Address Calculation Method Formula PC-relative disp:12 Effective address is PC+4 with 12-bit displacement PC + 4 + disp × 2 → Branch- disp added after being sign-extended and multiplied by 2.
Instruction Set Table 7.2 shows the notation used in the following SH instruction list. Table 7.2 Notation Used in Instruction List Item Format Description Instruction OP.Sz SRC, DEST Operation code mnemonic Size SRC: Source DEST: Source and/or destination operand →, ← Summary of Transfer direction operation...
Page 155
Table 7.6 Shift Instructions Instruction Operation Instruction Code Privileged T Bit T ← Rn ← MSB ROTL 0100nnnn00000100 — LSB → Rn → T ROTR 0100nnnn00000101 — T ← Rn ← T ROTCL 0100nnnn00100100 — T → Rn → T ROTCR 0100nnnn00100101 —...
Page 156
Table 7.7 Branch Instructions Instruction Operation Instruction Code Privileged T Bit When T = 0, disp × 2 + PC + label 10001011dddddddd — — 4 → PC When T = 1, nop BF/S label Delayed branch; when T = 0, 10001111dddddddd —...
Page 157
Table 7.8 System Control Instructions Instruction Operation Instruction Code Privileged T Bit 0 → MACH, MACL CLRMAC 0000000000101000 — — 0 → S CLRS 0000000001001000 — — 0 → T CLRT 0000000000001000 — Rm → SR Rm,SR 0100mmmm00001110 Privileged Rm → GBR Rm,GBR 0100mmmm00011110 —...
Page 158
Table 7.8 System Control Instructions (cont) Instruction Operation Instruction Code Privileged T Bit 1 → S SETS 0000000001011000 — — 1 → T SETT 0000000000011000 — SLEEP Sleep or standby 0000000000011011 Privileged — SR → Rn SR,Rn 0000nnnn00000010 Privileged — GBR →...
Section 8 Pipelining The SH7750 is a 2-ILP (instruction-level-parallelism) superscalar pipelining microprocessor. Instruction execution is pipelined, and two instructions can be executed in parallel. The execution cycles depend on the implementation of a processor. Definitions in this section may not be applicable to SH-4 Series models other than the SH7750.
Parallel-Executability Instructions are categorized into six groups according to the internal function blocks used, as shown in table 8.1. Table 8.2 shows the parallel-executability of pairs of instructions in terms of groups. For example, ADD in the EX group and BRA in the BR group can be executed in parallel. Table 8.1 Instruction Groups 1.
Table 8.2 Parallel-Executability 2nd Instruction Instruction O: Can be executed in parallel X: Cannot be executed in parallel Execution Cycles and Pipeline Stalling There are three basic clocks in this processor: the I-clock, B-clock, and P-clock. Each hardware unit operates on one of these clocks, as follows: •...
Page 175
The instruction execution sequence is expressed as a combination of the execution patterns shown in figure 8.2. One instruction is separated from the next by the number of machine cycles for its issue rate. Normally, execution, data access, and write-back stages cannot be overlapped onto the same stages of another instruction;...
Page 176
Anti-flow dependency can occur only between a preceding double-precision FADD, FMUL, FSUB, or FTRV and a following FMOV, FLDI0, FLDI1, FABS, FNEG, or FSTS. See figure 8.3 (g). If an executing instruction locks any resource—i.e. a function block that performs a basic operation—a following instruction that happens to attempt to use the locked resource must be stalled (figure 8.3 (h)).
Page 177
(a) Serial execution: non-parallel-executable instructions 1 issue cycle SHAD R0,R1 EX-group SHAD and EX-group ADD R2,R3 cannot be executed in parallel. Therefore, next SHAD is issued first, and the following 1 stall cycle ADD is recombined with the next instruction. (b) Parallel execution: parallel-executable and no dependency 1 issue cycle EX-group ADD and LS-group MOV.L can...
Page 178
(e) Flow dependency Zero-cycle latency The following instruction, ADD, is not R0,R1 stalled when executed after an instruction R2,R1 with zero-cycle latency, even if there is dependency. 1-cycle latency ADD and MOV.L are not executed in R2,R1 parallel, since MOV.L references the result MOV.L @R1,R1 of ADD as its destination address.
Page 179
(e) Flow dependency (cont) Effectively 1-cycle latency for consecutive LDS/FLOAT instructions R0,FPUL FLOAT FPUL,FR0 R1,FPUL FLOAT FPUL,R1 Effectively 1-cycle latency for consecutive FTRC FR0,FPUL FTRC/STS instructions FPUL,R0 FTRC FR1,FPUL FPUL,R1 (f) Output dependency 11-cycle latency FSQRT FR4 FMOV FR0,FR4 10 stall cycles = latency (11) - 1 The registers are written-back in program order.
Page 189
4. Conditional branch latency “2 (or 1)”: The latency is 2 for a nonzero displacement, and 1 for a zero displacement. 5. Double-precision floating-point instruction latency “(L1, L2)/L3”: L1 is the latency for FR [n+1], L2 that for FR [n], and L3 that for FPSCR. 6.
Section 9 Power-Down Modes Overview In the power-down modes, some of the on-chip peripheral modules and the CPU functions are halted, enabling power consumption to be reduced. 9.1.1 Types of Power-Down Modes The following power-down modes and functions are provided: •...
Page 192
Table 9.1 Status of CPU and Peripheral Modules in Power-Down Modes Status Power- On-chip Down Entering On-Chip Peripheral External Exiting Mode Conditions CPG Memory Modules Pins Memory Method Refreshing • Interrupt Sleep SLEEP Operating Halted Held Operating Held instruction (registers •...
9.1.2 Register Configuration Table 9.2 shows the registers used for power-down mode control. Table 9.2 Power-Down Mode Registers Initial Area 7 Access Name Abbreviation Value P4 Address Address Size Standby control register STBCR H’00 H’FFC00004 H’1FC00004 Standby control register 2 STBCR2 H’00 H’FFC00010 H’1FC00010 Register Descriptions...
Page 194
Bit 5—Peripheral Module Pin Pull-Up Control (PPU): Controls the state of peripheral module related pins. When the PPU bit is cleared to 0, the pull-up resistor is turned on for peripheral module related pins in the input or high-impedance state. For the relevant pins, see section 9.2.3, Peripheral Module Pin Pull-Up Control.
Bit 1—Module Stop 1 (MSTP1): Specifies stopping of the clock supply to the realtime clock (RTC) among the on-chip peripheral modules. The clock supply to the RTC is stopped when the MSTP1 bit is set to 1. When the clock supply is stopped, RTC registers cannot be accessed but the counters continue to operate.
9.2.3 Peripheral Module Pin Pull-Up Control When bit 5 in the standby control register (STBCR) is cleared to 0, peripheral module related pins are pulled up when in the input or high-impedance state. • Relevant Pins SCI related pins MD0/SCK MD1/TXD2 MD2/RXD2 MD7/TXD...
Sleep Mode 9.3.1 Transition to Sleep Mode If a SLEEP instruction is executed when the STBY bit in STBCR is cleared to 0, the chip switches from the program execution state to sleep mode. After execution of the SLEEP instruction, the CPU halts but its register contents are retained.
Standby Mode 9.5.1 Transition to Standby Mode If a SLEEP instruction is executed when the STBY bit in STBCR is set to 1, the chip switches from the program execution state to standby mode. In standby mode, the on-chip peripheral modules halt as well as the CPU.
9.5.2 Exit from Standby Mode Standby mode is exited by means of an interrupt (NMI, IRL, or on-chip peripheral module) or a reset via the pin. Exit by Interrupt: A hot start can be performed by means of the on-chip WDT. When an NMI, , or on-chip peripheral module (except interval timer) interrupt is detected, the WDT starts counting.
Module Standby Function 9.6.1 Transition to Module Standby Function Setting the MSTP4–MSTP0 bits in the standby control register to 1 enables the clock supply to the corresponding on-chip peripheral modules to be halted. Use of this function allows power consumption in sleep mode to be further reduced. In the module standby state, the on-chip peripheral module external pins retain their states prior to halting of the modules, and most registers retain their states prior to halting of the modules.
Section 10 Instruction Descriptions Instructions are listed in this section in alphabetical order. The following format is used for the instruction descriptions. Instruction Name Full Name Instruction Type Function (Indication of delayed branch instruction or interrupt-disabling instruction) Execution Format Summary of Operation Instruction Code States T Bit...
Page 202
unsigned char Read_Byte(unsigned long Addr); unsigned short Read_Word(unsigned long Addr); unsigned long Read_Long(unsigned long Addr); These reflect the respective sizes of address Addr. A word read from other than a 2n address, or a longword read from other than a 4n address, will be detected as an address error. unsigned char Write_Byte(unsigned long Addr, unsigned long Data);...
Page 203
Error( char *er ); Error display function These are floating-point number definition statements. #define PZERO #define NZERO #define DENORM #define NORM #define PINF #define NINF #define qNaN #define sNaN #define EQ #define GT #define LT #define UO #define INVALID #define FADD #define FSUB #define CAUSE 0x0003f000...
Page 209
else if(data_type_of(m+i) == NZERO) FR[m+i] = -0.0; (data_type_of(n+i) == PZERO) FR[n+i] = +0.0; else if(data_type_of(n+i) == NZERO) FR[n+i] = -0.0; mlt[i].d = FR[m+i]; mlt[i].d *= FR[n+i]; /* To be precise, with FIPR, the lower 18 bits are discarded; therefore, this description is simplified, and differs from the hardware.
Page 213
void qnan(int n) if (FPSCR_PR==0) FR[n] = 0x7fbfffff; else { FR[n] = 0x7ff7ffff; FR[n+1] = 0xffffffff; Example An example is shown using assembler mnemonics, indicating the states before and after execution of the instruction. Italics (e.g., .align) indicate an assembler control instruction. The meaning of the assembler control instructions is given below.
10.1 ADD binary Arithmetic Instruction Binary Addition Execution Format Summary of Operation Instruction Code States T Bit Rn+Rm → Rn ADD Rm,Rn 0011nnnnmmmm1100 1 — Rn+imm → Rn ADD #imm,Rn 0111nnnniiiiiiii 1 — Description This instruction adds together the contents of general registers Rn and Rm and stores the result in 8-bit immediate data can also be added to the contents of general register Rn.
10.2 ADDC ADD with Carry Arithmetic Instruction Binary Addition with Carry Execution Format Summary of Operation Instruction Code States T Bit Rn+Rm+T → Rn, carry → T 0011nnnnmmmm1110 1 ADDC Rm,Rn Carry Description This instruction adds together the contents of general registers Rn and Rm and the T bit, and stores the result in Rn.
10.3 ADDV ADD with (V flag) overflow check Arithmetic Instruction Binary Addition with Overflow Check Execution Format Summary of Operation Instruction Code States T Bit Rn+Rm → Rn, ADDV Rm,Rn 0011nnnnmmmm1111 1 Overflow overflow → T Description This instruction adds together the contents of general registers Rn and Rm and stores the result in Rn.
Page 221
10.5 Branch if False Branch Instruction Conditional Branch Execution Format Summary of Operation Instruction Code States T Bit BF label If T = 0 10001011dddddddd 1 — PC + 4 + disp × 2 → PC If T = 1, nop Description This is a conditional branch instruction that references the T bit.
Page 222
Example ;Normally T = 0 CLRT ;T = 0, so branch is not taken. TRGET_T ;T = 0, so branch to TRGET_F. TRGET_F ;← BF instruction branch destination TRGET_F: Rev. 2.0, 03/99, page 208 of 396...
10.6 BF/S Branch if False with delay Slot Branch Instruction Conditional Branch with Delay Delayed Branch Instruction Execution Format Summary of Operation Instruction Code States T Bit BF/S label If T = 0 10001111dddddddd 1 — PC + 4 + disp × 2 → PC If T = 1, nop Description This is a delayed conditional branch instruction that references the T bit.
Page 224
Operation BFS(int d) /* BFS disp */ int disp; unsigned int temp; temp=PC; if ((d&0x80)==0) disp=(0x000000FF & d); else disp=(0xFFFFFF00 | d); if (T==0) PC=PC+4+(disp<<1); else PC+=4; Delay_Slot(temp+2); Example ;Normally T = 0 CLRT ;T = 0, so branch is not taken. BT/S TRGET_T ;T = 0, so branch to TRGET.
10.7 BRAnch Branch Instruction Unconditional Branch Delayed Branch Instruction Execution Format Summary of Operation Instruction Code States T Bit PC+4+disp×2 → PC BRA label 1010dddddddddddd 1 — Description This is an unconditional branch instruction. The branch destination is address (PC + 4 + displacement ×...
Page 226
Example ;Branch to TRGET. TRGET ;ADD executed before branch. R0,R1 ;← BRA instruction branch destination TRGET: Rev. 2.0, 03/99, page 212 of 396...
10.8 BRAF BRAnch Far Branch Instruction Unconditional Branch Delayed Branch Instruction Execution Format Summary of Operation Instruction Code States T Bit PC+4+Rn → PC BRAF Rn 0000nnnn00100011 2 — Description This is an unconditional branch instruction. The branch destination is address (PC + 4 + Rn). The branch destination address is the result of adding 4 plus the 32-bit contents of general register Rn to PC.
10.9 Branch to SubRoutine Branch Instruction Branch to Subroutine Procedure Delayed Branch Instruction Execution Format Summary of Operation Instruction Code States T Bit PC+4 → PR, BSR label 1011dddddddddddd 1 — PC+4+disp×2 → PC Description This instruction branches to address (PC + 4 + displacement × 2), and stores address (PC + 4) in PR.
Page 229
Example ;Branch to TRGET. TRGET ;MOV executed before branch. R3,R4 ;Subroutine procedure return destination (contents of PR) R0,R1 ..;← Entry to procedure TRGET: R2,R3 ;Return to above ADD instruction. ;MOV executed before branch. #1,R0 Rev. 2.0, 03/99, page 215 of 396...
10.10 BSRF Branch to SubRoutine Far Branch Instruction Branch to Subroutine Procedure Delayed Branch Instruction Execution Format Summary of Operation Instruction Code States T Bit PC+4 → PR, BSRF Rn 0000nnnn00000011 2 — PC+4+Rn → PC Description This instruction branches to address (PC + 4 + Rn), and stores address (PC + 4) in PR. The PC source value is the BSRF instruction address.
Page 231
Example #(TRGET-BSRF_PC),R0 ;Set displacement. MOV.L ;Branch to TRGET. BSRF ;MOV executed before branch. R3,R4 BSRF_PC: R0,R1 ..;← Entry to procedure TRGET: R2,R3 ;Return to above ADD instruction. ;MOV executed before branch. #1,R0 Rev. 2.0, 03/99, page 217 of 396...
Page 232
10.11 Branch if True Branch Instruction Conditional Branch Execution Format Summary of Operation Instruction Code States T Bit BT label If T = 1 10001001dddddddd 1 — PC + 4 + disp × 2 → PC If T = 0, nop Description This is a conditional branch instruction that references the T bit.
Page 233
Example ;Normally T = 1 SETT ;T = 1, so branch is not taken. TRGET_F ;T = 1, so branch to TRGET_T. TRGET_T ;← BT instruction branch destination TRGET_T: Rev. 2.0, 03/99, page 219 of 396...
10.12 BT/S Branch if True with delay Slot Branch Instruction Conditional Branch with Delay Delayed Branch Instruction Execution Format Summary of Operation Instruction Code States T Bit BT/S label If T = 1 10001101dddddddd 1 — PC + 4 + disp × 2 → PC If T = 0, nop Description This is a conditional branch instruction that references the T bit.
Page 235
Operation BTS(int d) /* BTS disp */ int disp; unsigned temp; temp=PC; if ((d&0x80)==0) disp=(0x000000FF & d); else disp=(0xFFFFFF00 | d); if (T==1) PC=PC+4+(disp<<1); else PC+=4; Delay_Slot(temp+2); Example ;Normally T = 1 SETT ;T = 1, so branch is not taken. BF/S TRGET_F ;T = 1, so branch to TRGET_T.
10.13 CLRMAC CleaR MAC register System Control Instruction MAC Register Clear Execution Format Summary of Operation Instruction Code States T Bit 0 → MACH, MACL CLRMAC 0000000000101000 1 — Description This instruction clears the MACH and MACL registers. Operation CLRMAC( ) /* CLRMAC */ MACH=0;...
10.14 CLRS CleaR S bit System Control Instruction S Bit Clear Execution Format Summary of Operation Instruction Code States T Bit 0 → S CLRS 0000000001001000 1 — Description This instruction clears the S bit to 0. Operation CLRS( ) /* CLRS */ S=0;...
10.15 CLRT CleaR T bit System Control Instruction T Bit Clear Execution Format Summary of Operation Instruction Code States T Bit 0 → T CLRT 0000000000001000 1 Description This instruction clears the T bit. Operation CLRT( ) /* CLRT */ T=0;...
10.16 CMP/cond CoMPare conditionally Arithmetic Instruction Compare Execution Format Summary of Operation Instruction Code States T Bit If Rn = Rm, 1 → T CMP/EQ Rm,Rn 0011nnnnmmmm0000 1 Result of comparison If Rn ≥ Rm, signed, 1 → T CMP/GE Rm,Rn 0011nnnnmmmm0011 1 Result of...
Page 240
Mnemonic Description CMP/EQ Rm,Rn If Rn = Rm, T = 1 If Rn ≥ Rm as signed values, T = 1 CMP/GE Rm,Rn CMP/GT Rm,Rn If Rn > Rm as signed values, T = 1 CMP/HI Rm,Rn If Rn > Rm as unsigned values, T = 1 If Rn ≥...
Page 241
PC+=2; CMPHS(long m, long n) /* CMP_HS Rm,Rn */ if ((unsigned long)R[n]>=(unsigned long)R[m]) T=1; else T=0; PC+=2; CMPPL(long n) /* CMP_PL Rn */ if ((long)R[n]>0) T=1; else T=0; PC+=2; CMPPZ(long n) /* CMP_PZ Rn */ if ((long)R[n]>=0) T=1; else T=0; PC+=2;...
Page 242
PC+=2; CMPIM(long i) /* CMP_EQ #imm,R0 */ long imm; if ((i&0x80)==0) imm=(0x000000FF & (long i)); else imm=(0xFFFFFF00 | (long i)); if (R[0]==imm) T=1; else T=0; PC+=2; Example ;R0 = H’7FFFFFFF, R1 = H’80000000 CMP/GE R0,R1 ;T = 0, so branch is not taken. TRGET_T ;R0 = H’7FFFFFFF, R1 = H’80000000 CMP/HS...
10.17 DIV0S DIVide (step 0) as Signed Arithmetic Instruction Initialization for Signed Division Execution Format Summary of Operation Instruction Code States T Bit MSB of Rn → Q, DIV0S Rm,Rn 0010nnnnmmmm0111 1 Result of MSB of Rm → M, calculation M^Q →...
10.18 DIV0U DIVide (step 0) as Unsigned Arithmetic Instruction Initialization for Unsigned Division Execution Format Summary of Operation Instruction Code States T Bit 0 → M/Q/T DIV0U 0000000000011001 1 Description This instruction performs initial settings for unsigned division. This instruction is followed by a DIV1 instruction that executes 1-digit division, for example, and repeated divisions are executed to find the quotient.
10.19 DIV1 DIVide 1 step Arithmetic Instruction Division Execution Format Summary of Operation Instruction Code States T Bit DIV1 Rm,Rn 1-step division 0011nnnnmmmm0100 1 Result of (Rn ÷ Rm) calculation Description This instruction performs 1-digit division (1-step division) of the 32-bit contents of general register Rn (dividend) by the contents of Rm (divisor).
Page 246
switch(old_q){ case 0:switch(M){ case 0:tmp0=R[n]; R[n]-=tmp2; tmp1=(R[n]>tmp0); switch(Q){ case 0:Q=tmp1; break; case 1:Q=(unsigned char)(tmp1==0); break; break; case 1:tmp0=R[n]; R[n]+=tmp2; tmp1=(R[n]<tmp0); switch(Q){ case 0:Q=(unsigned char)(tmp1==0); break; case 1:Q=tmp1; break; break; break; case 1:switch(M){ case 0:tmp0=R[n]; R[n]+=tmp2; tmp1=(R[n]<tmp0); switch(Q){ case 0:Q=tmp1; break; case 1:Q=(unsigned char)(tmp1==0);...
Page 247
R[n]-=tmp2; tmp1=(R[n]>tmp0); switch(Q){ case 0:Q=(unsigned char)(tmp1==0); break; case 1:Q=tmp1; break; break; break; T=(Q==M); PC+=2; Example 1 ;R1 (32 bits) ÷ R0 (16 bits) = R1 (16 bits); unsigned ;Set divisor in upper 16 bits, clear lower 16 bits to 0 SHLL16 ;Check for division by zero R0,R0...
Page 248
Example 2 ; R1:R2 (64 bits) ÷ R0 (32 bits) = R2 (32 bits); unsigned ;Check for division by zero R0,R0 ZERO_DIV ;Check for overflow CMP/HS R0,R1 OVER_DIV ;Flag initialization DIV0U .arepeat ;Repeat 32 times ROTCL DIV1 R0,R1 .aendr ;R2 = quotient ROTCL Example 3 ;R1 (16 bits) ÷...
Page 249
Example 4 ;R2 (32 bits) ÷ R0 (32 bits) = R2 (32 bits); signed R2,R3 ROTCL ;Dividend sign-extended to 64 bits (R1:R2) SUBC R1,R1 ;R3 = 0 R3,R3 ;If dividend is negative, subtract 1 to convert to one’s complement notation SUBC R3,R2 ;Flag initialization...
10.20 DMULS.L Double-length MULtiply as Signed Arithmetic Instruction Signed Double-Length Multiplication Execution Format Summary of Operation Instruction Code States T Bit DMULS.L Rm,Rn Signed, 0011nnnnmmmm1101 2–5 — Rn × Rm → MACH, MACL Description This instruction performs 32-bit multiplication of the contents of general register Rn by the contents of Rm, and stores the 64-bit result in the MACH and MACL registers.
Page 251
temp0=RmL*RnL; temp1=RmH*RnL; temp2=RmL*RnH; temp3=RmH*RnH; Res2=0; Res1=temp1+temp2; if (Res1<temp1) Res2+=0x00010000; temp1=(Res1<<16)&0xFFFF0000; Res0=temp0+temp1; if (Res0<temp0) Res2++; Res2=Res2+((Res1>>16)&0x0000FFFF)+temp3; if (fnLmL<0) { Res2= Res2; if (Res0==0) Res2++; else Res0=( Res0)+1; MACH=Res2; MACL=Res0; PC+=2; Example ;Before execution R0 = H’FFFFFFFE, R1 = H’00005555 DMULS.L R0,R1 ;After execution MACH = H’FFFFFFFF, MACL = H’FFFF5556 ;Get operation result (upper)
10.21 DMULU.L Double-length MULtiply as Unsigned Arithmetic Instruction Unsigned Double-Length Multiplication Execution Format Summary of Operation Instruction Code States T Bit DMULU.L Rm,Rn Unsigned, 0011nnnnmmmm0101 2–5 — Rn × Rm → MACH, MACL Description This instruction performs 32-bit multiplication of the contents of general register Rn by the contents of Rm, and stores the 64-bit result in the MACH and MACL registers.
Page 253
Res0=temp0+temp1; if (Res0<temp0) Res2++; Res2=Res2+((Res1>>16)&0x0000FFFF)+temp3; MACH=Res2; MACL=Res0; PC+=2; Example ;Before execution R0 = H’FFFFFFFE, R1 = H’00005555 DMULU.L R0,R1 ;After execution MACH = H’00005554, MACL = H’FFFF5556 ;Get operation result (upper) MACH,R0 ;Get operation result (lower) MACL,R1 Rev. 2.0, 03/99, page 239 of 396...
Page 254
10.22 Decrement and Test Arithmetic Instruction Decrement and Test Execution Format Summary of Operation Instruction Code States T Bit Rn – 1 → Rn; DT Rn 0100nnnn00010000 1 Test if Rn = 0, 1 → T result if Rn ≠ 0, 0 → T Description This instruction decrements the contents of general register Rn by 1 and compares the result with zero.
10.23 EXTS EXTend as Signed Arithmetic Instruction Sign Extension Execution Format Summary of Operation Instruction Code States T Bit EXTS.B Rm,Rn Rm sign-extended from 0110nnnnmmmm1110 1 — byte → Rn EXTS.W Rm,Rn Rm sign-extended from 0110nnnnmmmm1111 1 — word → Rn Description This instruction sign-extends the contents of general register Rm and stores the result in Rn.
10.24 EXTU EXTend as Unsigned Arithmetic Instruction Zero Extension Execution Format Summary of Operation Instruction Code States T Bit EXTU.B Rm,Rn Rm zero-extended from 0110nnnnmmmm1100 1 — byte → Rn EXTU.W Rm,Rn Rm zero-extended from 0110nnnnmmmm1101 1 — word → Rn Description This instruction zero-extends the contents of general register Rm and stores the result in Rn.
10.25 FABS Floating-point ABSolute value Floating-Point Instruction Floating-Point Absolute Value Execution Format Summary of Operation Instruction Code States T Bit |FRn| → FRn FABS FRn 1111nnnn01011101 1 — |DRn| → DRn FABS DRn 1111nnn001011101 1 — Description This instruction clears the most significant bit of the contents of floating-point register FRn/DRn to 0, and stores the result in FRn/DRn.
10.26 FADD Floating-point ADD Floating-Point Instruction Floating-Point Addition Execution Format Summary of Operation Instruction Code States T Bit FADD FRm,FRn FRn+FRm → FRn 1111nnnnmmmm0000 1 — FADD DRm,DRn DRn+DRm → DRn 1111nnn0mmm00000 6 — Description When FPSCR.PR = 0: Arithmetically adds the two single-precision floating-point numbers in FRn and FRm, and stores the result in FRn.
Page 260
case PZERO: switch (data_type_of(n)){ case NZERO: zero(n,0); break; default: break; break; case NZERO: break; case PINF: switch (data_type_of(n)){ case NINF: invalid(n); break; default: inf(n,0); break; break; case NINF: switch (data_type_of(n)){ case PINF: invalid(n); break; default: inf(n,1); break; break; FADD Special Cases FRm,DRm FRn,DRn NORM...
10.28 FCNVDS Floating-point CoNVert Double to Single precision Floating-Point Instruction Double-Precision to Single-Precision Conversion Execution Format Summary of Operation Instruction Code States T Bit — — — — — (float)DRm → FPUL FCNVDS DRm,FPUL 1111mmm010111101 2 — Description When FPSCR.PR = 1: This instruction converts the double-precision floating-point number in DRm to a single-precision floating-point number, and stores the result in FPUL.
Page 265
qNaN *FPUL = 0x7fbfffff; break; sNaN set_V(); if((FPSCR & ENABLE_V) == 0) *FPUL = 0x7fbfffff; else fpu_exception_trap(); break; void normal_fcnvds(int m, float *FPUL) int sign; float abs; union { float f; int l; dstf,tmpf; union { double d; int l[2]; dstd;...
10.29 FCNVSD Floating-point CoNVert Single to Double precision Floating-Point Instruction Single-Precision to Double-Precision Conversion Execution Format Summary of Operation Instruction Code States T Bit — — — — — (double) FPUL → DRn FCNVSD FPUL, DRn 1111nnn010101101 2 — Description When FPSCR.PR = 1: This instruction converts the single-precision floating-point number in FPUL to a double-precision floating-point number, and stores the result in DRn.
10.30 FDIV Floating-point DIVide Floating-Point Instruction Floating-Point Division Execution Format Summary of Operation Instruction Code States T Bit FRn/FRm → FRn FDIV FRm,FRn 1111nnnnmmmm0011 10 — DRn/DRm → DRn FDIV DRm,DRn 1111nnn0mmm00011 23 — Description When FPSCR.PR = 0: Arithmetically divides the single-precision floating-point number in FRn by the single-precision floating-point number in FRm, and stores the result in FRn.
Page 269
case PZERO: switch (data_type_of(n)){ case PZERO: case NZERO: invalid(n);break; case PINF: case NINF: break; default: dz(n,sign_of(m)^sign_of(n));break; break; case NZERO: switch (data_type_of(n)){ case PZERO: case NZERO: invalid(n); break; case PINF: inf(n,1); break; case NINF: inf(n,0); break; default: dz(FR[n],sign_of(m)^sign_of(n)); break; break; case DENORM: set_E();...
Page 270
tmpx; if(FPSCR_PR == 0) { tmpf.f = FR[n]; /* save destination value */ dstf.f /= FR[m]; /* round toward nearest or even */ tmpd.d = dstf.f; /* convert single to double */ tmpd.d *= FR[m]; if(tmpf.f != tmpd.d) set_I(); if((tmpf.f < tmpd.d) && (SPSCR_RM == 1)) dstf.l -= 1;...
Page 271
Possible Exceptions: • FPU error • Invalid operation • Divide by zero • Overflow • Underflow • Inexact Rev. 2.0, 03/99, page 257 of 396...
Page 273
When FPSCR.enable.O/U/I is set, an FPU exception trap is generated regardless of whether or not an exception has occurred. When an exception occurs, correct exception information is reflected in FPSCR.cause and FPSCR.flag, and FRn or DRn is not updated. Appropriate processing should therefore be performed by software.
10.34 FLDS Floating-point LoaD to System register Floating-Point Instruction Transfer to System Register Execution Format Summary of Operation Instruction Code States T Bit FRm → FPUL FLDS FRm,FPUL 1111mmmm00011101 1 — Description This instruction loads the contents of floating-point register FRm into system register FPUL. Operation void FLDS(int m, float *FPUL) *FPUL = FR[m];...
10.35 FLOAT Floating-point convert from integer Floating-Point Instruction Integer to Floating-Point Conversion Execution Format Summary of Operation Instruction Code States T Bit (float)FPUL → FRn FLOAT FPUL,FRn 1111nnnn00101101 1 — (double)FPUL → DRn FLOAT FPUL,DRn 1111nnn000101101 2 — Description When FPSCR.PR = 0: Taking the contents of FPUL as a 32-bit integer, converts this integer to a single-precision floating-point number and stores the result in FRn.
Page 278
Operation void FLOAT(int n, float *FPUL) union { double d; int l[2]; tmp; pc += 2; clear_cause(); if(FPSCR.PR==0){ FR[n] = *FPUL; /* convert from integer to float */ tmp.d = *FPUL; if(tmp.l[1] & 0x1fffffff) inexact(); }else { DR[n>>1] = *FPUL; /* convert from integer to double */ Possible Exceptions: Inexact: Not generated when FPSCR.PR = 1.
10.36 FMAC Floating-point Multiply and ACcumulate Floating-Point Instruction Floating-Point Multiply and Accumulate Execution PR Format Summary of Operation Instruction Code States T Bit FMAC FR0,FRm,FRn FR0*FRm+FRn → FRn 1111nnnnmmmm1110 1 — — — — — — Description When FPSCR.PR = 0: This instruction arithmetically multiplies the two single-precision floating- point numbers in FR0 and FRm, arithmetically adds the contents of FRn, and stores the result in FRn.
Page 280
case qNaN: qnan(n); break; case PZERO: case NZERO: zero(n,sign_of(0)^ sign_of(m)^sign_of(n)); break; default: break; case PINF: case NINF: switch (data_type_of(n)){ case DENORM: set_E(); break; case qNaN: qnan(n); break; case PINF: case NINF: if(sign_of(0)^ sign_of(m)^sign_of(n)) invalid(n); else inf(n,sign_of(0)^ sign_of(m)); break; default: inf(n,sign_of(0)^ sign_of(m)); break; case NORM: switch (data_type_of(n)){ case DENORM: set_E();...
Page 281
case PINF : case NINF : switch (data_type_of(m)){ case PZERO: case NZERO:invalid(n); break; default: switch (data_type_of(n)){ case DENORM: set_E(); break; case qNaN: qnan(n); break; default: inf(n,sign_of(0)^sign_of(m)^sign_of(n));break break; break; void normal_fmac(int m,n) union { int double x; int l[4]; dstx,tmpx; float dstf,srcf; if((data_type_of(n) == PZERO)|| (data_type_of(n) == NZERO)) srcf = 0.0;...
10.37 FMOV Floating-point MOVe Floating-Point Instruction Floating-Point Transfer Summary of Execution SZ Format Operation Instruction Code States T Bit FRm → FRn 1. FMOV FRm,FRn 1111nnnnmmmm1100 1 — DRm → DRn 2. FMOV DRm,DRn 1111nnn0mmm01100 1 — FRm → (Rn) 3.
Page 286
12. This instruction transfers contents of memory at address indicated by (R0 + Rm) to DRn. 13. This instruction transfers FRm contents to memory at address indicated by (R0 + Rn). 14. This instruction transfers DRm contents to memory at address indicated by (R0 + Rn). Operation void FMOV(int m,n) /* FMOV FRm,FRn */...
10.39 FMUL Floating-point MULtiply Floating-Point Instruction Floating-Point Multiplication Execution Format Summary of Operation Instruction Code States T Bit FRn*FRm → FRn FMUL FRm,FRn 1111nnnnmmmm0010 1 — DRn*DRm → DRn FMUL DRm,DRn 1111nnn0mmm00010 6 — Description When FPSCR.PR = 0: Arithmetically multiplies the two single-precision floating-point numbers in FRn and FRm, and stores the result in FRn.
Page 293
break; case PZERO: case NZERO: switch (data_type_of(n)){ case PINF: case NINF: invalid(n); break; default: zero(n,sign_of(m)^sign_of(n));break; break; case PINF : case NINF : switch (data_type_of(n)){ case PZERO: case NZERO: invalid(n); break; default: inf(n,sign_of(m)^sign_of(n));break break; FMUL Special Cases FRm,DRm FRn,DRn NORM –0 +INF –INF DENORM...
10.40 FNEG Floating-point NEGate value Floating-Point Instruction Floating-Point Sign Inversion Execution Format Summary of Operation Instruction Code States T Bit -FRn → FRn FNEG FRn 1111nnnn01001101 1 — -DRn → DRn FNEG DRn 1111nnn001001101 1 — Description This instruction inverts the most significant bit (sign bit) of the contents of floating-point register FRn/DRn, and stores the result in FRn/DRn.
10.41 FRCHG FR-bit CHanGe Floating-Point Instruction FR Bit Inversion Execution Format Summary of Operation Instruction Code States T Bit FRCHG FRSCR.FR=~FRSCR.FR 1111101111111101 1 — — — — — — Description This instruction inverts the FR bit in floating-point register FPSCR. When the FR bit in FPSCR is changed, FR0 to FR15 in FPPR0 to FPPR31 become XR0 to XR15, and XR0 to XR15 become FR0 to FR15.
10.42 FSCHG Sz-bit CHanGe Floating-Point Instruction SZ Bit Inversion Execution Format Summary of Operation Instruction Code States T Bit FSCHG FRSCR.SZ=~FRSCR.SZ 1111001111111101 1 — — — — — — Description This instruction inverts the SZ bit in floating-point register FPSCR. Changing the SZ bit in FPSCR switches FMOV instruction data transfer between one single-precision data unit and a data pair.
10.43 FSQRT Floating-point SQuare RooT Floating-Point Instruction Floating-Point Square Root Execution Format Summary of Operation Instruction Code States T Bit √FRn → FRn FSQRT FRn 1111nnnn01101101 9 — √DRn → DRn FSQRT DRn 1111nnnn01101101 22 — Description When FPSCR.PR = 0: Finds the arithmetical square root of the single-precision floating-point number in FRn, and stores the result in FRn.
Page 298
union { float f; int l; dstf,tmpf; union { double d; int l[2]; dstd,tmpd; union { int double x; int l[4]; tmpx; if(FPSCR_PR == 0) { tmpf.f = FR[n]; /* save destination value */ dstf.f = sqrt(FR[n]); /* round toward nearest or even */ tmpd.d = dstf.f;...
Page 299
FSQRT Special Cases +NORM –NORM –0 +INF –INF qNaN sNaN FSQRT(FRn) SQRT Invalid –0 +INF Invalid qNaN Invalid Note: When DN = 1, the value of a denormalized number is treated as 0. Possible Exceptions: • FPU error • Invalid operation •...
10.44 FSTS Floating-point STore System register Floating-Point Instruction Transfer from System Register Execution Format Summary of Operation Instruction Code States T Bit FPUL → FRn FSTS FPUL,FRn 1111nnnn00001101 1 — Description This instruction transfers the contents of system register FPUL to floating-point register FRn. Operation void FSTS(int n, float *FPUL) FR[n] = *FPUL;...
10.45 FSUB Floating-point SUBtract Floating-Point Instruction Floating-Point Subtraction Execution Format Summary of Operation Instruction Code States T Bit FRn-FRm → FRn FSUB FRm,FRn 1111nnnnmmmm0001 1 — FSUB DRm,DRn DRn-DRm → DRn 1111nnn0mmm00001 6 Description When FPSCR.PR = 0: Arithmetically subtracts the single-precision floating-point number in FRm from the single-precision floating-point number in FRn, and stores the result in FRn.
Page 302
break; case PZERO: break; case NZERO: switch (data_type_of(n)){ case NZERO: zero(n,0); break; default: break; break; case PINF: switch (data_type_of(n)){ case PINF: invalid(n); break; default: inf(n,1); break; break; case NINF: switch (data_type_of(n)){ case NINF: invalid(n); break; default: inf(n,0); break; break; FSUB Special Cases FRm,DRm FRn,DRn NORM...
10.46 FTRC Floating-point TRuncate and Convert to integer Floating-Point Instruction Conversion to Integer Execution Format Summary of Operation Instruction Code States T Bit (long)FRm → FPUL FTRC FRm,FPUL 1111mmmm00111101 1 — (long)DRm → FPUL FTRC DRm,FPUL 1111mmm000111101 2 — Description When FPSCR.PR = 0: Converts the single-precision floating-point number in FRm to a 32-bit integer, and stores the result in FPUL.
Page 304
NORM: *FPUL = DR[m>>1]; break; PINF: ftrc_invalid(0); break; NINF: ftrc_invalid(1); break; int ftrc_signle_type_of(int m) if(sign_of(m) == 0){ if(FR_HEX[m] > 0x7f800000) return(NINF); /* NaN */ else if(FR_HEX[m] > P_INT_SINGLE_RANGE) return(PINF); /* out of range,+INF */ else return(NORM); /* +0,+NORM }else { if((FR_HEX[m] &...
Page 305
if((FPSCR & ENABLE_V) == 0){ if(sign == 0) *FPUL = 0x7fffffff; else *FPUL = 0x80000000; else fpu_exception_trap(); FTRC Special Cases Positive Negative Out of Out of FRn,DRn NORM –0 Range Range +INF –INF qNaN sNaN FTRC Invalid Invalid Invalid Invalid Invalid Invalid (FRn,DRn)
10.47 FTRV Floating-point TRansform Vector Floating-Point Instruction Vector Transformation Execution Format Summary of Operation Instruction Code States T Bit FTRV XMTRX,FVn XMTRX*FVn → FVn 1111nn0111111101 4 — — — — — — Description When FPSCR.PR = 0: This instruction takes the contents of floating-point registers XF0 to XF15 indicated by XMTRX as a 4-row ×...
Page 307
5. If the input values do not include an sNaN, qNaN, or infinity, processing is performed in the normal way. When FPSCR.enable.V/O/U/I is set, an FPU exception trap is generated regardless of whether or not an exception has occurred. When an exception occurs, correct exception information is reflected in FPSCR.cause and FPSCR.flag, and FRn or DRn is not updated.
Page 308
Possible Exceptions: • Invalid operation • Overflow • Underflow • Inexact Rev. 2.0, 03/99, page 294 of 396...
10.48 JuMP Branch Instruction Unconditional Branch Delayed Branch Instruction Execution Format Summary of Operation Instruction Code States T Bit Rn → PC JMP @Rn 0100nnnn00101011 2 — Description Unconditionally makes a delayed branch to the address specified by Rn. Notes As this is a delayed branch instruction, the instruction following this instruction is executed before the branch destination instruction.
10.49 Jump to SubRoutine Branch Instruction Branch to Subroutine Procedure Delayed Branch Instruction Execution Format Summary of Operation Instruction Code States T Bit PC+4 → PR, Rn → PC JSR @Rn 0100nnnn00001011 2 — Description This instruction makes a delayed branch to the subroutine procedure at the specified address after execution of the following instruction.
Page 311
Example ;R0 = TRGET address MOV.L JSR_TABLE,R0 ;Branch to TRGET. ;XOR executed before branch. R1,R1 ;← Procedure return destination (PR contents) R0,R1 ..align ;Jump table JSR_TABLE: . data.l TRGET ;← Entry to procedure TRGET: R2,R3 ;Return to above ADD instruction. ;MOV executed before RTS.
10.50 LoaD to Control register System Control Instruction Load to Control Register (Privileged Instruction) Execution Format Summary of Operation Instruction Code States T Bit Rm → SR Rm, SR 0100mmmm00001110 Rm → GBR Rm, GBR — 0100mmmm00011110 Rm → VBR Rm, VBR —...
Page 313
Notes With the exception of LDC Rm,GBR and LDC.L @Rm+,GBR, the LDC/LDC.L instructions are privileged instructions and can only be used in privileged mode. Use in user mode will cause an illegal instruction exception. However, LDC Rm,GBR and LDC.L @Rm+,GBR can also be used in user mode.
10.51 LoaD to FPU System register System Control Instruction Load to FPU System Register Execution Format Summary of Operation Instruction Code States T Bit Rm → FPUL Rm,FPUL 0100mmmm01011010 1 — (Rm) → FPUL, Rm+4 → Rm LDS.L @Rm+,FPUL 0100mmmm01010110 1 —...
Page 317
R[m]+=4; PC+=2; Possible Exceptions: • Data TLB miss exception • Data access protection exception • Address error Rev. 2.0, 03/99, page 303 of 396...
10.52 LoaD to System register System Control Instruction Load to System Register Execution Format Summary of Operation Instruction Code States T Bit Rm → MACH Rm,MACH 0100mmmm00001010 1 — Rm → MACL Rm,MACL 0100mmmm00011010 1 — Rm,PR Rm→ PR 0100mmmm00101010 2 —...
Page 319
MACH=Read_Long(R[m]); R[m]+=4; PC+=2; LDSMMACL(int m) /* LDS.L @Rm+,MACL */ MACL=Read_Long(R[m]); R[m]+=4; PC+=2; LDSMPR(int m) /* LDS.L @Rm+,PR */ PR=Read_Long(R[m]); R[m]+=4; PC+=2; Example ; Before execution R0 = H’12345678, PR = H’00000000 R0,PR ; After execution PR = H’12345678 ; Before execution R15 = H’10000000 LDS.L @R15+,MACL...
10.53 LDTLB LoaD PTEH/PTEL/PTEA to TLB System Control Instruction Load to TLB (Privileged Instruction) Execution Format Summary of Operation Instruction Code States T Bit PTEH/PTEL/PTEA → TLB LDTLB 0000000000111000 1 — Description This instruction loads the contents of the PTEH/PTEL/PTEA registers into the TLB (translation lookaside buffer) specified by MMUCR.URC (random counter field in the MMC control register).
10.54 MAC.L Multiply and ACcumulate Long Arithmetic Instruction Double-Precision Multiply-and-Accumulate Operation Execution Format Summary of Operation Instruction Code States T Bit MAC.L @Rm+,@Rn+ Signed, 0000nnnnmmmm1111 2–5 — (Rn) × (Rm) + MAC → MAC Rn + 4 → Rn, Rm + 4 → Rm Description This instruction performs signed multiplication of the 32-bit operands whose addresses are the contents of general registers Rm and Rn, adds the 64-bit result to the MAC register contents, and...
Page 323
if (tempn<0) tempn=0-tempn; if (tempm<0) tempm=0-tempm; temp1=(unsigned long)tempn; temp2=(unsigned long)tempm; RnL=temp1&0x0000FFFF; RnH=(temp1>>16)&0x0000FFFF; RmL=temp2&0x0000FFFF; RmH=(temp2>>16)&0x0000FFFF; temp0=RmL*RnL; temp1=RmH*RnL; temp2=RmL*RnH; temp3=RmH*RnH; Res2=0; Res1=temp1+temp2; if (Res1<temp1) Res2+=0x00010000; temp1=(Res1<<16)&0xFFFF0000; Res0=temp0+temp1; if (Res0<temp0) Res2++; Res2=Res2+((Res1>>16)&0x0000FFFF)+temp3; if(fnLmL<0){ Res2= Res2; if (Res0==0) Res2++; else Res0=( Res0)+1; if(S==1){ Res0=MACL+Res0; if (MACL>Res0) Res2++;...
10.55 MAC.W Multiply and ACcumulate Word Arithmetic Instruction Single-Precision Multiply-and-Accumulate Operation Execution Format Summary of Operation Instruction Code States T Bit MAC.W @Rm+,@Rn+ Signed, 0100nnnnmmmm1111 2–5 — (Rn) × (Rm) + MAC →MAC @Rm+,@Rn+ Rn + 2 → Rn, Rm + 2 → Rm Description This instruction performs signed multiplication of the 16-bit operands whose addresses are the contents of general registers Rm and Rn, adds the 32-bit result to the MAC register contents, and...
Page 327
Operation MACW(long m, long n) /* MAC.W @Rm+,@Rn+ */ long tempm,tempn,dest,src,ans; unsigned long templ; tempn=(long)Read_Word(R[n]); R[n]+=2; tempm=(long)Read_Word(R[m]); R[m]+=2; templ=MACL; tempm=((long)(short)tempn*(long)(short)tempm); if ((long)MACL>=0) dest=0; else dest=1; if ((long)tempm>=0) { src=0; tempn=0; else { src=1; tempn=0xFFFFFFFF; src+=dest; MACL+=tempm; if ((long)MACL>=0) ans=0; else ans=1; ans+=dest;...
10.56 MOVe data Data Transfer Instruction Data Transfer Execution Format Summary of Operation Instruction Code States T Bit Rm → Rn Rm,Rn 0110nnnnmmmm0011 1 — Rm → (Rn) MOV.B Rm,@Rn 0010nnnnmmmm0000 1 — Rm → (Rn) MOV.W Rm,@Rn 0010nnnnmmmm0001 1 —...
Page 330
Operation MOV(long m, long n) /* MOV Rm,Rn */ R[n]=R[m]; PC+=2; MOVBS(long m, long n) /* MOV.B Rm,@Rn */ Write_Byte(R[n],R[m]); PC+=2; MOVWS(long m, long n) /* MOV.W Rm,@Rn */ Write_Word(R[n],R[m]); PC+=2; MOVLS(long m, long n) /* MOV.L Rm,@Rn */ Write_Long(R[n],R[m]); PC+=2;...
Page 331
else R[n]|=0xFFFF0000; PC+=2; MOVLL(long m, long n) /* MOV.L @Rm,Rn */ R[n]=Read_Long(R[m]); PC+=2; MOVBM(long m, long n) /* MOV.B Rm,@-Rn */ Write_Byte(R[n]-1,R[m]); R[n]-=1; PC+=2; MOVWM(long m, long n) /* MOV.W Rm,@-Rn */ Write_Word(R[n]-2,R[m]); R[n]-=2; PC+=2; MOVLM(long m, long n) /* MOV.L Rm,@-Rn */ Write_Long(R[n]-4,R[m]);...
Page 332
PC+=2; MOVWP(long m, long n) /* MOV.W @Rm+,Rn */ R[n]=(long)Read_Word(R[m]); if ((R[n]&0x8000)==0) R[n]&=0x0000FFFF; else R[n]|=0xFFFF0000; if (n!=m) R[m]+=2; PC+=2; MOVLP(long m, long n) /* MOV.L @Rm+,Rn */ R[n]=Read_Long(R[m]); if (n!=m) R[m]+=4; PC+=2; MOVBS0(long m, long n) /* MOV.B Rm,@(R0,Rn) */ Write_Byte(R[n]+R[0],R[m]);...
Page 333
R[n]=(long)Read_Byte(R[m]+R[0]); if ((R[n]&0x80)==0) R[n]&=0x000000FF; else R[n]|=0xFFFFFF00; PC+=2; MOVWL0(long m, long n) /* MOV.W @(R0,Rm),Rn */ R[n]=(long)Read_Word(R[m]+R[0]); if ((R[n]&0x8000)==0) R[n]&=0x0000FFFF; else R[n]|=0xFFFF0000; PC+=2; MOVLL0(long m, long n) /* MOV.L @(R0,Rm),Rn */ R[n]=Read_Long(R[m]+R[0]); PC+=2; Example ;Before execution R0 = H’FFFFFFFF, R1 = H’00000000 R0,R1 ;After execution R1 = H’FFFFFFFF...
10.57 MOVe constant value Data Transfer Instruction Immediate Data Transfer Execution Format Summary of Operation Instruction Code States T Bit #imm,Rn imm sign extension Rn 1110nnnniiiiiiii 1 — MOV.W @(disp,PC),Rn (disp×2+PC+4) → sign 1001nnnndddddddd 1 — extension Rn MOV.L @(disp,PC),Rn (disp×4+PC+4) → Rn 1101nnnndddddddd 1 —...
Page 335
Operation MOVI(int i, int n) /* MOV #imm,Rn */ if ((i&0x80)==0) R[n]=(0x000000FF & i); else R[n]=(0xFFFFFF00 | i); PC+=2; MOVWI(d, n) /* MOV.W @(disp,PC),Rn */ unsigned int disp; disp=(unsigned int)(0x000000FF & d); R[n]=(int)Read_Word(PC+4+(disp<<1)); if ((R[n]&0x8000)==0) R[n]&=0x0000FFFF; else R[n]|=0xFFFF0000; PC+=2; MOVLI(int d, int n)/* MOV.L @(disp,PC),Rn */ unsigned int disp;...
10.58 MOVe global data Data Transfer Instruction Global Data Transfer Execution Format Summary of Operation Instruction Code States T Bit (disp+GBR) → sign MOV.B @(disp,GBR),R0 11000100dddddddd 1 — extension R0 (disp×2+GBR) → sign MOV.W @(disp,GBR), R0 11000101dddddddd 1 — extension R0 (disp×4+GBR) →...
10.59 MOVe structure data Data Transfer Instruction Structure Data Transfer Execution Format Summary of Operation Instruction Code States T Bit R0 → (disp+Rn) MOV.B R0,@(disp,Rn) 10000000nnnndddd 1 — R0 → (disp×2+Rn) MOV.W R0,@(disp,Rn) 10000001nnnndddd 1 — Rm → (disp×4+Rn) MOV.L Rm,@(disp,Rn) 0001nnnnmmmmdddd 1 —...
Page 341
Operation MOVBS4(long d, long n /* MOV.B R0,@(disp,Rn) */ long disp; disp=(0x0000000F & (long)d); Write_Byte(R[n]+disp,R[0]); PC+=2; MOVWS4(long d, long n) /* MOV.W R0,@(disp,Rn) */ long disp; disp=(0x0000000F & (long)d); Write_Word(R[n]+(disp<<1),R[0]); PC+=2; MOVLS4(long m, long d, long n) /* MOV.L Rm,@(disp,Rn) */ long disp;...
Page 342
MOVWL4(long m, long d) /* MOV.W @(disp,Rm),R0 */ long disp; disp=(0x0000000F & (long)d); R[0]=Read_Word(R[m]+(disp<<1)); if ((R[0]&0x8000)==0) R[0]&=0x0000FFFF; else R[0]|=0xFFFF0000; PC+=2; MOVLL4(long m, long d, long n) /* MOV.L @(disp,Rm),Rn */ long disp; disp=(0x0000000F & (long)d); R[n]=Read_Long(R[m]+(disp<<2)); PC+=2; Example ;Before execution (R0+8) = H’12345670 MOV.L @(2,R0),R1 ;After execution...
10.60 MOVA MOVe effective Address Data Transfer Instruction Effective Address Transfer Execution Format Summary of Operation Instruction Code States T Bit MOVA @(disp,PC),R0 disp×4+PC+4 → R0 11000111dddddddd 1 — Description This instruction stores the source operand effective address in general register R0. The 8-bit displacement is multiplied by four after zero-extension.
10.61 MOVCA.L MOVe with Cache block Allocation Data Transfer Instruction Cache Block Allocation Execution Format Summary of Operation Instruction Code States T Bit R0 → (Rn) MOVCA.L R0,@Rn 0000nnnn11000011 1 — Description This instruction stores the contents of general register R0 in the memory location indicated by effective address Rn.
10.62 MOVT MOVe T bit Data Transfer Instruction T Bit Transfer Execution Format Summary of Operation Instruction Code States T Bit T → Rn MOVT Rn 0000nnnn00101001 1 — Description This instruction stores the T bit in general register Rn. When T = 1, Rn = 1; when T = 0, Rn = 0. Operation MOVT(long n) /* MOVT Rn */...
10.63 MUL.L MULtiply Long Arithmetic Instruction Double-Precision Multiplication Execution Format Summary of Operation Instruction Code States T Bit Rn×Rm → MACL MUL.L Rm,Rn 0000nnnnmmmm0111 2–5 — Description This instruction performs 32-bit multiplication of the contents of general registers Rn and Rm, and stores the lower 32 bits of the result in the MACL register.
10.64 MULS.W MULtiply as Signed Word Arithmetic Instruction Signed Multiplication Execution Format Summary of Operation Instruction Code States T Bit Signed, Rn × Rm → MACL MULS.W Rm,Rn 0010nnnnmmmm1111 2–5 — MULS Rm,Rn Description This instruction performs 16-bit multiplication of the contents of general registers Rn and Rm, and stores the 32-bit result in the MACL register.
10.65 MULU.W MULtiply as Unsigned Word Arithmetic Instruction Unsigned Multiplication Execution Format Summary of Operation Instruction Code States T Bit Unsigned, Rn × Rm → MACL MULU.W Rm,Rn 0010nnnnmmmm1110 2–5 — MULU Rm,Rn Description This instruction performs 16-bit multiplication of the contents of general registers Rn and Rm, and stores the 32-bit result in the MACL register.
10.66 NEGate Arithmetic Instruction Sign Inversion Execution Format Summary of Operation Instruction Code States T Bit 0-Rm → Rn NEG Rm,Rn 0110nnnnmmmm1011 1 — Description This instruction finds the two’s complement of the contents of general register Rm and stores the result in Rn.
10.67 NEGC NEGate with Carry Arithmetic Instruction Sign Inversion with Borrow Execution Format Summary of Operation Instruction Code States T Bit 0 – Rm – T → Rn, NEGC Rm,Rn 0110nnnnmmmm1010 1 Borrow borrow → T Description This instruction subtracts the contents of general register and the T bit from 0 and stores the result in Rn.
10.68 No OPeration System Control Instruction No Operation Execution States Format Summary of Operation Instruction Code T Bit No operation 0000000000001001 1 — Description This instruction simply increments the program counter (PC), advancing the processing flow to execution of the next instruction. Operation NOP( ) /* NOP */ PC+=2;...
10.69 NOT-logical complement Logical Instruction Bit Inversion Execution Format Summary of Operation Instruction Code States T Bit ∼Rm → Rn NOT Rm,Rn 0110nnnnmmmm0111 1 — Description This instruction finds the one’s complement of the contents of general register Rm and stores the result in Rn.
10.70 OCBI Operand Cache Block Invalidate Data Transfer Instruction Cache Block Invalidation Execution Format Summary of Operation Instruction Code States T Bit OCBI @Rn Operand cache block 0000nnnn10010011 1 — invalidation Description This instruction accesses data using the contents indicated by effective address Rn. In the case of a hit in the cache, the corresponding cache block is invalidated (the V bit is cleared to 0).
10.71 OCBP Operand Cache Block Purge Data Transfer Instruction Cache Block Purge Execution States Format Summary of Operation Instruction Code T Bit OCBP @Rn Operand cache block purge 0000nnnn10100011 1 — Description This instruction accesses data using the contents indicated by effective address Rn. If the cache is hit and there is unwritten information (U bit = 1), the corresponding cache block is written back to external memory and that block is invalidated (the V bit is cleared to 0).
10.72 OCBWB Operand Cache Block Write Back Data Transfer Instruction Cache Block Write-Back Execution Format Summary of Operation Instruction Code States T Bit OCBWB @Rn Operand cache block write- 0000nnnn10110011 1 — back Description This instruction accesses data using the contents indicated by effective address Rn. If the cache is hit and there is unwritten information (U bit = 1), the corresponding cache block is written back to external memory and that block is cleaned (the U bit is cleared to 0).
Page 356
10.73 OR logical Logical Instruction Logical OR Execution Format Summary of Operation Instruction Code States T Bit Rn | Rm → Rn Rm,Rn 0010nnnnmmmm1011 1 — R0 | imm → R0 #imm,R0 11001011iiiiiiii 1 — (R0+GBR) | imm → OR.B #imm,@(R0,GBR) 11001111iiiiiiii 4 —...
Page 357
Operation OR(long m, long n) /* OR Rm,Rn */ R[n]|=R[m]; PC+=2; ORI(long i) /* OR #imm,R0 */ R[0]|=(0x000000FF & (long)i); PC+=2; ORM(long i) /* OR.B #imm,@(R0,GBR) */ long temp; temp=(long)Read_Byte(GBR+R[0]); temp|=(0x000000FF & (long)i); Write_Byte(GBR+R[0],temp); PC+=2; Example ;Before execution R0 = H’AAAA5555, R1 = H’55550000 R0,R1 ;After execution R1 = H’FFFF5555...
10.74 PREF PREFetch data to cache Data Transfer Instruction Prefetch to Data Cache Execution Format Summary of Operation Instruction Code States T Bit PREF @Rn Prefetch cache block — 0000nnnn10000011 Description This instruction reads a 32-byte data block starting at a 32-byte boundary into the operand cache. The lower 5 bits of the address specified by Rn are masked to zero.
10.75 ROTCL ROTate with Carry Left Shift Instruction One-Bit Left Rotation through T Bit Execution Format Summary of Operation Instruction Code States T Bit T ← Rn ← T ROTCL Rn 0100nnnn00100100 1 Description This instruction rotates the contents of general register Rn one bit to the left through the T bit, and stores the result in Rn.
10.76 ROTCR ROTate with Carry Right Shift Instruction One-Bit Right Rotation through T Bit Execution Format Summary of Operation Instruction Code States T Bit T → Rn → T ROTCR Rn 0100nnnn00100101 1 Description This instruction rotates the contents of general register Rn one bit to the right through the T bit, and stores the result in Rn.
10.77 ROTL ROTate Left Shift Instruction One-Bit Left Rotation Execution Format Summary of Operation Instruction Code States T Bit T ← Rn ← MSB ROTL Rn 0100nnnn00000100 1 Description This instruction rotates the contents of general register Rn one bit to the left, and stores the result in Rn.
10.78 ROTR ROTate Right Shift Instruction One-Bit Right Rotation Execution Format Summary of Operation Instruction Code States T Bit LSB → Rn → T ROTR 0100nnnn00000101 1 Description This instruction rotates the contents of general register Rn one bit to the right, and stores the result in Rn.
10.79 ReTurn from Exception System Control Instruction Return from Exception Handling (Privileged Instruction) Delayed Branch Instruction Execution Format Summary of Operation Instruction Code States T Bit SSR → SR, SPC→ PC 0000000000101011 5 — Description This instruction returns from an exception or interrupt handling routine by restoring the PC and SR values from SPC and SSR.
Page 364
Operation RTE( ) /* RTE */ unsigned int temp; temp=PC; SR=SSR; PC=SPC; Delay_Slot(temp+2); Example ;Return to original routine. ;Executed before branch. #8,R14 Note: In a delayed branch, the actual branch operation occurs after execution of the slot instruction, but instruction execution (register updating, etc.) is in fact performed in delayed branch instruction →...
10.80 ReTurn from Subroutine Branch Instruction Return from Subroutine Procedure Delayed Branch Instruction Execution Format Summary of Operation Instruction Code States T Bit PR → PC 0000000000001011 2 — Description This instruction returns from a subroutine procedure by restoring the PC from PR. Processing continues from the address indicated by the restored PC value.
Page 366
Example ;R3 = TRGET address MOV.L TABLE,R3 ; Branch to TRGET. ;NOP executed before branch. ;← Subroutine procedure return destination (PR contents) R0,R1 ..;Jump table TABLE: .data.l TRGET ..;← Entry to procedure TRGET: R1,R0 ;PR contents → PC ;MOV executed before branch.
10.81 SETS SET S bit System Control Instruction S Bit Setting Execution Format Summary of Operation Instruction Code States T Bit 1 → S SETS 0000000001011000 1 — Description This instruction sets the S bit to 1. Operation SETS( ) /* SETS */ S=1;...
10.82 SETT SET T bit System Control Instruction T Bit Setting Execution Format Summary of Operation Instruction Code States T Bit 1 → T SETT 0000000000011000 1 Description This instruction sets the T bit to 1. Operation SETT( ) /* SETT */ T=1;...
10.84 SHAL SHift Arithmetic Left Shift Instruction One-Bit Left Arithmetic Shift Execution Format Summary of Operation Instruction Code States T Bit T ← Rn ← 0 SHAL Rn 0100nnnn00100000 1 Description This instruction arithmetically shifts the contents of general register Rn one bit to the left, and stores the result in Rn.
10.85 SHAR SHift Arithmetic Right Shift Instruction One-Bit Right Arithmetic Shift Execution Format Summary of Operation Instruction Code States T Bit MSB → Rn → T SHAR 0100nnnn00100001 1 Description This instruction arithmetically shifts the contents of general register Rn one bit to the right, and stores the result in Rn.
10.87 SHLL SHift Logical Left Shift Instruction One-Bit Left Logical Shift Execution Format Summary of Operation Instruction Code States T Bit T ← Rn ← 0 SHLL Rn 0100nnnn00000000 1 Description This instruction logically shifts the contents of general register Rn one bit to the left, and stores the result in Rn.
10.89 SHLR SHift Logical Right Shift Instruction One-Bit Right Logical Shift Execution Format Summary of Operation Instruction Code States T Bit 0 → Rn → T SHLR 0100nnnn00000001 1 Description This instruction logically shifts the contents of general register Rn one bit to the right, and stores the result in Rn.
10.91 SLEEP SLEEP System Control Instruction Transition to Power-Down Mode (Privileged Instruction) Execution Format Summary of Operation Instruction Code States T Bit SLEEP Sleep 0000000000011011 4 — Description This instruction places the CPU in the power-down state. In power-down mode, the CPU retains its internal state, but immediately stops executing instructions and waits for an interrupt request.
10.92 STore Control register System Control Instruction Store from Control Register (Privileged Instruction) Execution Format Summary of Operation Instruction Code States T Bit SR → Rn SR, Rn — 0000nnnn00000010 GBR → Rn GBR, Rn — 0000nnnn00010010 VBR → Rn VBR, Rn —...
Page 383
Description This instruction stores control register SR, GBR, VBR, SSR, SPC, SGR, DBR or Rm_BANK (m = 0–7) in the destination. Rm_BANK operands are specified by the RB bit of the SR register: when the RB bit is 1 Rm_BANK0 is accessed, when the RB bit is 0 Rm_BANK1 is accessed.
10.93 STore System register System Control Instruction Store from System Register Execution Format Summary of Operation Instruction Code States T Bit MACH → Rn MACH,Rn 0000nnnn00001010 1 — MACL → Rn MACL,Rn 0000nnnn00011010 1 — PR → Rn PR,Rn 0000nnnn00101010 1 —...
Page 388
R[n]–=4; Write_Long(R[n],MACH); PC+=2; STSMMACL(int n) /* STS.L MACL,@-Rn */ R[n]–=4; Write_Long(R[n],MACL); PC+=2; STSMPR(int n) /* STS.L PR,@-Rn */ R[n]–=4; Write_Long(R[n],PR); PC+=2; Possible Exceptions: • Data TLB miss exception • Data TLB protection violation exception • Address error Example ; Before execution R0 = H’FFFFFFFF, MACH = H’00000000 STS MACH,R0 ;...
10.94 STore from FPU System register System Control Instruction Store from FPU System Register Execution Format Summary of Operation Instruction Code States T Bit FPUL → Rn FPUL,Rn 0000nnnn01011010 1 — FPSCR → Rn FPSCR,Rn 0000nnnn01101010 1 — Rn-4 → Rn, FPUL → (Rn) STS.L FPUL,@-Rn 0100nnnn01010010 1 —...
Page 390
PC+=2; Possible Exceptions: • Data TLB miss exception • Data TLB protection violation exception • Address error Examples • STS Example 1: MOV.L #H’12ABCDEF, R12 R12, FPUL FPUL, R13 ; After executing the STS instruction: ; R13 = 12ABCDEF Example 2: FPSCR, R2 ;...
10.95 SUBtract binary Arithmetic Instruction Binary Subtraction Execution Format Summary of Operation Instruction Code States T Bit Rn-Rm → Rn SUB Rm,Rn 0011nnnnmmmm1000 1 — Description This instruction subtracts the contents of general register Rm from the contents of general register Rn and stores the result in Rn.
10.96 SUBC SUBtract with Carry Arithmetic Instruction Binary Subtraction with Borrow Execution Format Summary of Operation Instruction Code States T Bit Rn-Rm-T → Rn, borrow → T SUBC Rm,Rn 0011nnnnmmmm1010 1 Borrow Description This instruction subtracts the contents of general register Rm and the T bit from the contents of general register Rn, and stores the result in Rn.
10.97 SUBV SUBtract with (V flag) underflow check Arithmetic Instruction Binary Subtraction with Underflow Check Execution Format Summary of Operation Instruction Code States T Bit Rn-Rm → Rn, underflow → T SUBV Rm,Rn 0011nnnnmmmm1011 1 Underflow Description This instruction subtracts the contents of general register Rm from the contents of general register Rn, and stores the result in Rn.
10.99 Test And Set Logical Instruction Memory Test and Bit Setting Execution Format Summary of Operation Instruction Code States T Bit If (Rn) = 0, 1 → T, else 0 → T TAS.B @Rn 0100nnnn00011011 5 Test result 1 → MSB of (Rn) Description This instruction purges the cache block corresponding to the memory area specified by the contents of general register Rn, reads the byte data indicated by that address, and sets the T bit to 1...
Page 398
Possible Exceptions: • Data TLB miss exception • Data TLB protection violation exception • Initial page write exception • Address error Exceptions are checked taking a data access by this instruction as a byte store. Rev. 2.0, 03/99, page 384 of 396...
10.101 TST TeST logical Logical Instruction AND Operation T Bit Setting Execution Format Summary of Operation Instruction Code States T Bit Rm,Rn Rn & Rm; if result is 0, 0010nnnnmmmm1000 1 Test 1 → T, else 0 → T result #imm,R0 R0 &...
Page 401
TSTM(long i) /* TST.B #imm,@(R0,GBR) */ long temp; temp=(long)Read_Byte(GBR+R[0]); temp&=(0x000000FF & (long)i); if (temp==0) T=1; else T=0; PC+=2; Example ;Before execution R0 = H’00000000 R0,R0 ;After execution T = 1 ;Before execution R0 = H’FFFFFF7F #H’80,R0 ;After execution T = 1 TST.B #H’A5,@(R0,GBR) ;Before execution (R0,GBR) = H’A5 ;After execution T = 0...
10.103 XTRCT eXTRaCT Data Transfer Instruction Middle Extraction from Linked Registers Execution Format Summary of Operation Instruction Code States T Bit Middle 32 bits of Rm:Rn → Rn XTRCT Rm,Rn 0010nnnnmmmm1101 1 — Description This instruction extracts the middle 32 bits from the 64-bit contents of linked general registers Rm and Rn, and stores the result in Rn.
Page 409
SCSPTR2 H’FFE8 0020 H’1FE8 0020 16 H’0000* H’0000* Held Held Pclk SCIF SCLSR2 H’FFE8 0024 H’1FE8 0024 16 H’0000 H’0000 Held Held Pclk Hitachi- SDIR H’FFF0 0000 H’1FF0 0000 16 H’FFFF* Held Held Held Pclk Hitachi- SDDR H’FFF0 0008 H’1FF0 0008 32 Held Held Held...
Page 410
2. Includes undefined bits. See the descriptions of the individual modules. 3. Use word-size access when writing. Perform the write with the upper byte set to H’5A or H’A5, respectively. Byte- and longword-size writes cannot be used. Use byte-size access when reading. Rev.
Appendix B Instruction Prefetch Side Effects The SH4 is provided with an internal buffer for holding pre-read instructions, and always performs pre-reading. Therefore, program code must not be located in the last 20-byte area of any memory space. If program code is located in these areas, the memory area will be exceeded and a bus access for instruction pre-reading may be initiated.