Taken from Hitachi homepage


up
up

CPU

up
up

2.1 Register Configuration

The register set consists of sixteen 32-bit general registers, three 32-bit control registers and four 32-bit system registers.

up
up

2.1.1 General Registers

The 16 general registers (R0-R15) are shown in figure 2.1. General registers are used for data processing and address calculation. R0 is also used as an index register, and several instructions use R0 as a fixed source or destination register. R15 is used as the hardware stack pointer (SP). Saving and recovering the status register (SR) and program counter (PC) in exception processing is accomplished by referencing the stack using R15.

picture Figure 2.1 General Registers
  1. Notes: 1. R0 functions as an index register in the indirect indexed register addressing mode and indirect indexed GBR addressing mode. In some instructions, R0 functions as a fixed source register or destination register.
  2. 2. R15 functions as a hardware stack pointer (SP) during exception processing.

up
up

2.1.2 Control Registers

The 32-bit control registers consist of the 32-bit status register (SR), global base register (GBR), and vector base register (VBR) (figure 2.2). The status register indicates processing states. The global base register functions as a base address for the indirect GBR addressing mode to transfer data to the registers of on-chip peripheral modules. The vector base register functions as the base address of the exception processing vector area (including interrupts).

picture Figure 2.2 Control Registers

up
up

2.1.3 System Registers

System registers consist of four 32-bit registers: high and low multiply and accumulate registers (MACH and MACL), the procedure register (PR), and the program counter (PC) (figure 2.3). The multiply and accumulate registers store the results of multiply and accumulate operations. The procedure register stores the return address from the subroutine procedure. The program counter stores program addresses to control the flow of the processing.

picture Figure 2.3 System Registers

up
up

2.1.4 Initial Values of Registers

Table 2.1 lists the values of the registers after reset.

Table 2.1 Initial Values of Registers

Classification Register Initial Value

General registers R0-R14 Undefined

-- R15 (SP) Value of the stack pointer in the vector address table

