=== page 1 === TOSHIBA TLCS-900/H CPU 900, 900/L, 900/H, 900/L1, 900/H2 CPU Core Different Points There are 5 type CPU core: ® 900, @ 900/L, ® 900/H, ® 900/L1, © 900/H2 in TLCS- 900 series and they are different from following points. Instruction Set TLCS-900 Deleted instruction Deleted instruction Deleted instruction NORMAL NORMAL NORMAL MAX MAX MAX Added instruction LDX MIN Code Fetch Only when branch, e e Even when not branch, CPU fetch branch CPU fetch branch destination code. destination code. Operation Mode Normal mode, System mode < < System mode Register Mode MIN mode, MIN mode, MAX mode < MAX mode, MAX mode, (MIN mode at reset) (MAX mode at reset) Normal Stack exist not exist oa ia Pointer (XNSP) Interrupt Nesting not exist exist e | Counter (INTNEST) Figure 1 CPU Different Points CPU900H-1 2001-03-16 === page 2 === TOSHIBA TLCS-900/H CPU 1. Outline The TLCS-900 series has an original Toshiba high-performance 16-bit CPU. Combining the CPU with various I/O function blocks (such as timers, serial I/Os, ADs) creates broad possibilities in application fields. The TLCS-900 CPU, being 16-bit CPU, has a 32-bit/16-bit register bank configuration, therefore it is suitable as an embedded controller. The TLCS-900 CPU features are as follows : (1)TLCS-90 extended architecture @ Upward compatibility on mnemonic and register set levels (2)General-purpose registers e All 8 registers usable as accumulator (3)Register bank system e four 32-bit register banks (4)16M-byte linear address space ; 9 types addressing modes (5)Dynamic bus sizing system @ Can consist 8- / 16-bit external data bus together ® Supporting only system mode (900/L, 900/H) (7)Orthogonal instruction sets @ 8-/16-/32-bit data transfer/arithmetic instructions @ 16-bit multiplication/division 16 X 16 to 32-bits (signed/unsigned) 32+ 16 to 16-bits -:- remainder 16-bits (signed/unsigned) e Bit processing including bit arithmetic @ Supporting instruction for C compiler e Filter calculations : multiplication-addition arithmetic, modulo increment instruction (8)High-speed processing @ Pipeline system with 4-byte instruction queue buffer @ 32-bit ALU CPU900H-2 2001-03-16 === page 3 === TOSHIBA TLCS-900/H CPU The 900/H has only system mode. In system mode, there are no restrictions on using instructions or registers. The CPU resources effective in system mode are as follows: 1) General-purpose registers @ Four 32-bit general-purpose registers X 4 banks e@ Four 32-bit general-purpose registers (including system stack pointer : XSP) 2) Status register (SR) 3) Program counter (PC): 32 bits 4) Control register: parameter register for micro DMA, etc. 5) All CPU instructions 6) All built-in I/O registers 7) All built-in memories CPU900H-3 2001-03-16 === page 4 === TOSHIBA TLCS-900/H CPU 3. Registers 3.1 Register Structure------ 16M-byte program area/ 16M-byte data area Figure 3.1.1 illustrates the format of registers. Four 32-bit general-purpose registers X 4 banks + Four 32-bit general-purpose registers + 32-bit program counter + Status register Register mode changing The bit in status register (SR) is initialized to “1” and set to Maximum mode by resetting. The 900/H has only Maximum mode. The stack pointer (SP) is provided for only System mode (XSP). The System stack pointer (XSP) is set to 100H by resetting. 4 bank eT an ——<—— ell 7 a i a XE ee cenerat | xuxf sd dT dt purpose F’ registers |__ 32 bits on Figure 3.1.1 Register Format (16M-byte program area) CPU900H-4 2001-03-16 === page 5 === TOSHIBA TLCS-900/H CPU 3.2 Register Details 3.2.1. General-purpose bank registers In maximum mode, the following four 32-bit general-purpose registers consisting of 4 banks can be used. The register format in a bank is shown below. Four 32-bit registers 32 bits. ———————_—————™ 16 bits —————> (XWA, XBC, XDE, and XHL) <— 8 bits —>|<— 8 bits | are general Purpose wees ww and can be used as an accumulators and index*®°|_ Ss Ci| SB) registers. They can also be E{ |] DE) used as 16-bit registers (WA, xu] | (HL) BC, DE, and HL), in which Note: Round brackets(_) signify 16-bit registers. case, the lower 16 bits of the 32-bit registers are assigned. 16-bit registers can be used as accumulators, index registers in index addressing mode, and displacement registers. They can also be used as two 8-bit general-purpose registers (W, A, B, C, D, E, H, and L) to function for example as accumulators. 3.2.2 32-bit General-purpose Registers The TLCS-900 series has four 32-bit general-purpose registers (XIX, XIY, XIZ, and XSP). The register format is shown below. These registers can also be -<—_—_—_——_—_———- 32-bit register —————————> : |<—— 16-bit Register ——> used as accumulators, index registers, and displacement 1X] SK registers. They can be used MY} registers are used as 8-bit registers are listed later. The XSP register is utilized for stack pointer. It is used when the interrupt is occured or “CALL”, “RET” instruction are executed. The stack pointer (XSP) is set to 100H by resetting. CPU900H-5 2001-03-16 === page 6 === TOSHIBA TLCS-900/H CPU 3.2.3 Status Register (SR) The status register contains flags indicating the status (operating mode, register format, etc.) of the CPU and operation results. This register consists of two parts. The upper byte of the status register (bits 8 to 15) indicates the CPU status. The lower byte (bits 0 to 7) are referred to as the flag register (F). This indicates the status of the operation result. The TLCS-900 series has two flag registers (F and F'). They can be switched using the EX instruction. (1) Upper Byte of Status Register ee —4 13 12 —0 9 8 Indicates the CPU operating mode, system or normal. 900/H has only system mode. Initialized to 1 (system mode) by reset. @ —IFF2 to IFFO (Interrupt mask Flip-Flop2 to 0) Mask registers with interrupt levels from 1 to 7. Level 7 has the highest priority. Any value can be set using the El instruction. Initialized to 111 by reset. | 000_fenablesinterruptswithlevel torhigher. = F010 [Enables interuptswith evel 2orhigher. 01+ [enablesinterruptswith level orhigher. When an interrupt is received, the mask register sets a value higher by 1 than the interrupt level received. When an interrupt with level 7 is received, 111 is set. Unlike with the TLCS-90 series, the EI instruction becomes effective immediately after execution. CPU900H-6 2001-03-16 === page 7 === TOSHIBA TLCS-900/H CPU @ MAX (MINimum /MAXimum) Bit used to specify the register mode which determines the sizes of the register banks and the program counter. Initialized to “1” (maximum mode) for 900/H by reset. 900/H does not have Minimum mode. Don’t set to “0”. @ __RFP2 to RFPO (Register File Pointer2 to 0) Indicates the number of register file (register bank) currently being used. Initialized to 000 by reset. The values in these registers can be operated on using the following three instructions. RFP2 is fixed to 0 in maximum mode. It remains 0 even if an attempt to change it to 1 using following instructions. e LDF imm ; RFP<—imm (0 to 3) (160 ns at 25 MHz) e INCF ; RFP 900/H CPU has only system mode. Only bits 14 to 12 @ El num A value of “num” is written. Only bit 11 “1" is always set, because 900/H CPU has only maximum mode. Only bits 10 to 8 @® LDF imm @ INCF @ DECF Only bits 7 to 0 @ PUSH F/POP F @ EX F, F’ @ A flag is set indirectly by executing arithmetic instructions etc. CPU900H-8 2001-03-16 === page 9 === TOSHIBA TLCS-900/H CPU 3.2.4 Program Counter (PC) The program counter is a pointer indicating the memory address to be executed next. In maximum mode, the program counter consists of 32 bits. The size of the program area depends on the number of the address pins that the product has. With 24 address pins (AO to A23), a maximum program area of 16M bytes can be accessed as a linear address space. In this case, the upper 8 bits of the program counter (bits 24 to 31) are ignored. The 900/H reads a value of a reset vector from a vector base address by reset and sets the value into a program counter. Then, program after the vector specified by the program counter are executed. 3.2.5 Control registers (CR) ppepspusipussussimesupeeseeeeme, | Control registersare ustrated below, , 1 T T Micro DMA source register ; T T T Micro DMA Micro DMA register ; SS wa a ct) | | Mig DMA pe MAMZ (DMA CZ2) | frregister ()__: Word register name (16 bits) eG ser Nesteg <> : Long word register name (32 bits) SEM For micro DMA, refer to “Chapter 4 TLCS-900/H LSI Devices”. CPU900H-9 2001-03-16 === page 10 === TOSHIBA TLCS-900/H CPU 3.3 Register Bank Switching Register banks are classified into the following three types. Current bank registers Previous bank registers Absolute bank registers The current bank is indicated by the register file pointer, , (status register bits 8 to 10). The registers in the current bank are used as general-purpose registers, as described in the previous section. By changing the contents of the , another register bank becomes the current register bank. The previous bank is indicated by the value obtained by subtracting 1 from the . For example, if the current bank is bank 3, bank 2 is the previous bank. The names of registers in the previous bank are indicated with a dash (WA', BC’, DE', HL’). The EX instruction (EX A,A') is used to switch between current and previous banks. All bank registers, including the current and previous ones, have a numerical value (absolute bank number) to indicate the bank. With a register name which includes a numerical value such as RWO, RAO, etc., all bank registers can be used. These registers (that is, all registers) are called absolute bank registers. The TLCS-900 series CPU is designed to perform optimally when the current bank registers are operated as the working registers. In other words, if the CPU uses other bank registers, its performance degrades somewhat. In order to obtain maximum CPU efficiency, the TLCS-900 series has a function which easily switches register banks. The bank switching function provides the following advantages: ° Optimum CPU operating efficiency ° Reduced programming size (Object codes) ° Higher response speed and reduced programming size when used as a context switch for an interrupt service routine. Bank switching is performed by the instructions listed below. LDF imm: Sets the contents of the immediate value in . imm: 0to3 INCF : Increments by 1. DECF : Decrements by 1. The immediate values used by the LDF instruction are from 0 to 3. If a carry or borrow occurs when the INCF or DECF instruction is executed, it is ignored. The value of the rotates. For example, if the INCF instruction is executed with bank 3, the result is bank 0. If the DECF instruction is executed with bank 0, the result is bank 3. Note that careless execution of the INCF or DECF instruction may destroy the contents of the register bank. CPU900H-10 2001-03-16 === page 11 === TOSHIBA TLCS-900/H CPU e Example of Register Bank Usage The TLCS-900 series registers are formatted in banks. Banks can be used for processing objectives or interrupt levels. Two examples are given below. When assigning register banks to interrupt processing routines. Register bank 0 = Used for the main program and interrupt processing other than that shown below. Register bank 1 = Used for processing INTO. Register bank 2 = Used for processing timer 0. Register bank 3 = Used for processing timer 1. For example, if a timer 1 interrupt occurs during main program execution, processing jumps to a subroutine as follows. PUSH/POP processing for the register is unnecessary. LDF 3 ; Sets register bank to 3. 0.16 us (at 25 MHz) RETI ; Returns to previous status including . 0.96 us (at 25 MHz) When assigning register banks to their appropriate interrupt level nesting. Main Interrupt Interrupt Interrupt 1/7 Notel : In the above example, when interrupt nesting exceeds the number of register banks (4), the becomes 000 and the contents of register bank 0 are destroyed. Note2 : TheINCF instruction is used to execute < + 1. 0.16 us (at 25 MHz) CPU900H-11 2001-03-16 === page 12 === TOSHIBA TLCS-900/H CPU 3.4 Accessing General-purpose Registers The register access code is formatted in a varied code length on byte basis. The current bank registers can be accessed by the shortest code length. All general-purpose registers can be accessed by an instruction code which is 1 byte longer. General-purpose registers are as follows. @® General-purpose registers in current bank QB Qi BC Qc BB BIC C () : Word register name (16 bits) < > : Long word register name (32 bits) @ General-purpose registers in previous bank QB’ Q'BC’) QC’ BB’ BC’) C’ @ 32-bit general-purpose registers QSPH 0 1SP QSPL__ SPH S iP) SPL CPU900H-12 2001-03-16 === page 13 === TOSHIBA TLCS-900/H CPU @ Absolute bank registers oi pow ss oi () : Word register name (16 bits) < > : Long word register name (32 bits) CPU900H-13 2001-03-16 === page 14 === TOSHIBA TLCS-900/H CPU 4. Addressing Modes The TLCS-900 series has nine addressing modes. These are combined with most instructions to improve CPU processing capabilities. TLCS-900 series addressing modes are listed below. They cover the entire TLCS-90 addressing modes. [ee [aa 1. Register reg8 reg16 reg32 2. Immediate ns ni6 n32 Register indirect (-reg) pre-decrement Register indirect (reg +) post-increment Index (reg + d8) {reg + d16) 7. Register index (reg + reg8) (reg + reg 16) Absolute (n8) (Direct addressing mode) (n16) (n24) Relative (PC + d8) (PC +d 16) reg8 :All8-bit registers such as W, A, B, C, D, E, H, L, ete. reg 16 : All 16-bit registers such as WA, BC, DE, HL, IX, IY, IZ, SP, ete. reg 32. : All 32-bit registers such as XWA, WBC, XDE, XHL, XIX, XIY, XIZ, XSP, etc. reg :All32-bit registers such as XWA, WBC, XDE, XHL, XIX, XIY, XIZ, XSP, etc. d8 :8-bit displacement (— 80H to + 7FH) d16 :16-bit displacement (—8000H to + 7FFFH) n8& :8-bit constant (00H to FFH) n16 :16-bit constant (0000H to FFFFH) n32 : 82-bit constant (00000000H to FFFFFFFFH) Note: Relative addressing mode can only be used with the following instructions: LDAR, JR, JRL, DJNZ, and CALR CPU900H-14 2001-03-16 === page 15 === TOSHIBA TLCS-900/H CPU (1) Register Addressing Mode In this mode, the operand is the specified register. Example: LD HL,IX CPU n mx The IX register contents, 1234H, are loaded to the HL register. (2) Immediate Addressing Mode In this mode, the operand is in the instruction code. Example: LD HL,5678H Program code (OP code) n Lt 56 The immediate data, 5678H, is loaded to the HL register. CPU900H-15 2001-03-16 === page 16 === TOSHIBA TLCS-900/H CPU (3) Register Indirect Addressing Mode In this mode, the operand is the memory address specified by the contents of the register. Example 1: LD, HL, (XIX) Memory HL —|_33_| Address 345678H ~-, Address 345679H |! Memory data, 2233H, at address 345678H is loaded to the HL register. Example 2: LD HL,(XBC) Memory HL|4.455 | —{55_| Address 345678H <- | 44 | Address345679H If a bank register (XWA, XBC, XDE, or XHL) is used for addressing, the values of bits 0 to 23 are output to the address bus. CPU900H-16 2001-03-16 === page 17 === TOSHIBA TLCS-900/H CPU (4) Register Indirect Pre-decrement Addressing Mode In this mode, the contents of the register is decremented by the pre-decrement values. In this case, the operand is the memory address specified by the decremented register. Example 1: LD HL, (— XIX) Memory HL }—|_77_| Address 345676H =~, Previous | 66 | Address 345677H_ ! XIX ~ O—2| ! Current The pre-decrement values are as follows: When the size of the operand is one byte (8 bits): —1 When the size of the operand is one word (16 bits): —2 When the size of the operand is one long word (82 bits): —4 Example 2: LD XIX,(-XBC) Memory XIX 55 Address 33FFFEH <-- Address 33FFFFH aa 3 Previous -—[_33_|Address 3400001 | XBC Address 340001H_—s! eH} BS XBC CPU900H-17 2001-03-16 === page 18 === TOSHIBA TLCS-900/H CPU (5) Register Indirect Post-increment Addressing Mode In this mode, the operand is the memory address specified by the contents of the register. After the operation, the contents of the register are incremented by the size of the operand. Example 1: LD HL,(XIX +) Memory HL|8 899 199 Address 345678H ~<~1 Address 345679H | Previous XIX TT A ! Example 2: LD A,(XBC +) Memory A [55 | Address 345678H ~<-- @ {1 | beeen eee eee eee eee! CPU900H-18 2001-03-16 === page 19 === TOSHIBA TLCS-900/H CPU (6) Index Addressing Mode In this mode, the operand is the memory address obtained by adding the contents of the specified register to the 8- or 16-bit displacement value in the instruction code. Example 1: LD HL,(XIX + 13H) Memory HL {66 _| Address 345683H <-, | 55 | Address345684H =! bi] : Example 2: LD HL,(XBC-1000H) Memory = a HL 66 Address 33F000H <-- A FOOIH st xBC | 55 | ddress 33F00 | b[r000) - ! The displacement values range from —8000H to + 7FFFH. CPU900H-19 2001-03-16 === page 20 === TOSHIBA TLCS-900/H CPU (7) Register Index Addressing Mode The operand is the memory address obtained by adding the contents of the register specified to the base and the register specified to the displacement (signed 8- or 16-bit integer). Example 1: LD HL,(XIX + A) Memory HL[2 2 33 | {33 | Address 345666H <-y Address 34566FH | bis : Example 2: LD HL,(XBC + DE) Memory “ fi“ HL {33 _| Address 347678H ~--» Address 347679H — | [Loa oo : The range of displacement is: — 80H ~ 7FH in case of 8-bit and —8000H ~ + 7FFFH in case of 16-bit. CPU900H-20 2001-03-16 === page 21 === TOSHIBA TLCS-900/H CPU (8) Absolute Addressing Mode In this mode, the operand is the memory address specified by 1 to 3 bytes in the instruction code. Addresses 000000H to OOOOFFH can be specified by 1 byte. Addresses 000000H to OOFFFFH can be specified by 2 bytes. Addresses 000000H to FFFFFFH can be specified by 3 bytes. In this mode, addressing to 256-byte area (0H to FFH) which can be specified by 1 byte is called the direct addressing mode. In the direct addressing mode, a program memory area and execution time can be cut down. Example 1: LD HL,(80H) Memory HL[2 233 | 33 Address 000080H Address 000081H Example 2: LD HL,(1234H) Memory HL[4455 | a Address 001234H | 44 | Address 001235H Example 3: LD HL,(56789AH) Memory HL[6 6 77 | —[ 7 Address 56789AH | 66 | Address 56789BH CPU900H-21 2001-03-16 === page 22 === TOSHIBA TLCS-900/H CPU (9) Relative Addressing Mode In this mode, the operand is the memory address obtained by adding the 8- or 16-bit displacement value to the address where the instruction code being executed is located. In this mode, only the following five instructions can be used. LDAR R,$+4+d16 JR ec, $+2+d8 JRL ec, $+34+d16 CALR $+3+d16 DJNZ r,$+3+4+d8 ($ : start address of instruction code) In calculating the displacement object code value, the adjustment value (+2 to +4) depends on the instruction type. Example 1: JR 2034H Memory JR instruction code —>| 68 | Address 2000H Displacement Address 2001H In the above example, the displacement object code value is: 2034H — (2000H + 2) = 32H. CPU900H-22 2001-03-16