Control registers SR Bits I3-I0 are 1111 (H'F), reserved bits are 0, and other bits are undefined

-- GBR Undefined

-- VBR H'00000000

System registers MACH, MACL, PR Undefined

-- PC Value of the program counter in the vector address table

up
up

2.2 Data Formats

up
up

2.2.1 Data Format in Registers

Register operands are always longwords (32 bits) (figure 2.4). When the 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.

picture Figure 2.4 Longword Operand

up
up

2.2.2 Data Format in Memory

Memory data formats are classified into bytes, words, and longwords. Byte data can be accessed from any address, but an address error will occur if you try to access word data starting from an address other than 2n or longword data starting from an address other than 4n. In such cases, the data accessed cannot be guaranteed (figure 2.5). The hardware stack area, referred to by the hardware stack pointer (SP, R15), uses only longword data starting from address 4n because this area holds the program counter and status register. See the SH 7032/34 Hardware User Manual for more information on address errors.

This microprocessor has a function that allows access of CSZ space (area 2) in little endian format, which enables the microprocessor to share memory with processors that access memory in little endian format. The microprocessor arranges byte data differently for little endian and the more usual big endian format.

picture Figure 2.5 Byte, Word, and Longword Alignment

up
up

2.2.3 Immediate Data Format

Byte immediate data resides in an instruction code. Immediate data accessed by the MOV, ADD, and CMP/EQ instructions is sign-extended and handled in registers as longword data. Immediate data accessed by the TST, AND, OR, and XOR instructions is zero-extended and handled as longword data. Consequently, AND instructions with immediate data always clear the upper 24 bits of the destination register.

Word or longword immediate data is not located in the instruction code: it is stored in a memory table. An immediate data transfer instruction (MOV) accesses the memory table using the PC relative addressing mode with displacement. Specific examples are given in table 2.5, Immediate Data Accessing.

up
up

2.3 Instruction Features

up
up

2.3.1 RISC-Type Instruction Set

All instructions are RISC type. This section details their functions.

16-Bit Fixed Length: All instructions are 16 bits long, increasing program code efficiency.

One Instruction per Cycle: The microprocessor can execute basic instructions in one cycle using the pipeline system. Instructions are executed in 35 ns at 28.7 MHz.

Data Length: Longword is the standard data length for all operations. Memory can be accessed in bytes, words, or longwords. Byte or word data accessed from memory is sign-extended and handled as longword data (table 2.2). Immediate data is sign-extended for arithmetic operations or zero-extended for logic operations. It also is handled as longword data.

Table 2.2 Sign Extension of Word Data

SH7604 Series CPU Description Example of Conventional CPU

MOV.W @(disp,PC),R1

ADD R1,R0

.........

.DATA.W H'1234

Data is sign-extended to 32 bits, and R1 becomes H'00001234. It is next operated upon by an ADD instruction. ADD.W #H'1234,R0

Note: @(disp, PC) accesses the address of the immediate data.

Load-Store Architecture: Basic operations are executed between registers. For operations that involve memory access, data is loaded to the registers and executed (load-store architecture). Instructions such as AND that manipulate bits, however, are executed directly in memory.

Delayed Branch Instructions: Unconditional branch instructions are delayed. Executing the instruction that follows the branch instruction, and then branching reduces pipeline disruption during branching (table 2.3).

Table 2.3 Delayed Branch Instructions

SH7604 Series CPU Description Example of Conventional CPU

BRA TRGET

ADD R1,R0

Executes an ADD before branching to TRGET ADD.W R1,R0

BRA TRGET


Multiplication/Accumulation Operation: 16-bit X 16-bit --> 32-bit multiplication operations are executed in one to two cycles. 16-bit X 16-bit + 64-bit --> 64-bit multiplication/accumulation operations are executed in two to three cycles. 32-bit X 32-bit --> 64-bit and 32-bit X 32-bit + 64­bit --> 64-bit multiplication/accumulation operations are executed in two to four cycles.

T Bit: The T bit in the status register changes according to the result of the comparison, and in turn is the condition (true/false) that determines if the program will branch (table 2.4). The number of instructions after the T bit in the status register is kept to a minimum to improve the processing speed.

Table 2.4 T Bit

SH7604 Series CPU Description Example of Conventional CPU

CMP/GE R1,R0

BT TRGET0

BF TRGET1

T bit is set when R0 >= R1. The program branches to TRGET0 when R0 >= R1 and to TRGET1 when R0 < R1. CMP.W R1,R0

BGE TRGET0

BLT TRGET1


ADD #-1,R0

CMP/EQ #0,R0

BT TRGET

T bit is not changed by ADD. T bit is set when R0 = 0. The program branches if R0 = 0. SUB.W #1,R0

BEQ TRGET


Immediate Data: Byte immediate data resides in instruction code. Word or longword immediate data is not input via instruction codes but is stored in a memory table. An immediate data transfer instruction (MOV) accesses the memory table using the PC relative addressing mode with displacement (table 2.5).

Table 2.5 Immediate Data Accessing

Classification SH7604 Series CPU Example of Conventional CPU

8-bit immediate MOV #H'12,R0 MOV.B #H'12,R0

16-bit immediate MOV.W @(disp,PC),R0

.................

.DATA.W H'1234

MOV.W #H'1234,R0

32-bit immediate MOV.L @(disp,PC),R0

.................

.DATA.L H'12345678

MOV.L #H'12345678,R0

Note: @(disp, PC) accesses the address of the immediate data.

Absolute Address: When data is accessed by absolute address, the value already in the absolute address is placed in the memory table. Loading the immediate data when the instruction is executed transfers that value to the register and the data is accessed in the indirect register addressing mode (table 2.6).

Table 2.6 Absolute Address Accessing

Classification SH7604 Series CPU Example of Conventional CPU

Absolute address MOV.L @(disp,PC),R1

MOV.B @R1,R0

..................

.DATA.L H'12345678

MOV.B @H'12345678,R0

Note: @(disp,PC) accesses the address of the immediate data.

16-Bit/32-Bit Displacement: When data is accessed by 16-bit or 32-bit displacement, the pre-existing displacement value is placed in the memory table. Loading the immediate data when the instruction is executed transfers that value to the register and the data is accessed in the indirect indexed register addressing mode (table 2.7).

Table 2.7 16/32-Bit Displacement Accessing

Classification SH7604 Series CPU Example of Conventional CPU

16-bit displacement MOV.W @(disp,PC),R0

MOV.W @(R0,R1),R2

..................

.DATA.W H'1234

MOV.W @(H'1234,R1),R2

Note: @(disp,PC) accesses the address of the immediate data.

up
up

2.3.2 Addressing Modes

Table 2.8 describes addressing modes and effective address calculation.

Table 2.8 Addressing Modes and Effective Addresses

Addressing Mode Instruction Format
Effective Addresses Calculation

Equation

Direct register addressing Rn The effective address is register Rn. (The operand is the contents of register Rn.) --

Indirect register addressing @Rn The effective address is the content of register Rn.

Rn

Post-increment indirect register addressing @Rn+ The effective address is the content of register Rn. A constant is added to the content of Rn after the instruction is executed. 1 is added for a byte operation, 2 for a word operation, and 4 for a longword operation.

Rn

(After the instruction executes)

Byte: Rn + 1 --> Rn

Word: Rn + 2 --> Rn

Longword: Rn + 4 --> Rn


Pre-decrement indirect register addressing @-Rn The effective address is the value obtained by subtracting a constant from Rn. 1 is subtracted for a byte operation, 2 for a word operation, and 4 for a longword operation.

Byte: Rn - 1 --> Rn

Word: Rn - 2 --> Rn

Longword: Rn - 4 --> Rn (Instruction executed with Rn after calculation)


Table 2.8 Addressing Modes and Effective Addresses (cont)

Addressing Mode Instruction Format
Effective Addresses Calculation

Equation

Indirect register addressing with displacement @(disp:4, Rn) The effective address is Rn plus a 4-bit displacement (disp). The value of disp is zero-extended, and remains the same for a byte operation, is doubled for a word operation, and is quadrupled for a longword operation.

Byte: Rn + disp

Word: Rn + disp X 2

Longword: Rn + disp X 4


Indirect indexed register addressing @(R0, Rn) The effective address is the Rn value plus R0.

Rn + R0

Indirect GBR addressing with displacement @(disp:8, GBR) The effective address is the GBR value plus an 8-bit displacement (disp). The value of disp is zero-extended, and remains the same for a byte opera-tion, is doubled for a word operation, and is quadrupled for a longword operation.

Byte: GBR + disp

Word: GBR + disp X 2

Longword: GBR + disp X 4


Indirect indexed GBR addressing @(R0, GBR) The effective address is the GBR value plus the R0.

GBR + R0

Table 2.8 Addressing Modes and Effective Addresses (cont)

Addressing Mode Instruction Format
Effective Addresses Calculation

Equation

Indirect PC addressing with displacement @(disp:8, PC) The effective address is the PC value plus an 8-bit displacement (disp). The value of disp is zero-extended, and remains the same for a byte operation, is doubled for a word operation, and is quadrupled for a longword operation. For a longword operation, the lowest two bits of the PC value are masked.

Word: PC + disp X 2

Longword: PC & H'FFFFFFFC + disp X 4


PC relative addressing disp:8 The effective address is the PC value sign-extended with an 8-bit displacement (disp), doubled, and added to the PC value.

PC + disp X 2

-- disp:12 The effective address is the PC value sign-extended with a 12-bit displacement (disp), doubled, and added to the PC value.

PC + disp X 2

Table 2.8 Addressing Modes and Effective Addresses (cont)

Addressing Mode Instruction Format
Effective Addresses Calculation

Equation

PC relative addressing (cont) Rn The effective address is the register PC value plus Rn.

PC + Rn

Immediate addressing #imm:8 The 8-bit immediate data (imm) for the TST, AND, OR, and XOR instructions are zero-extended. --

-- #imm:8 The 8-bit immediate data (imm) for the MOV, ADD, and CMP/EQ instructions are sign-extended. --

-- #imm:8 Immediate data (imm) for the TRAPA instruction is zero-extended and is quadrupled. --

up
up

2.3.3 Instruction Format

The instruction format table, table 2.9, refers to the source operand and the destination operand. The meaning of the operand depends on the instruction code. The symbols are used as follows:

Table 2.9 Instruction Formats


Instruction Formats

Source Operand
Destination Operand
Example

0 format

-- -- NOP

n format

-- nnnn: Direct register MOVT Rn

-- Control register or system register nnnn: Direct register STS MACH,Rn

-- Control register or system register nnnn: Indirect pre-decrement register STC.L SR,@-Rn

m format

mmmm: Direct register Control register or system register LDC Rm,SR

-- mmmm: Indirect post-increment register Control register or system register LDC.L @Rm+,SR

-- mmmm: Indirect register -- JMP @Rm

-- mmmm: PC relative using Rm -- BRAF Rm

Table 2.9 Instruction Formats (cont)


Instruction Formats

Source Operand
Destination Operand
Example

nm format mmmm: Direct register nnnn: Indirect register ADD Rm,Rn

mmmm: Direct register nnnn: Direct register MOV.L Rm,@Rn

-- mmmm: Indirect post-increment register (multiply/ accumulate)

nnnn: Indirect post-increment register (multiply/ accumulate)*

MACH, MACL MAC.W
@Rm+,@Rn+

-- mmmm: Indirect post-increment register nnnn: Direct register MOV.L @Rm+,Rn

-- mmmm: Direct register nnnn: Indirect pre-decrement register MOV.L Rm,@-Rn

-- mmmm: Direct register nnnn: Indirect indexed register MOV.L Rm,@(R0,Rn)

md format

mmmmdddd: indirect register with displacement R0 (Direct register) MOV.B @(disp,Rn),R0

nd4 format

R0 (Direct register) nnnndddd: Indirect register with displacement MOV.B R0,@(disp,Rn)

nmd format

mmmm: Direct register nnnndddd: Indirect register with displacement MOV.L Rm,@(disp,Rn)

-- mmmmdddd: Indirect register with displacement nnnn: Direct register MOV.L @(disp,Rm),Rn

Table 2.9 Instruction Formats (cont)


Instruction Formats

Source Operand
Destination Operand
Example

d format

dddddddd: Indirect GBR with displacement R0 (Direct register) MOV.L @(disp,GBR),R0

-- R0(Direct register) dddddddd: Indirect GBR with displacement MOV.L R0,@(disp,GBR)

-- dddddddd: PC relative with displacement R0 (Direct register) MOVA @(disp,PC),R0

-- dddddddd: PC relative -- BF label

d12 format

dddddddddddd:
PC relative
-- BRA label

(label = disp + PC)


nd8 format

dddddddd: PC relative with displacement nnnn: Direct register MOV.L @(disp,PC),Rn

i format iiiiiiii: Immediate Indirect indexed GBR AND.B #imm,@(R0,GBR)

iiiiiiii: Immediate R0 (Direct register) AND #imm,R0

-- iiiiiiii: Immediate -- TRAPA #imm

ni format

iiiiiiii: Immediate nnnn: Direct register ADD #imm,Rn

Note: In multiply/accumulate instructions, nnnn is the source register.

up
up

2.4 Instruction Set

up
up

2.4.1 Instruction Set by Classification

Table 2.10 Instruction Set by Classification


Classification

Types
Operation Code
Function
Number of Instructions

Data transfer 5 MOV Data transfer, immediate data transfer, peripheral module data transfer, structure data transfer 39

-- -- MOVA Effective address transfer --

-- -- MOVT T bit transfer --

-- -- SWAP Swap of upper and lower bytes --

-- -- XTRCT Extraction of the middle of registers connected --

Arithmetic 21 ADD Binary addition 33

operations -- ADDC Binary addition with carry --

-- -- ADDV Binary addition with overflow check --

-- -- CMP/cond Comparison --

-- -- DIV1 Division --

-- -- DIV0S Initialization of signed division --

-- -- DIV0U Initialization of unsigned division --

-- -- DMULS Signed double-length multiplication --

-- -- DMULU Unsigned double-length multiplication --

-- -- DT Decrement and test --

-- -- EXTS Sign extension --

-- -- EXTU Zero extension --

-- -- MAC Multiply/accumulate, double-length multiply/accumulate operation --

-- -- MUL Double-length multiplication --

-- -- MULS Signed multiplication --

-- -- MULU Unsigned multiplication --

-- -- NEG Negation --

-- -- NEGC Negation with borrow --

-- -- SUB Binary subtraction --

-- -- SUBC Binary subtraction with borrow --

-- -- SUBV Binary subtraction with underflow check --

Table 2.10 Instruction Set by Classification (cont)


Classification

Types
Operation Code
Function
Number of Instructions

Logic 6 AND Logical AND 14

operations -- NOT Bit inversion --

-- -- OR Logical OR --

-- -- TAS Memory test and bit set --

-- -- TST Logical AND and T bit set --

-- -- XOR Exclusive OR --

Shift 10 ROTL One-bit left rotation 14

-- -- ROTR One-bit right rotation --

-- -- ROTCL One-bit left rotation with T bit --

-- -- ROTCR One-bit right rotation with T bit --

-- -- SHAL One-bit arithmetic left shift --

-- -- SHAR One-bit arithmetic right shift --

-- -- SHLL One-bit logical left shift --

-- -- SHLLn n-bit logical left shift --

-- -- SHLR One-bit logical right shift --

-- -- SHLRn n-bit logical right shift --

Branch 9 BF Conditional branch, conditional branch with delay (T = 0) 11

-- -- BT Conditional branch, conditional branch with delay (T = 1) --

-- -- BRA Unconditional branch --

-- -- BRAF Unconditional branch --

-- -- BSR Branch to subroutine procedure --

-- -- BSRF Branch to subroutine procedure --

-- -- JMP Unconditional branch --

-- -- JSR Branch to subroutine procedure --

-- -- RTS Return from subroutine procedure --

Table 2.10 Instruction Set by Classification (cont)


Classification

Types
Operation Code
Function
Number of Instructions

System 11 CLRT T bit clear 31

control -- CLRMAC MAC register clear --

-- -- LDC Load to control register --

-- -- LDS Load to system register --

-- -- NOP No operation --

-- -- RTE Return from exception processing --

-- -- SETT T bit set --

-- -- SLEEP Shift into power-down state --

-- -- STC Storing control register data --

-- -- STS Storing system register data --

-- -- TRAPA Trap exception handling --

Total: 61 -- -- 142

Table 2.11 shows the format for instruction codes, operation, and execution states used in tables 2.12 to 2.17, which list the minimum number of clock cycles required for execution. In practice, the number of execution cycles increases when the instruction fetch is in contention with data access or when the destination register of a load instruction (memory --> register) is the same as the register used by the next instruction.

Table 2.11 Instruction Code Format

Item Format Explanation

Instruction mnemonic OP.Sz SRC,DEST OP: Operation code
Sz: Size (B: byte, W: word, or L: longword)
SRC: Source
DEST: Destination
Rm: Source register
Rn: Destination register
imm: Immediate data
disp: Displacement*2

Instruction code MSB &harr; LSB mmmm: Source register
nnnn: Destination register
0000: R0
0001: R1
...........
1111: R15
iiii: Immediate data
dddd: Displacement

Operation -->, <-- Direction of transfer

summary (xx) Memory operand

-- M/Q/T Flag bits in the SR

-- & Logical AND of each bit

-- | Logical OR of each bit

-- ^ Exclusive OR of each bit

-- ~ Logical NOT of each bit

-- <<n, >>n n-bit shift

Execution cycle -- Value when no wait states are inserted*1

T bit -- Value of T bit after instruction is executed. An em-dash (--) in the column means no change.

  1. Notes: 1. Instruction execution cycles: The execution cycles shown in the table are minimums. The actual number of cycles may be increased when:
  2. Contention occurs between instruction fetch and data access
  3. The destination register of the load instruction (memory --> register) and the register used by the next instruction are the same.
  4. 2. Depending on the operand size, displacement is scaled X1, X2, or X3. For details, see the SH-1/SH-2 programming manual.

Table 2.12 Data Transfer Instructions



Instruction


Instruction Code


Operation
Execu-tion Cycles
T Bit

MOV #imm,Rn 1110nnnniiiiiiii #imm --> Sign extension --> Rn 1 --

MOV.W @(disp,PC),Rn 1001nnnndddddddd (disp X 2 + PC) --> Sign extension --> Rn 1 --

MOV.L @(disp,PC),Rn 1101nnnndddddddd (disp X 4 + PC) --> Rn 1 --

MOV Rm,Rn 0110nnnnmmmm0011 Rm --> Rn 1 --

MOV.B Rm,@Rn 0010nnnnmmmm0000 Rm --> (Rn) 1 --

MOV.W Rm,@Rn 0010nnnnmmmm0001 Rm --> (Rn) 1 --

MOV.L Rm,@Rn 0010nnnnmmmm0010 Rm --> (Rn) 1 --

MOV.B @Rm,Rn 0110nnnnmmmm0000 (Rm) --> Sign extension --> Rn 1 --

MOV.W @Rm,Rn 0110nnnnmmmm0001 (Rm) --> Sign extension --> Rn 1 --

MOV.L @Rm,Rn 0110nnnnmmmm0010 (Rm) --> Rn 1 --

MOV.B Rm,@-Rn 0010nnnnmmmm0100 Rn-1 --> Rn, Rm --> (Rn) 1 --

MOV.W Rm,@-Rn 0010nnnnmmmm0101 Rn-2 --> Rn, Rm --> (Rn) 1 --

MOV.L Rm,@-Rn 0010nnnnmmmm0110 Rn-4 --> Rn, Rm --> (Rn) 1 --

MOV.B @Rm+,Rn 0110nnnnmmmm0100 (Rm) --> Sign extension --> Rn,Rm + 1 --> Rm 1 --

MOV.W @Rm+,Rn 0110nnnnmmmm0101 (Rm) --> Sign extension --> Rn,Rm + 2 --> Rm 1 --

MOV.L @Rm+,Rn 0110nnnnmmmm0110 (Rm) --> Rn,Rm + 4 --> Rm 1 --

MOV.B R0,@(disp,Rn) 10000000nnnndddd R0 --> (disp + Rn) 1 --

MOV.W R0,@(disp,Rn) 10000001nnnndddd R0 --> (disp X 2 + Rn) 1 --

MOV.L Rm,@(disp,Rn) 0001nnnnmmmmdddd Rm --> (disp X 4 + Rn) 1 --

MOV.B @(disp,Rm),R0 10000100mmmmdddd (disp + Rm) --> Sign extension --> R0 1 --

MOV.W @(disp,Rm),R0 10000101mmmmdddd (disp X 2 + Rm) --> Sign extension --> R0 1 --

MOV.L @(disp,Rm),Rn 0101nnnnmmmmdddd (disp X 4 + Rm) --> Rn 1 --

MOV.B Rm,@(R0,Rn) 0000nnnnmmmm0100 Rm --> (R0 + Rn) 1 --

MOV.W Rm,@(R0,Rn) 0000nnnnmmmm0101 Rm --> (R0 + Rn) 1 --

MOV.L Rm,@(R0,Rn) 0000nnnnmmmm0110 Rm --> (R0 + Rn) 1 --

Table 2.12 Data Transfer Instructions (cont)



Instruction


Instruction Code


Operation
Execu-tion Cycles
T Bit

MOV.B @(R0,Rm),Rn 0000nnnnmmmm1100 (R0 + Rm) --> Sign extension --> Rn 1 --

MOV.W @(R0,Rm),Rn 0000nnnnmmmm1101 (R0 + Rm) --> Sign extension --> Rn 1 --

MOV.L @(R0,Rm),Rn 0000nnnnmmmm1110 (R0 + Rm) --> Rn 1 --

MOV.B R0,@(disp,GBR) 11000000dddddddd R0 --> (disp + GBR) 1 --

MOV.W R0,@(disp,GBR) 11000001dddddddd R0 --> (disp X 2 + GBR) 1 --

MOV.L R0,@(disp,GBR) 11000010dddddddd R0 --> (disp X 4 + GBR) 1 --

MOV.B @(disp,GBR),R0 11000100dddddddd (disp + GBR) --> Sign extension --> R0 1 --

MOV.W @(disp,GBR),R0 11000101dddddddd (disp X 2 + GBR) --> Sign extension --> R0 1 --

MOV.L @(disp,GBR),R0 11000110dddddddd (disp X 4 + GBR) --> R0 1 --

MOVA @(disp,PC),R0 11000111dddddddd disp X 4 + PC --> R0 1 --

MOVT Rn 0000nnnn00101001 T --> Rn 1 --

SWAP.B Rm,Rn 0110nnnnmmmm1000 Rm --> Swap the bottom two bytes --> Rn 1 --

SWAP.W Rm,Rn 0110nnnnmmmm1001 Rm --> Swap two consecutive words --> Rn 1 --

XTRCT Rm,Rn 0010nnnnmmmm1101 Rm: Middle 32 bits of Rn --> Rn 1 --

Table 2.13 Arithmetic Instructions


Instruction

Instruction Code

Operation
Execution Cycles
T Bit

ADD Rm,Rn 0011nnnnmmmm1100 Rn + Rm --> Rn 1 --

ADD #imm,Rn 0111nnnniiiiiiii Rn + imm --> Rn 1 --

ADDC Rm,Rn 0011nnnnmmmm1110 Rn + Rm + T --> Rn, Carry --> T 1 Carry

ADDV Rm,Rn 0011nnnnmmmm1111 Rn + Rm --> Rn, Overflow --> T 1 Overflow

CMP/EQ #imm,R0 10001000iiiiiiii If R0 = imm, 1 --> T 1 Comparison result

CMP/EQ Rm,Rn 0011nnnnmmmm0000 If Rn = Rm, 1 --> T 1 Comparison result

CMP/HS Rm,Rn 0011nnnnmmmm0010 If Rn>=Rm with unsigned data, 1 --> T 1 Comparison result

CMP/GE Rm,Rn 0011nnnnmmmm0011 If Rn >= Rm with signed data, 1 --> T 1 Comparison result

CMP/HI Rm,Rn 0011nnnnmmmm0110 If Rn > Rm with unsigned data, 1 --> T 1 Comparison result

CMP/GT Rm,Rn 0011nnnnmmmm0111 If Rn > Rm with signed data, 1 --> T 1 Comparison result

CMP/PZ Rn 0100nnnn00010001 If Rn >= 0, 1 --> T 1 Comparison result

CMP/PL Rn 0100nnnn00010101 If Rn > 0, 1 --> T 1 Comparison result

CMP/ST Rm,Rn 0010nnnnmmmm1100 If Rn and Rm have an equivalent byte, 1 --> T 1 Comparison result

DIV1 Rm,Rn 0011nnnnmmmm0100 Single-step division (Rn/Rm) 1 Calculation result

DIV0S Rm,Rn 0010nnnnmmmm0111 MSB of Rn --> Q, MSB of Rm --> M, M ^ Q --> T 1 Calculation result

DIV0U 0000000000011001 0 --> M/Q/T 1 0

DMULS. Rm,Rn 0011nnnnmmmm1101 Signed operation of Rn X Rm --> MACH, MACL 32 X 32 --> 64 bit 2 to 4* --

Table 2.13 Arithmetic Instructions (cont)


Instruction

Instruction Code

Operation
Execution Cycles
T Bit

DMULU.L Rm,Rn 0011nnnnmmmm0101 Unsigned operation of Rn X Rm --> MACH, MACL 32 X 32 --> 64 bit 2 to 4* --

DT Rn 0100nnnn00010000 Rn - 1 --> Rn, when Rn is 0, 1 --> T. When Rn is nonzero, 0 --> T 1 Comparisonresult

EXTS.B Rm,Rn 0110nnnnmmmm1110 A byte in Rm is sign-extended --> Rn 1 --

EXTS.W Rm,Rn 0110nnnnmmmm1111 A word in Rm is sign-extended --> Rn 1 --

EXTU.B Rm,Rn 0110nnnnmmmm1100 A byte in Rm is zero-extended --> Rn 1 --

EXTU.W Rm,Rn 0110nnnnmmmm1101 A word in Rm is zero-extended --> Rn 1 --

MAC.L @Rm+,@Rn+ 0000nnnnmmmm1111 Signed operation of (Rn) X (Rm) --> MAC --> MAC 32 X 32 --> 64 bit 3/(2 to 4)* --

MAC @Rm+,@Rn+ 0100nnnnmmmm1111 Signed operation of (Rn) X (Rm) + MAC --> MAC 16 X 16 + 64 --> 64 bit 3/(2)* --

MUL.L Rm,Rn 0000nnnnmmmm0111 Rn X Rm --> MACL, 32 X 32 --> 32 bit 2 to 4* --

MULS.W Rm,Rn 0010nnnnmmmm1111 Signed operation of Rn X Rm --> MAC 16 X 16 --> 32 bit 1 to 3* --

MULU.W Rm,Rn 0010nnnnmmmm1110 Unsigned operation of Rn X Rm --> MAC 16 X 16 --> 32 bit 1 to 3* --

NEG Rm,Rn 0110nnnnmmmm1011 0-Rm --> Rn 1 --

NEGC Rm,Rn 0110nnnnmmmm1010 0-Rm-T --> Rn, Borrow --> T 1 Borrow

Table 2.13 Arithmetic Instructions (cont)


Instruction

Instruction Code

Operation
Execution Cycles
T Bit

SUB Rm,Rn 0011nnnnmmmm1000 Rn-Rm --> Rn 1 --

SUBC Rm,Rn 0011nnnnmmmm1010 Rn-Rm-T --> Rn, Borrow --> T 1 Borrow

SUBV Rm,Rn 0011nnnnmmmm1011 Rn-Rm --> Rn, Underflow --> T 1 Underflow

Note: The normal minimum number of execution cycles. (The number in parentheses is the number of cycles when there is contention with following instructions.)

Table 2.14 Logic Operation Instructions



Instruction


Instruction Code


Operation
Execu-tion Cycles

T Bit

AND Rm,Rn 0010nnnnmmmm1001 Rn & Rm --> Rn 1 --

AND #imm,R0 11001001iiiiiiii R0 & imm --> R0 1 --

AND.B #imm,@(R0,GBR) 11001101iiiiiiii (R0 + GBR) & imm --> (R0 + GBR) 3 --

NOT Rm,Rn 0110nnnnmmmm0111 ~Rm --> Rn 1 --

OR Rm,Rn 0010nnnnmmmm1011 Rn | Rm --> Rn 1 --

OR #imm,R0 11001011iiiiiiii R0 | imm --> R0 1 --

OR.B #imm,@(R0,GBR) 11001111iiiiiiii (R0 + GBR) | imm --> (R0 + GBR) 3 --

TAS.B @Rn 0100nnnn00011011 If (Rn) is 0, 1 --> T; 1 --> MSB of (Rn) 4 Test result

TST Rm,Rn 0010nnnnmmmm1000 Rn & Rm; if the result is 0, 1 --> T 1 Test result

TST #imm,R0 11001000iiiiiiii R0 & imm; if the result is 0, 1 --> T 1 Test result

TST.B #imm,@(R0,GBR) 11001100iiiiiiii (R0 + GBR) & imm; if the result is 0, 1 --> T 3 Test result

XOR Rm,Rn 0010nnnnmmmm1010 Rn ^ Rm --> Rn 1 --

XOR #imm,R0 11001010iiiiiiii R0 ^ imm --> R0 1 --

XOR.B #imm,@(R0,GBR) 11001110iiiiiiii (R0 + GBR) ^ imm --> (R0 + GBR) 3 --

Table 2.15 Shift Instructions


Instruction

Instruction Code

Operation
Execution Cycles
T Bit

ROTL Rn 0100nnnn00000100 T <-- Rn <-- MSB 1 MSB

ROTR Rn 0100nnnn00000101 LSB --> Rn --> T 1 LSB

ROTCL Rn 0100nnnn00100100 T <-- Rn <-- T 1 MSB

ROTCR Rn 0100nnnn00100101 T --> Rn --> T 1 LSB

SHAL Rn 0100nnnn00100000 T <-- Rn <-- 0 1 MSB

SHAR Rn 0100nnnn00100001 MSB --> Rn --> T 1 LSB

SHLL Rn 0100nnnn00000000 T <-- Rn <-- 0 1 MSB

SHLR Rn 0100nnnn00000001 0 --> Rn --> T 1 LSB

SHLL2 Rn 0100nnnn00001000 Rn<<2 --> Rn 1 --

SHLR2 Rn 0100nnnn00001001 Rn>>2 --> Rn 1 --

SHLL8 Rn 0100nnnn00011000 Rn<<8 --> Rn 1 --

SHLR8 Rn 0100nnnn00011001 Rn>>8 --> Rn 1 --

SHLL16 Rn 0100nnnn00101000 Rn<<16 --> Rn 1 --

SHLR16 Rn 0100nnnn00101001 Rn>>16 --> Rn 1 --

Table 2.16 Branch Instructions


Instruction

Instruction Code

Operation
Execution Cycles T Bit

BF label 10001011dddddddd If T = 0, disp X 2 + PC --> PC; if T = 1, nop 3/1* --

BF/S label 10001111dddddddd Delayed branch, if T = 0, disp X 2 + PC --> PC; if T = 1, nop 2/1* --

BT label 10001001dddddddd Delayed branch, if T = 1, disp X 2 + PC --> PC; if T = 0, nop 3/1* --

BT/S label 10001101dddddddd If T = 1, disp X 2 + PC --> PC; if T = 0, nop 2/1* --

BRA label 1010dddddddddddd Delayed branch, disp X 2 + PC --> PC 2 --

BRAF Rm 0000mmmm00100011 Delayed branch, Rm + PC --> PC 2 --

BSR label 1011dddddddddddd Delayed branch, PC --> PR, disp X 2 + PC --> PC 2 --

BSRF Rm 0000mmmm00000011 Delayed branch, PC --> PR, Rm + PC --> PC 2 --

JMP @Rm 0100mmmm00101011 Delayed branch, Rm --> PC 2 --

JSR @Rm 0100mmmm00001011 Delayed branch, PC --> PR, Rm --> PC 2 --

RTS 0000000000001011 Delayed branch, PR --> PC 2 --

Note: One state when it does not branch.

Table 2.17 lists the minimum execution cycles. In practice, the number of execution cycles increases when the instruction fetch is in contention with data access or when the destination register of a load instruction (memory --> register) is the same as the register used by the next instruction.

Table 2.17 System Control Instructions



Instruction


Instruction Code


Operation
Execu-tion Cycles
T Bit

CLRT 0000000000001000 0 --> T 1 0

CLRMAC 0000000000101000 0 --> MACH, MACL 1 --

LDC Rm,SR 0100mmmm00001110 Rm --> SR 1 LSB

LDC Rm,GBR 0100mmmm00011110 Rm --> GBR 1 --

LDC Rm,VBR 0100mmmm00101110 Rm --> VBR 1 --

LDC.L @Rm+,SR 0100mmmm00000111 (Rm) --> SR, Rm + 4 --> Rm 3 LSB

LDC.L @Rm+,GBR 0100mmmm00010111 (Rm) --> GBR, Rm + 4 --> Rm 3 --

LDC.L @Rm+,VBR 0100mmmm00100111 (Rm) --> VBR, Rm + 4 --> Rm 3 --

LDS Rm,MACH 0100mmmm00001010 Rm --> MACH 1 --

LDS Rm,MACL 0100mmmm00011010 Rm --> MACL 1 --

LDS Rm,PR 0100mmmm00101010 Rm --> PR 1 --

LDS.L @Rm+,MACH 0100mmmm00000110 (Rm) --> MACH, Rm + 4 --> Rm 1 --

LDS.L @Rm+,MACL 0100mmmm00010110 (Rm) --> MACL, Rm + 4 --> Rm 1 --

LDS.L @Rm+,PR 0100mmmm00100110 (Rm) --> PR, Rm + 4 --> Rm 1 --

NOP 0000000000001001 No operation 1 --

RTE 0000000000101011 Delayed branch, stack area --> PC/SR 4 --

SETT 0000000000011000 1 --> T 1 1

SLEEP 0000000000011011 Sleep 3* --

STC SR,Rn 0000nnnn00000010 SR --> Rn 1 --

STC GBR,Rn 0000nnnn00010010 GBR --> Rn 1 --

STC VBR,Rn 0000nnnn00100010 VBR --> Rn 1 --

STC.L SR,@-Rn 0100nnnn00000011 Rn-4 --> Rn, SR --> (Rn) 2 --

STC.L GBR,@-Rn 0100nnnn00010011 Rn-4 --> Rn, GBR --> (Rn) 2 --

STC.L VBR,@-Rn 0100nnnn00100011 Rn-4 --> Rn, VBR --> (Rn) 2 --

Table 2.17 System Control Instructions (cont)



Instruction


Instruction Code


Operation
Execu-tion Cycles
T Bit

STS MACH,Rn 0000nnnn00001010 MACH --> Rn 1 --

STS MACL,Rn 0000nnnn00011010 MACL --> Rn 1 --

STS PR,Rn 0000nnnn00101010 PR --> Rn 1 --

STS.L MACH,@-Rn 0100nnnn00000010 Rn-4 --> Rn, MACH --> (Rn) 1 --

STS.L MACL,@-Rn 0100nnnn00010010 Rn-4 --> Rn, MACL --> (Rn) 1 --

STS.L PR,@-Rn 0100nnnn00100010 Rn-4 --> Rn, PR --> (Rn) 1 --

TRAPA #imm 11000011iiiiiiii PC/SR --> stack area, (imm) --> PC 8 --

Note: The number of execution states before the chip enters the sleep mode.

Instruction states: The values shown for the execution cycles are minimums. The actual number of cycles may be increased when:

Contention occurs between instruction fetch and data access

The destination register of the load instruction (memory --> register) and the register used by the next instruction are the same.

up
up

2.4.2 Operation Code Map

Table 2.18 Operation Code Map

Instruction Code Fx: 0000 Fx: 0001 Fx: 0010 Fx: 0011-1111

MSB LSB MD: 00 MD: 01 MD: 10 MD: 11

0000 Rn Fx 0000 -- -- -- --

0000 Rn Fx 0001 -- -- -- --

0000 Rn Fx 0010 STC SR,Rn STC GBR,Rn STC VBR,Rn --

0000 Rm Fx 0011 BSRF Rm -- BRAF Rm --

0000 Rn Rm 01MD MOV.B RM,
@(R0,Rn)
MOV.W RM,
@(R0,Rn)
MOV.L RM,
@(R0,Rn)
MUL.L Rm,Rn

0000 0000 Fx 1000 CLRT SETT CLRMAC --

0000 0000 Fx 1001 NOP DIVOU -- --

0000 0000 Fx 1010 -- -- -- --

0000 0000 Fx 1011 RTS SLEEP RTE --

0000 Rn Fx 1000 -- -- -- --

0000 Rn Fx 1001 -- -- MOVT Rn --

0000 Rn Fx 1010 STS MACH,Rn STS MACL,Rn STS PR,Rn --

0000 Rn Fx 1011 -- -- -- --

0000 Rn Rm 11MD MOV.B
@(R0,Rm),Rn
MOV.W
@(R0,Rm),Rn
MOV.L
@(R0,Rm),Rn
MAC.L
@Rm+,@Rn+

0001 Rn Rm disp MOV.L Rm,@(disp:4,Rn)

0010 Rn Rm 00MD MOV.B Rm,@Rn MOV.W Rm,@Rn MOV.L Rm,@Rn --

0010 Rn Rm 01MD MOV.B Rm,
@-Rn
MOV.W Rm,
@-Rn
MOV.L Rm,
@-Rn
DIV0S Rm,Rn

0010 Rn Rm 10MD TST Rm,Rn AND Rm,Rn XOR Rm,Rn OR Rm,Rn

0010 Rn Rm 11MD CMP/STR Rm,Rn XTRCT
Rm,Rn
MULU.W Rm,Rn MULS.W Rm,Rn

0011 Rn Rm 00MD CMP/EQ Rm,Rn -- CMP/HS Rm,Rn CMP/GE Rm,Rn

0011 Rn Rm 01MD DIV1 Rm,Rn DMULU.L
Rm,Rn
CMP/HI Rm,Rn CMP/GT Rm,Rn

0011 Rn Rm 10MD SUB Rm,Rn -- SUBC Rm,Rn SUBV Rm,Rn

0011 Rn Rm 11MD ADD Rm,Rn DMULS.L
Rm,Rn
ADDC Rm,Rn ADDV Rm,Rn

0100 Rn Fx 0000 SHLL Rn DT Rn SHAL Rn --

Table 2.18 Operation Code Map (cont)

Instruction Code Fx: 0000 Fx: 0001 Fx: 0010 Fx: 0011-1111

MSB LSB MD: 00 MD: 01 MD: 10 MD: 11

0100 Rn Fx 0001 SHLR Rn CMP/PZ Rn SHAR Rn --

0100 Rn Fx 0010 STS.L MACH,
@-Rn
STS.L MACL,
@-Rn
STS.L PR,
@-Rn
--

0100 Rn Fx 0011 STC.L
SR,@-Rn
STC.L
GBR,@-Rn
STC.L
VBR,@-Rn
--

0100 Rn Fx 0100 ROTL Rn -- ROTCL Rn --

0100 Rn Fx 0101 ROTR Rn CMP/PL Rn ROTCR Rn --

0100 Rm Fx 0110 LDS.L
@Rm+,MACH
LDS.L
@Rm+,MACL
LDS.L
@Rm+,PR
--

0100 Rm Fx 0111 LDC.L
@Rm+,SR
LDC.L
@Rm+,GBR
LDC.L
@Rm+,VBR
--

0100 Rn Fx 1000 SHLL2 Rn SHLL8 Rn SHLL16 Rn --

0100 Rn Fx 1001 SHLR2 Rn SHLR8 Rn SHLR16 Rn --

0100 Rm Fx 1010 LDS Rm,MACH LDS Rm,MACL LDS Rm,PR --

0100 Rm/Rn Fx 1011 JSR @Rm TAS.B @Rn JMP @Rm --

0100 Rm Fx 1100 -- -- -- --

0100 Rm Fx 1101 -- -- -- --

0100 Rn Fx 1110 LDC Rm,Sr LDC Rm,GBR LDC Rm,VBR --

0100 Rn Rm 1111 MAC.W @Rm+,@Rn+

0101 Rn Rm disp MOV.L @(disp:4,Rm),Rn

0110 Rn Rm 00MD MOV.B @Rm,Rn MOV.W @Rm,Rn MOV.L @Rm,Rn MOV Rm,Rn

0110 Rn Rm 01MD MOV.B
@Rm+,Rn
MOV.W
@Rm+,Rn
MOV.L
@Rm+,Rn
NOT
Rm,Rn

0110 Rn Rm 10MD SWAP.B Rm,Rn SWAP.W Rm,Rn NEGC Rm,Rn NEG Rm,Rn

0110 Rn Rm 11MD EXTU.B Rm,Rn EXTU.W Rm,Rn EXTS.B Rm,Rn EXTS.W Rm,Rn

0111 Rn imm ADD #imm:8,Rn

1000 00MD Rn disp MOV.B R0,
@(disp:4,Rn)
MOV.W R0,
@(disp:4,Rn)
-- --

1000 01MD Rm disp MOV.B
@(disp:4,
Rm),R0
MOV.W
@(disp:4,
Rm),R0
-- --

Table 2.18 Operation Code Map (cont)

Instruction Code Fx: 0000 Fx: 0001 Fx: 0010 Fx: 0011-1111

MSB LSB MD: 00 MD: 01 MD: 10 MD: 11

1000 10MD imm/disp CMP/EQ
#imm:8,R0
BT LABEL:8 -- BF LABEL:8

1000 10MD imm/disp -- BT/S LABEL:8 -- BF/S LABEL:8

1001 Rn disp MOV.W @(disp:8,PC),Rn

1010 disp BRA LABEL:12

1011 disp BSR LABEL:12

1100 00MD imm/disp MOV.B R0,
@(disp:8,
GBR)
MOV.W R0,
@(disp:8,
GBR)
MOV.L R0,
@(disp:8,
GBR)
TRAPA #imm:8

1100 01MD disp MOV.B
@(disp:8,
GBR),R0
MOV.W
@(disp:8,
GBR),R0
MOV.L
@(disp:8,
GBR),R0
MOVA
@(disp:8,
PC),R0

1100 10MD imm TST
#imm:8,R0
AND
#imm:8,R0
XOR
#imm:8,R0
OR
#imm:8,R0

1100 11MD imm TST.B
#imm:8,
@(R0,GBR)
AND.B
#imm:8,
@(R0,GBR)
XOR.B
#imm:8,
@(R0,GBR)
OR.B
#imm:8,
@(R0,GBR)

1101 Rn disp MOV.L @(disp:8,PC),Rn

1110 Rn imm MOV #imm:8,Rn

1111 ... --

up
up

2.5 Processing States

up
up

2.5.1 State Transitions

The CPU has five processing states: reset, exception processing, bus release, program execution, and power-down. Figure 2.6 shows the transitions between the states. See section 14, Power-Down Mode, for more information on the power-down mode.

picture Figure 2.6 Transitions between Processing States

Reset State: The CPU resets in the reset state. This occurs when the \RES pin level goes low. When the NMI pin is high, the result is a power-on reset; when it is low, a manual reset will occur.

Exception Processing State: The exception processing state is a transient state that occurs when exception processing sources such as resets or interrupts alter the CPU's processing state flow.

For a reset, the initial values of the program counter (PC) (execution start address) and stack pointer (SP) are fetched from the exception processing vector table and stored; the CPU then branches to the execution start address and execution of the program begins.

For an interrupt, the stack pointer (SP) is accessed and the program counter (PC) and status register (SR) are saved to the stack area. The exception service routine start address is fetched from the exception processing vector table; the CPU then branches to that address and the program starts executing, thereby entering the program execution state.

Program Execution State: In the program execution state, the CPU sequentially executes the program.

Power-Down State: In the power-down state, the CPU operation halts and power consumption declines. The SLEEP instruction places the CPU in the power-down state. This state has two modes: sleep mode and standby mode. See section 2.5.2 for more details.

Bus Release State: In the bus release state, the CPU releases access rights to the bus to the device that has requested them.

up
up

2.5.2 Power-Down State

Besides the ordinary program execution states, the CPU also has a power-down state in which CPU operation halts, lowering power consumption (table 2.19). There are two power-down state modes: sleep mode and standby mode.

Sleep Mode: When standby bit SBY (in the standby control register SBYCR) is cleared to 0 and a SLEEP instruction executed, the CPU moves from program execution state to sleep mode. The on-chip peripheral modules other than the CPU do not halt in the sleep mode. To return from sleep mode, use a reset, any interrupt, or a DMA address error; the CPU returns to the ordinary program execution state through the exception processing state.

Software Standby Mode: To enter the standby mode, set the standby bit SBY (in the standby control register SBYCR) to 1 and execute a SLEEP instruction. In standby mode, all CPU, on-chip peripheral module, and oscillator functions are halted. However, when entering the standby mode, confirm that the DMAC master enable bit is 0. If a multiplication instruction is in process at a standby, the MACL and MACH registers will be invalid. CPU internal register contents and on-chip RAM data are held. Cache (and on-chip RAM) data is not held.

To return from standby mode, use a reset or an external NMI interrupt. For resets, the CPU returns to ordinary program execution state through the exception processing state when placed in a reset state after the oscillator stabilization time has elapsed. For NMI interrupts, the CPU returns to ordinary program execution state through the exception processing state after the oscillator stabilization time has elapsed. Turn the cache off before entering standby. In this mode, power consumption drops substantially because the oscillator stops.

Module Standby Function: The module standby function is available for the multiplier (MULT), divider (DIVU), 16-bit free-running timer (FRT), serial communications interface (SCI), and the DMA controller (DMAC) for the on-chip peripheral modules.

The supply of the clock to these on-chip peripheral modules can be halted by setting the corresponding bits 4-0 (MSTP4-MSTP0) in the standby control register (SBYCR). By using this function, the power consumption can be reduced.

The external pins of the on-chip peripheral modules in module standby are reset and all registers except DMAC, MULT, and DIVU are initialized. (The master enable bit (bit 0) of the DMAC's DMAOR register is initialized to 0). Module standby function is cleared by clearing the MSTP4-MSTP0 bits to 0.

When MULT has entered the software standby mode, do not execute the DMULS.L, DMULU.L, MAC.L, MAC.W, MUL.L, MULS, and MULU instructions (all of which are multiplication instruction) or any instructions that access the MACH and MACL registers (CLRMAC, LDS MACH/MACL, STS MACH/MACL).

When module standby functions of DMAC are used, set the DMA master enable bit in the DMAC to 0.

Table 2.19 Power-Down State

-- -- State --



Mode


Conditions


Clock


CPU
On-Chip Peripheral Modules
CPU Registers


RAM


Canceling

Sleep mode Execute SLEEP instruction with SBY bit cleared to 0 in SBYCR Run Halt Run Held Held 1. Interrupt

2. DMA address error

3. Power-on reset

4. Manual reset


Standby mode Execute SLEEP instruction with SBY bit set to 1 in SBYCR Halt Halt Halt and initialize*1 Held Undefined 1. NMI

2. Power-on reset

3. Manual reset


Module standby function (SH7604 only) MSTP4-MSTP0 bits of SBYCR set to 1 Run Run (MULT is halted.) Supply of clock to affected module is halted and module initialized.*2 Held Held Clear bits MSTP 4-0 of SBYCR to 0

  1. Notes: 1. Differs depending on peripheral module and pin.
  2. 2. The DMAC, MULT, DIV registers and the specified interrupt vectors maintain their settings.

Return to the top.