|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
S3FB42F 8-BIT CMOS MICROCONTROLLER USER'S MANUAL Revision 1 Important Notice The information in this publication has been carefully checked and is believed to be entirely accurate at the time of publication. Samsung assumes no responsibility, however, for possible errors or omissions, or for any consequences resulting from the use of the information contained herein. Samsung reserves the right to make changes in its products or product specifications with the intent to improve function or design at any time and without notice and is not required to update this documentation to reflect such changes. This publication does not convey to a purchaser of semiconductor devices described herein any license under the patent rights of Samsung or others. Samsung makes no warranty, representation, or guarantee regarding the suitability of its products for any particular purpose, nor does Samsung assume any liability arising out of the application or use of any product or circuit and specifically disclaims any and all liability, including without limitation any consequential or incidental damages. "Typical" parameters can and do vary in different applications. All operating parameters, including "Typicals" must be validated for each customer application by the customer's technical experts. Samsung products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, for other applications intended to support or sustain life, or for any other application in which the failure of the Samsung product could create a situation where personal injury or death may occur. Should the Buyer purchase or use a Samsung product for any such unintended or unauthorized application, the Buyer shall indemnify and hold Samsung and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, expenses, and reasonable attorney fees arising out of, either directly or indirectly, any claim of personal injury or death that may be associated with such unintended or unauthorized use, even if such claim alleges that Samsung was negligent regarding the design or manufacture of said product. S3FB42F 8-Bit CMOS Microcontroller User's Manual, Revision 1 Publication Number: 21-S3-FB42F-052001 (c) 2001 Samsung Electronics All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electric or mechanical, by photocopying, recording, or otherwise, without the prior written consent of Samsung Electronics. Samsung Electronics' microcontroller business has been awarded full ISO-14001 certification (BVQ1 Certificate No. 9330). All semiconductor products are designed and manufactured in accordance with the highest quality standards and objectives. Samsung Electronics Co., Ltd. San #24 Nongseo-Lee, Kiheung-Eup Yongin-City Kyungi-Do, Korea C.P.O. Box #37, Suwon 449-900 TEL: (82)-(331)-209-1907 FAX: (82)-(331)-209-1889 Home-Page URL: Http://www.samsungsemi.com/ Printed in the Republic of Korea Preface The S3FB42F Microcontroller User's Manual is designed for application designers and programmers who are using the S3FB42F microcontroller for application development. It is organized in two main parts: Part I Programming Model Part II Hardware Descriptions Part I contains software-related information to familiarize you with the microcontroller's architecture, programming model, instruction set, and interrupt structure. It has nine chapters: Chapter 1 Chapter 2 Chapter 3 Chapter 4 Product Overview Address Spaces Register Memory Map Chapter 5 Chapter 6 Chapter 7 Chapter 8 Hardware Stack Exceptions Coprocessor Interface Instruction Set Chapter 1, "Product Overview," is a high-level introduction to S3FB42F with general product descriptions, as well as detailed information about individual pin characteristics and pin circuit types. Chapter 2, "Address Spaces," describes program and data memory spaces. Chapter 2 also describes ROM code option. Chapter 3, "Register," describes the special registers. Chapter 4, "Memory Map," describes the internal register file. Chapter 5, "Hardware Stack," describes the S3FB42F hardware stack structure in detail. Chapter 6, "Exception," describes the S3FB42F exception structure in detail. Chapter 7, "Coprocessor Interface," describes the S3FB42F coprocessor interface in detail. Chapter 8, "Instruction Set," describes the features and conventions of the instruction set used for all S3FB-series microcontrollers. A basic familiarity with the information in Part I will help you to understand the hardware module descriptions in Part II. If you are not yet familiar with the S3FB-series microcontroller family and are reading this manual for the first time, we recommend that you first read Chapters 1-3 carefully. Then, briefly look over the detailed information in Chapters 4, 5, 6, 7, and 8. Later, you can reference the information in Part I as necessary. Part II "hardware Descriptions," has detailed information about specific hardware components of the S3FB42F microcontroller. Also included in Part II are electrical, mechanical. It has 19 chapters: Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18 PLL (Phase Locked Loop) Reset and Power-Down I/O Ports Basic Timer Real Timer (Watch Timer) 16-bit Timer (8-bit Timer A & B) Serial I/O Interface UART I2S Bus (Inter-IC Sound) SSFDC (Solid State Floppy Disk Card) Chapter 19 Chapter 20 Chapter 21 Chapter 22 Chapter 23 Chapter 24 Chapter 25 Chapter 26 Chapter 27 Parallel Port Interface 8-bit Analog-to-Digital Converter I2C-BUS Interface Random Number Generator USB Embedded Flash Memory Interface MAC2424 Electrical Data Mechanical Data Chapter 25, "MAC2424" describes the MAC2424 structure in detail, as well as instructions. S3FB42F MICROCONTROLLER iii One order form is included at the back of this manual to facilitate customer order for S3FB42F microcontrollers: the Flash Factory Writing Order Form. You can photocopy this form, fill it out, and then forward it to your local Samsung Sales Representative. iv KS86C6204/C6208/P6208 (Preliminary Spec) Table of Contents Part I -- Programming Model Chapter 1 Product Overview Calmrisc Overview ...............................................................................................................................1-1 Features .............................................................................................................................................1-1 Pin Description....................................................................................................................................1-9 Pin Circuit Diagrams............................................................................................................................1-13 Chapter 2 Address Spaces Overview .............................................................................................................................................2-1 Program Memory (ROM) ......................................................................................................................2-2 Data Memory Organization...................................................................................................................2-3 Chapter 3 Register Overview .............................................................................................................................................3-1 Index Registers: IDH, IDL0 and IDL1..............................................................................................3-2 Link Registers: ILX, ILH and ILL ....................................................................................................3-2 Status Register 0: SR0 ................................................................................................................3-3 Status Register 1: SR1 ................................................................................................................3-4 Chapter 4 Memory Map Overview .............................................................................................................................................4-1 Chapter 5 Hardware Stack Overview .............................................................................................................................................5-1 S3FB42F MICROCONTROLLER v Table of Contents (Continued) Chapter 6 Exceptions Overview .............................................................................................................................................6-1 Hardware Reset...........................................................................................................................6-1 Nmi Exception (Edge Sensitive)....................................................................................................6-2 IRQ[0] Exception (Level-Sensitive).................................................................................................6-2 IRQ[1] Exception (Level-Sensitive).................................................................................................6-2 Hardware Stack Full Exception.....................................................................................................6-2 Break Exception..........................................................................................................................6-2 Exceptions (or Interrupts).............................................................................................................6-3 Interrupt Mask Registers ..............................................................................................................6-5 Interrupt Priority Register..............................................................................................................6-6 Chapter 7 Coprocessor Interface Overview .............................................................................................................................................7-1 Chapter 8 Instruction Set Overview .............................................................................................................................................8-1 Glossary.....................................................................................................................................8-1 Instruction Set Map .............................................................................................................................8-2 Quick Reference..................................................................................................................................8-9 Instruction Group Summary ..................................................................................................................8-12 ALU Instructions..........................................................................................................................8-12 Shift/Rotate Instructions ...............................................................................................................8-16 Load Instructions .........................................................................................................................8-18 Branch Instructions......................................................................................................................8-21 Bit Manipulation Instructions.........................................................................................................8-25 Miscellaneous Instruction.............................................................................................................8-26 Pseudo Instructions .....................................................................................................................8-29 vi S3FB42F MICROCONTROLLER Table of Contents (Continued) Part II -- Hardware Descriptions Chapter 9 PLL (Phase Locked Loop) Overview .............................................................................................................................................9-1 PLL Register Description......................................................................................................................9-2 PLL Control Register (PLLCON)....................................................................................................9-2 PLL Frequency Divider Data Register (PLLDATA)...........................................................................9-2 System Control Circuit.........................................................................................................................9-4 Oscillator Control Register (OSCCON)...........................................................................................9-4 Power Control Register (PCON) ....................................................................................................9-5 Chapter 10 Reset and Power-Down Overview .............................................................................................................................................10-1 Chapter 11 I/O Ports Port Data Registers .............................................................................................................................11-1 Port Control Registers..........................................................................................................................11-2 Port 0 Control Register (P0CON)...................................................................................................11-2 Port 1 Control Register (P1CON)...................................................................................................11-2 Port 2 Control Low Register (P2CONL) ..........................................................................................11-3 Port 2 Control High Register (P2CONH).........................................................................................11-4 Port 3 Control Low Register (P3CONL) ..........................................................................................11-5 Port 3 Control High Register (P3CONH).........................................................................................11-6 Port 3 Pull-Up Register (P3PUR)...................................................................................................11-6 Port 4 Control Register (P4CON)...................................................................................................11-7 Port 4 Interrupt Control Register (P4INTCON) .................................................................................11-7 Port 4 Interrupt Mode Register (P4INTMOD)...................................................................................11-8 Port 5 Control Register (P5CON)...................................................................................................11-8 Port 5 Pull-Up Register (P5PUR)...................................................................................................11-9 Port 5 Interrupt Control Register (P5INTCON) .................................................................................11-9 Port 5 External Interrupt Pending Register (EINTPND).....................................................................11-9 Port 5 Interrupt Mode Low Register (P5INTMODL) ..........................................................................11-9 Port 5 Interrupt Mode High Register (P5INTMODH) .........................................................................11-10 Port 6 Control Register (P6CON)...................................................................................................11-11 Port 2 Control High Register Or P6pur (P2CONH)...........................................................................11-12 Port 7 Control Register (P7CON)...................................................................................................11-12 Port 8 Control Register (P8CON)...................................................................................................11-13 Port 9 Control Register (P9CON)...................................................................................................11-14 S3FB42F MICROCONTROLLER vii Table of Contents (Continued) Chapter 12 Basic Timer Overview .............................................................................................................................................12-1 Watchdog Timer..................................................................................................................................12-2 Block Diagram ............................................................................................................................12-3 Chapter 13 Real Timer (Watch Timer) Overview .............................................................................................................................................13-1 Watch Timer Circuit Diagram........................................................................................................13-2 Chapter 14 16-bit Timer (8-bit Timer A & B) Overview .............................................................................................................................................14-1 Chapter 15 Serial I/O Interface Overview .............................................................................................................................................15-1 SIO Pre-Scaler Register (SIOPS)..........................................................................................................15-2 Block Diagram ....................................................................................................................................15-2 Serial I/O Timing Diagram.....................................................................................................................15-3 Chapter 16 UART Overview .............................................................................................................................................16-1 UART Special Registers.......................................................................................................................16-2 UART Line Control Register..........................................................................................................16-2 UART Control Register.................................................................................................................16-3 UART Status Register..................................................................................................................16-4 UART Transmit Buffer Register .....................................................................................................16-5 UART Receive Buffer Register.......................................................................................................16-5 UART Baud Rate Prescaler Registers ...........................................................................................16-6 UART Interrupt Pending Register (Upend) ......................................................................................16-6 viii S3FB42F MICROCONTROLLER Table of Contents (Continued) Chapter 17 I2S Bus (Inter-IC Sound) Overview .............................................................................................................................................17-1 The I2S Bus ........................................................................................................................................17-2 I2S Special Register Description ...........................................................................................................17-6 I2S Control Registers ...................................................................................................................17-6 I2S Control Registers (IISCON) .....................................................................................................17-6 I2S Mode Registers (IISMODE).....................................................................................................17-8 I2S Pointer Registers (IISPTR) ......................................................................................................17-9 I2S Buffer Registers (IISBUF)........................................................................................................17-9 Chapter 18 SSFDC (Soild State Floppy Disk Card) Overview .............................................................................................................................................18-1 SSFDC Register Description ................................................................................................................18-3 Smartmedia Control Register (SMCON).........................................................................................18-3 Smartmedia Ecc Count Register (ECCNT) ....................................................................................18-3 Smartmedia Ecc Data Register (ECCDATA) ..................................................................................18-4 Smartmedia Ecc Result Data Register (ECCRST) ..........................................................................18-4 Chapter 19 Parallel Port Interface Overview .............................................................................................................................................19-1 PPIC Operating Modes ................................................................................................................19-2 PPIC Special Registers........................................................................................................................19-5 Parallel Port Data/Command Data Register....................................................................................19-5 Parallel Port Status Control And Status Register............................................................................19-6 Parallel Port Control Register........................................................................................................19-8 Parallel Port Interrupt Event Registers ...........................................................................................19-11 Parallel Port Ack Width Register...................................................................................................19-12 Chapter 20 8-bit Analog-to-Digital Converter Overview .............................................................................................................................................20-1 Function Description............................................................................................................................20-1 Conversion Timing ...............................................................................................................................20-2 A/D C Special Registers ......................................................................................................................20-3 A/D C Control Registers ...............................................................................................................20-3 A/D Converter Data Registers .......................................................................................................20-3 S3FB42F MICROCONTROLLER ix Table of Contents (Continued) Chapter 21 I2C Bus Interface Overview .............................................................................................................................................21-1 Functional Description .................................................................................................................21-2 2C Special Registers...........................................................................................................................21-3 I Multi-Master I2C-Bus Control Register ...........................................................................................21-3 Multi-Master I2C-Bus Control/Status Register (IICSR) .....................................................................21-4 Multi-Master I2C-Bus Transmit/Receive Data Register (IICDATA)......................................................21-5 Multi-Master I2C-Bus Address Register (IICADDR)..........................................................................21-5 Prescaler Counter Register (IICCNT)..............................................................................................21-6 Chapter 22 Random Number Generator Overview .............................................................................................................................................22-1 Functional Description .................................................................................................................22-3 Random Number Control Register .................................................................................................22-3 Ring Oscillator ............................................................................................................................22-4 Linear Feedback Shift Register 8 (LFSR8) .....................................................................................22-5 Linear Feedback Shift Register 16 (LFSR16)..................................................................................22-5 Chapter 23 USB USB Peripheral Features.....................................................................................................................23-1 Functional Specification ...............................................................................................................23-1 USB Module Block Diagram .................................................................................................................23-2 Function Description............................................................................................................................23-3 USB Function Registers Description .....................................................................................................23-5 USB Releated Registers ......................................................................................................................23-6 Chapter 24 Embedded Flash Memory Interface Overview .............................................................................................................................................24-1 Tool Program Mode .....................................................................................................................24-1 Flash Memory Control Register.....................................................................................................24-3 x S3FB42F MICROCONTROLLER Table of Contents (Continued) Chapter 25 MAC2424 Introduction.........................................................................................................................................25-1 Architecture Features ..........................................................................................................................25-2 Block Diagram ....................................................................................................................................25-3 I/O Description ....................................................................................................................................25-4 Programming Model.............................................................................................................................25-6 Multiplier and Accumulator Unit ....................................................................................................25-7 Arithmetic Unit ............................................................................................................................25-11 Status Register 1 (MSR1) ............................................................................................................25-16 Ram Pointer Unit.................................................................................................................................25-18 Address Modification ...................................................................................................................25-18 Data Memory Spaces and Organization.........................................................................................25-23 Arithmetic Unit ....................................................................................................................................25-24 A, B Accumulators ......................................................................................................................25-25 Overflow Protection in A/B Accumulators .......................................................................................25-25 Arithmetic Unit ............................................................................................................................25-26 External Condition Generation Unit................................................................................................25-27 Status Register 0 (MSR0) ............................................................................................................25-27 Status Register 2 (MSR2) ............................................................................................................25-30 Barrel Shifter and Exponent Unit ...........................................................................................................25-31 Barrel Shifter...............................................................................................................................25-32 Exponent Block...........................................................................................................................25-35 Instruction Set Map and Summary ........................................................................................................25-37 Addressing Modes.......................................................................................................................25-37 Instruction Coding........................................................................................................................25-42 Quick Reference..........................................................................................................................25-55 Quick Reference..........................................................................................................................25-56 Instruction Set.....................................................................................................................................25-60 Glossary.....................................................................................................................................25-60 Instruction Description .................................................................................................................25-61 Chapter 26 Electrical Data Overview .............................................................................................................................................26-1 Chapter 27 Mechanical Data Overview .............................................................................................................................................27-1 S3FB42F MICROCONTROLLER xi List of Figures Figure Number 1-1 1-2 1-3 1-4 1-5 1-6 1-7 1-8 1-9 1-10 1-11 1-12 1-13 1-14 1-15 2-1 2-2 2-3 2-4 2-5 3-1 4-1 5-1 5-2 5-3 5-4 5-5 6-1 6-2 6-3 6-4 Title Page Number Top Block Diagram ..............................................................................................1-3 CalmRISC Pipeline Diagram .................................................................................1-4 CalmRISC Pipeline Stream Diagram......................................................................1-5 Block Diagram ....................................................................................................1-6 100-QFP Pin Assignment.....................................................................................1-7 100-TQFP Pin Assignment ...................................................................................1-8 Pin Circuit Type 1 (Port 0, P1.0-P1.4, P6.0-P6.5, and Port 7) ..................................1-13 Pin Circuit Type 2 (P6.6 and P6.7) ........................................................................1-13 Pin Circuit Type 3 (P4.2) ......................................................................................1-14 Pin Circuit Type 4 (Port 2, Port 8, and Port 9) ........................................................1-15 Pin Circuit Type 5 (Port 3) ....................................................................................1-15 Pin Circuit Type 6 (P4.0, and P4.1) .......................................................................1-16 Pin Circuit Type 7 (Port 5) ....................................................................................1-16 Pin Circuit Type 8 (RESET) ..................................................................................1-17 Pin Circuit Type 9 (TEST) .....................................................................................1-17 Flash Memory (Code Memory Area)......................................................................2-2 Data Memory Map...............................................................................................2-3 Data Memory Map in CalmRISC Side....................................................................2-4 Data Memory Map in MAC-2424 Side....................................................................2-5 Data Memory Map...............................................................................................2-6 Bank Selection by Setting of GRB Bits and IDB Bit ................................................3-3 Memory Map Area...............................................................................................4-1 Hardware Stack...................................................................................................5-1 Even and Odd Bank Selection Example.................................................................5-2 Stack Operation with PC [19:0].............................................................................5-3 Stack Operation with Registers.............................................................................5-4 Stack Overflow ....................................................................................................5-5 Interrupt Structure................................................................................................6-3 Interrupt Structure................................................................................................6-4 Interrupt Mask Register........................................................................................6-5 Interrupt Priority Register......................................................................................6-6 S3FB42F MICROCONTROLLER xiii List of Figures (Continued) Figure Number 7-1 7-2 9-1 9-2 9-3 11-1 12-1 12-2 12-3 12-4 13-1 14-1 14-2 14-3 15-1 15-2 15-3 15-4 15-5 16-1 16-2 Title Page Number Coprocessor Interface Diagram .............................................................................7-1 Coprocessor Instruction Pipeline...........................................................................7-3 Simple Circuit Diagram ........................................................................................9-1 PLL Frequency Divider Data Register (PLLDATA)...................................................9-3 System Clock Circuit Diagram..............................................................................9-6 Port Data Register Structure.................................................................................11-1 Basic Timer Control Register (BTCON) ..................................................................12-1 Watchdog Timer Control Register (WDTCON) ........................................................12-2 Watchdog Timer Enable Register (WDTEN) ...........................................................12-2 Basic Timer & Watchdog Timer Functional Block Diagram ......................................12-3 Watch Timer Circuit Diagram................................................................................13-2 Timer A Control Register (TACON) ........................................................................14-1 Timer B Control Register (TBCON) ........................................................................14-2 Timer A, B Function Block Diagram ......................................................................14-3 Serial I/O Module Control Registers (SIOCON) .......................................................15-1 SIO Pre-scaler Register (SIOPS) ..........................................................................15-2 SIO Function Block Diagram ................................................................................15-2 Serial I/O Timing in Transmit/Receive Mode (Tx at falling, SIOCON.4=0)...................15-3 Serial I/O Timing in Transmit/Receive Mode (Tx at rising, SIOCON.4=1) ...................15-3 UART Block Diagram...........................................................................................16-1 UART Line Control Register (LCON) ......................................................................16-2 17-1 17-2 17-3 17-4 17-5 18-1 18-2 Simple System Configuration................................................................................17-1 I2S Basic Interface Format (Phillips)......................................................................17-2 LSI Interface Format (Sony)..................................................................................17-2 Timing for I2S Transmitter.....................................................................................17-4 Timing for I2S Receiver.........................................................................................17-4 Simple System Configuration................................................................................18-2 ECC Processor Block Diagram.............................................................................18-5 xiv S3FB42F MICROCONTROLLER List of Figures (Continued) Figure Number 19-1 19-2 19-3 20-1 21-1 21-2 21-3 22 -1 22-2 23-1 23-2 23-3 23-4 23-5 23-6 23-7 23-8 23-9 23-10 23-11 23-12 23-13 23-14 23-15 23-16 23-17 23-18 24-1 24-2 Title Page Number Compatibility Hardware Handshaking Timing ..........................................................19-3 ECP Hardware Handshaking Timing (Forward)........................................................19-4 ECP Hardware Handshaking Timing (Reverse)........................................................19-4 A/D C Block Diagram...........................................................................................20-2 I2C-Bus Block Diagram ........................................................................................22-1 Multi-Master I2C-Bus Tx/Rx Data Register (IICDATA)..............................................22-5 Multi-Master I2C-Bus Address Register (IICADDR)..................................................22-6 Top Block Diagram of Random Number Generator ..................................................22-2 Ring Oscillator Block ...........................................................................................22-4 USB Module Block Diagram .................................................................................23-2 Function Address Register ...................................................................................23-6 Power Management Register................................................................................23-7 Frame Number Low Register ................................................................................23-8 Frame Number High Register................................................................................23-8 Interrupt Pending Register ....................................................................................23-9 Interrupt Enable Register......................................................................................23-11 Endpoint Index Register .......................................................................................23-12 Endpoint Direction Register ..................................................................................23-12 EP0 CSR Register (EP0CSR)...............................................................................23-14 INCSR Register...................................................................................................23-16 OUT Control Status Register ................................................................................23-18 IN MAX Packet Register (INMAXP)........................................................................23-19 OUT MAX Packet Register ...................................................................................23-20 EP0 MAX Packet Register ...................................................................................23-21 Write Counter LO Regsiter ...................................................................................23-22 Write Counter HI Register.....................................................................................23-22 USB Enable Register...........................................................................................23-24 Flash memory structure .......................................................................................24-2 Flash Memory Control Register.............................................................................24-4 S3FB42F MICROCONTROLLER xv List of Figures (Continued) Figure Number 25-1 25-2 25-3 25-4 25-5 25-6 25-7 25-8 25-9 25-10 25-11 25-12 25-13 25-14 25-15 25-16 25-17 25-18 25-19 25-20 25-21 26-1 26-2 26-3 26-4 26-5 26-6 27-1 27-2 Title Page Number MAC2424 Block Diagram .....................................................................................25-3 MAC2424 Pin Diagram.........................................................................................25-4 Multiplier and Accumulator Unit Block Diagram ......................................................25-7 MAU Registers Configuration................................................................................25-10 Integer Division Example ......................................................................................25-13 Fractional Division Example..................................................................................25-14 MSR1 Register Configuration................................................................................25-16 RAM Pointer Unit Block Diagram ..........................................................................25-19 Pointer Register and Index Register Configuration...................................................25-20 Modulo Control Register Configuration ...................................................................25-21 Data Memory Space Map.....................................................................................25-23 Arithmetic Unit Block Diagram..............................................................................25-24 Ai Accumulator Register Configuration...................................................................25-25 MSR0 Register Configuration................................................................................25-27 MSR2 Register Configuration................................................................................25-30 Barrel Shifter and Exponent Unit Block Diagram.....................................................25-31 Various Barrel Shifter Instruction Operation............................................................25-34 Indirect Addressing Example I (Read Operation).....................................................25-37 Indirect Addressing Example II (Write Operation)....................................................25-38 Short Direct Addressing Example .........................................................................25-39 Long Direct Addressing Example ..........................................................................25-40 Input Timing for External Interrupts (Port 4, Port5)...................................................26-3 Input Timing for RESET........................................................................................26-3 Stop Mode Release Timing When Initiated by a RESET..........................................26-6 Stop Mode Release Timing When Initiated by Interrupts..........................................26-7 Serial Data Transfer Timing...................................................................................26-8 Clock Timing Measurement at XIN.........................................................................26-11 100-QFP-1420C Package Dimensions...................................................................27-1 100-TQFP-1414 Package Dimensions ...................................................................27-2 xvi S3FB42F MICROCONTROLLER List of Tables Table Number 1-1 3-1 3-2 3-3 4-1 6-1 7-1 8-1 8-2 8-3 8-4 8-5 8-6 8-7 8-8 8-9 9-1 9-2 11-1 13-1 17-1 17-2 17-3 Title Page Number S3FB42F Pin Descriptions (100-TQFP) .................................................................1-9 General and Special Purpose Registers.................................................................3-1 Status Register 0: SR0 ........................................................................................3-3 Status Register 1: SR1 ........................................................................................3-4 Registers ............................................................................................................4-1 Exceptions .........................................................................................................6-1 Coprocessor instructions......................................................................................7-2 Instruction Notation Conventions ...........................................................................8-1 Overall Instruction Set Map...................................................................................8-2 Instruction Encoding ............................................................................................8-4 Index Code Information ("idx")...............................................................................8-7 Index Modification Code Information ("mod")...........................................................8-7 Condition Code Information ("cc")..........................................................................8-7 "ALUop1" Code Information ..................................................................................8-8 "ALUop2" Code Information ..................................................................................8-8 "MODop1" Code Information .................................................................................8-8 PLL Register Description......................................................................................9-2 System Control Circuit Register Description...........................................................9-4 Port Data Register Summary ................................................................................11-1 Watch Timer Control Register (WTCON): 8-Bit R/W................................................13-1 Master Transmitter with Data Rate of 2.5 MHz (10%) (Unit: ns)................................17-5 Slave Receiver with Data Rate of 2.5 MHz (10%) (Unit: ns)......................................17-5 Function Register Description...............................................................................17-6 S3FB42F MICROCONTROLLER xvii List of Tables (Continued) Table Number 18-1 23-1 23-2 23-3 23-4 25-1 25-2 26-1 26-2 26-3 26-4 26-5 26-6 26-7 26-8 26-9 26-10 26-11 26-12 26-13 Title Page Number Control Register Description .................................................................................18-3 General USB Features .........................................................................................23-1 General Function Features ...................................................................................23-1 USB Function Registers Description .....................................................................23-5 Interrupt Pending Register ....................................................................................23-10 MAC2424 Pin Description ....................................................................................25-5 Exponent Evaluation and Normalization Example ...................................................25-35 Absolute Maximum Ratings..................................................................................26-1 D.C. Electrical Characteristics..............................................................................26-1 A.C. Electrical Characteristics..............................................................................26-3 Input/Output Capacitance.....................................................................................26-3 A/D Converter Electrical Characteristics ................................................................26-4 I2S Master Transmitter with Data Rate of 2.5 MHz (10%) (Unit: ns)..........................26-4 I2S Slave Receiver with Data Rate of 2.5 MHz (10%) (Unit: ns) ................................26-5 Flash Memory D.C. Electrical Characteristics ........................................................26-5 Flash Memory A.C. Electrical Characteristics ........................................................26-5 Data Retention Supply Voltage in Stop Mode.........................................................26-6 Synchronous SIO Electrical Characteristics...........................................................26-8 Main Oscillator Frequency (fosc1).........................................................................26-9 Sub Oscillator Frequency (fosc2) ..........................................................................26-10 xviii S3FB42F MICROCONTROLLER List of Programming Tips Description Page Number Chapter 6: Exceptions Interrupt Programming Tip 1..................................................................................................................6-7 Interrupt Programming Tip 2..................................................................................................................6-8 S3FB42F MICROCONTROLLER xix List of Instruction Descriptions Instruction Mnemonic ADC ADD AND AND SR0 BANK BITC BITR BITS BITT BMC/BMS CALL CALLS CLD CLD COM COM2 COMC COP CP CPC DEC DECC DI EI IDLE INC INCC IRET JNZD JP JR LCALL LD adr:8 Full Instruction Name Page Number Add with Carry ....................................................................................................8-31 Add....................................................................................................................8-32 Bit-wise AND ......................................................................................................8-33 Bit-wise AND with SR0Call Procedure ...................................................................8-34 Bank GPR Selection............................................................................................8-35 Bit Complement ..................................................................................................8-36 Bit Reset ............................................................................................................8-37 Bit Set................................................................................................................8-38 Bit Test ..............................................................................................................8-39 TF bit clear/set ....................................................................................................8-40 Conditional subroutine call (Pseudo Instruction) .....................................................8-41 Call Subroutine....................................................................................................8-42 Load into Coprocessor .........................................................................................8-43 Load from Coprocessor ........................................................................................8-44 1's or Bit-wise Complement ..................................................................................8-45 2's Complement ..................................................................................................8-46 Bit-wise Complement with Carry ...........................................................................8-47 Coprocessor .......................................................................................................8-48 Compare.............................................................................................................8-49 Compare with Carry .............................................................................................8-50 Decrement ..........................................................................................................8-51 Decrement with Carry ..........................................................................................8-52 Disable Interrupt (Pseudo Instruction) ....................................................................8-53 Enable Interrupt (Pseudo Instruction) ....................................................................8-54 Idle Operation (Pseudo Instruction) .......................................................................8-55 Increment ...........................................................................................................8-56 Increment with Carry ............................................................................................8-57 Return from Interrupt Handling...............................................................................8-58 Jump Not Zero with Delay Slot ..............................................................................8-59 Conditional Jump (Pseudo Instruction) ..................................................................8-60 Conditional Jump Relative.....................................................................................8-61 Conditional Subroutine Call...................................................................................8-62 Load into Memory................................................................................................8-63 S3FB42F MICROCONTROLLER xxi List of Instruction Descriptions (Continued) Instruction Mnemonic LD @idm LD LD LD LD LD SPR LD SPR0 LDC LJP LLNK LNK LNKS LRET NOP OR OR SR0 POP POP PUSH RET RL RLC RR RRC SBC SL SLA SR SRA STOP SUB SWAP SYS TM XOR Full Instruction Name Page Number Load into Memory Indexed ...................................................................................8-64 Load Register......................................................................................................8-65 Load GPR:bankd, GPR:banks ..............................................................................8-66 Load GPR, TBH/TBL............................................................................................8-67 Load TBH/TBL, GPR............................................................................................8-68 Load SPR...........................................................................................................8-69 Load SPR0 Immediate.........................................................................................8-70 Load Code ..........................................................................................................8-71 Conditional Jump.................................................................................................8-72 Linked Subroutine Call Conditional ........................................................................8-73 Linked Subroutine Call (Pseudo Instruction) ..........................................................8-74 Linked Subroutine Call .........................................................................................8-75 Return from Linked Subroutine Call .......................................................................8-76 No Operation.......................................................................................................8-77 Bit-wise OR ........................................................................................................8-78 Bit-wise OR with SR0 ..........................................................................................8-79 POP...................................................................................................................8-80 POP to Register..................................................................................................8-81 Push Register .....................................................................................................8-82 Return from Subroutine ........................................................................................8-83 Rotate Left ..........................................................................................................8-84 Rotate Left with Carry ..........................................................................................8-85 Rotate Right........................................................................................................8-86 Rotate Right with Carry ........................................................................................8-87 Subtract with Carry ..............................................................................................8-88 Shift Left .............................................................................................................8-89 Shift Left Arithmetic .............................................................................................8-90 Shift Right...........................................................................................................8-91 Shift Right Arithmetic...........................................................................................8-92 Stop Operation (Pseudo Instruction) .....................................................................8-93 Subtract .............................................................................................................8-94 Swap..................................................................................................................8-95 System ..............................................................................................................8-96 Test Multiple Bits ................................................................................................8-97 Exclusive OR ......................................................................................................8-98 xxii S3FB42F MICROCONTROLLER S3FB42F PRODUCT OVERVIEW 1 FEATURES CPU * * PRODUCT OVERVIEW CALMRISC OVERVIEW The S3FB42F single-chip CMOS microcontroller is designed for high performance using Samsung's newest 8-bit CPU core, CalmRISC. CalmRISC is an 8-bit low power RISC microcontroller. Its basic architecture follows Harvard style, that is, it has separate program memory and data memory. Both instruction and data can be fetched simultaneously without causing a stall, using separate paths for memory access. Represented below is the top block diagram of the CalmRISC microcontroller. * * * 8-Bit Basic Timer & Watchdog timer Programmable basic timer 8-bit counter + WDT 3-bit counter 8 kinds of clock source Overflow signal of 8-bit counter makes a basic timer interrupt. And control the oscillation warm-up time Overflow signal of 3-bit counter makes a system reset. 8-Bit CalmRISC Core DSP Architecture (24 x 24-bit MAC) Memory * * * * Code memory: 144K byte (72K word) half flash type memory Data memory: 48K byte SRAM + 69K byte flash type memory One 16-Bit Timer/Counter STACK * * * Programmable interval timer Two 8-bit timer counter mode and one 16-bit timer counter mode, selectable by S/W Size: maximum 16 (word)-level. 65 I/O Pins * * I/O: 59 pins Input only: 6 pins One Real Time Clock * * Real time clock generation (0.5 or 1 second) Buzzer signal generation (1, 2, 4 or 8 kHz) 8-Bit Serial I/O Interface * * * 8-bit transmit/receive or 8-bit receive mode. LSB first or MSB first transmission selectable. Internal and external clock source. ROM Code Options * Basic timer counter clock source selecting reset value 1-1 PRODUCT OVERVIEW S3FB42F FEATURES (Continued) I2C, I2S Interface * * External Interrupt * One-Ch Multi-Master I2C controller Two-Ch Sony/Phillips I2S controller 8 source (Edge triggered 6 + Level triggered 2) ADC * UART Interface * Six 8-bit resolution channels and normal input One Full-duplex UART controller Two Power-down Modes * * USB Specification Compliance (Ver1.0, Ver1.1) * * * * * Idle mode: only CPU clock stop. Stop mode: system clock and CPU clock stop. Built in Full Speed Transceiver Support 1 device address and 4 endpoints. 1 control endpoint and 3 data endpoints One 16 bytes endpoint, one 32 bytes end point, and two 64 bytes end points. Each data endpoint can be configurable as interrupt, bulk and isochronous. Oscillation Sources * * Clock synthesizer (Phase-locked loop circuit) based on 32.768 kHz CPU clock divider circuit (Div by 1, 2, 4, 8, 16, 32, 64, 128) Instruction Execution Times Parallel Port Interface Controller * * * * * 33.3ns at fxx = 30 MHz when 1 cycle instruction 66.6ns at fxx = 30 MHz when 2 cycle instruction Interrupt-based operation Support IEEE Standard 1284 communication mode (compatibility, nibble, byte and ECP mode). Automatic handshaking mode for any forward or reverse protocol with software enable/disable Operating Temperature * - 40 C to 85 C SSFDC (Smart MediaTM card) Interface * Operating Voltage Range * 3.0 V to 3.6 V at 30 MHz Control signals are operated by CPU instruction Package Types * Random Number Generator * * 100-QFP, 100-TQFP Two ring oscillators Linear feedback shifter register LFSR8/LFSR16 1-2 S3FB42F PRODUCT OVERVIEW 20 PA[19:0] PD[15:0] Program Memory Address Generation Unit PC[19:0] 20 8 8 HS[0] Hardware Stack TBH DO[7:0] ABUS[7:0] BBUS[7:0] DI[7:0] ALUL ALUR R0 R1 R2 ALU Flag R3 GPR TBL HS[15] RBUS SR1 ILX Data Memory Address Generation Unit ILH SR0 ILL IDL0 DA[15:0] IDH IDL1 SPR Figure 1-1. Top Block Diagram 1-3 PRODUCT OVERVIEW S3FB42F The CalmRISC building blocks consist of: -- An 8-bit ALU -- 16 general purpose registers (GPR) -- 11 special purpose registers (SPR) -- 16-level hardware stack -- Program memory address generation unit -- Data memory address generation unit 16 GPR's are grouped into four banks (Bank0 to Bank3) and each bank has four 8-bit registers (R0, R1, R2, and R3). SPR's, designed for special purposes, include status registers, link registers for branch-link instructions, and data memory index registers. The data memory address generation unit provides the data memory address (denoted as DA[15:0] in the top block diagram) for a data memory access instruction. Data memory contents are accessed through DI[7:0] for read operations and DO[7:0] for write operations. The program memory address generation unit contains a program counter, PC[19:0], and supplies the program memory address through PA[19:0] and fetches the corresponding instruction through PD[15:0] as the result of the program memory access. CalmRISC has a 16-level hardware stack for low power stack operations as well as a temporary storage area. CalmRISC has a 3-stage pipeline as discribed below: Instruction Fetch (IF) Instruction Decode/ Data Memory Access (ID/MEM) Execution/Writeback (EXE/WB) Figure 1-2. CalmRISC Pipeline Diagram As can be seen in the pipeline scheme, CalmRISC adopts a register-memory instruction set. In other words, data memory where R is a GPR, can be one operand of an ALU instruction as shown below: The first stage (or cycle) is Instruction Fetch stage (IF for short), where the instruction pointed to by the program counter, PC[19:0] , is read into the Instruction Register (IR for short). The second stage is Instruction Decode and Data Memory Access stage (ID/MEM for short), where the fetched instruction (stored in IR) is decoded and data memory access is performed, if necessary. The final stage is Execute and Write-back stage (EXE/WB), where the required ALU operation is executed and the result is written back into the destination registers. Since CalmRISC instructions are pipelined, the next instruction fetch is not postponed until the current instruction is completely finished, but is performed immediately after the current instruction fetch is done. The pipeline stream of instructions is illustrated in the following diagram. 1-4 S3FB42F PRODUCT OVERVIEW I1 IF I2 ID/MEM IF I3 EXE/WB ID/MEM IF I4 EXE/WB ID/MEM IF EXE/WB IF I5 ID/MEM IF I6 EXE/WB ID/MEM IF EXE/WB ID/MEM EXE/WB Figure 1-3. CalmRISC Pipeline Stream Diagram Most CalmRISC instructions are 1-word instructions, while same branch instructions such as "LCALL" and "LJT" instructions are 2-word instructions. In Figure 1-3, the instruction, I4, is a long branch instruction and it takes two clock cycles to fetch the instruction. As indicated in the pipeline stream, the number of clocks per instruction (CPI) is 1 except for long branches, which take 2 clock cycles per instruction. 1-5 PRODUCT OVERVIEW S3FB42F XIN XOUT BUZ Basic Timer CP, CZ Fvco OSC & PLL Control RTC WDT Random Number Gen. I/O0-I/O7 P9.0-P9.5 P8.0-P8.3 P7.0-P7.7 P6.0-P6.7 P5.0-P5.5 SSFDC Port 9 CalmRISC CPU SIO/UART IIC/IIS Timer 0/1 SI, Rx, SDA, SOI SO, Tx, SOD SCK, SCL, SOC TACK/TBCK TAOUT PD0-PD7 nSTROBE/nINIT BUSY/PERROR DP, DM AVref AVss ADC0-ADC5 INT0-INT5 INT8-INT9 Port 8 Port 7 Port 6 Port 5 Flash Memory 213-Kbytes SRAM 48-Kbytes PPIC USB DSP Core MAC 2424 8-bit A/D C Ext Interrupt Port 4 Port 3 Port 2 Port 1 P1.0-P1.4 P4.0-P4.3 P3.0-P3.7 P2.0-P2.7 Figure 1-4. Block Diagram 1-6 P0.0-P0.7 Port 0 S3FB42F PRODUCT OVERVIEW 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 P6.6/nRE P6.5/nWP P6.4/R/nB P6.3/ALE P6.2/CLE P6.1/nCE1 P6.0/nCE0 VDD AVSS AVREF P5.5/ADC5/INT5 P5.4/ADC4/INT4 P5.3/ADC3/INT3 P5.2/ADC2/INT2 P5.1/ADC1/INT1 P5.0/ADC0/INT0 P4.2/nCE2 P4.1/INT8 P4.0/INT9 P9.6/MCLK VDD VSS nWE/P6.7 I/O0/P7.0 I/O1/P7.1 I/O2/P7.2 I/O3/P7.3 VDD VSS I/O4/P7.4 I/O5/P7.5 I/O6/P7.6 SDAT/I/O7/P7.7 SCLK /nSLCTIN/P8.0 VDD/VDD VSS/VSS XIN XOUT VPP/TEST XTIN XTOUT RESET /RESET VDD VSS N.C FVCO/nSTROBE/P8.1 nAUTOFD/P8.2 CP CZ VSS 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 S3FB42F (100-QFP) VSS VSS VDD P9.5/SD1 P9.4/SCLK1 P9.3/WS1 VSS VDD P9.2/SD0 P9.1/SCLK0 P9.0/WS0 P3.7 P3.6 P3.5 P3.4/SDA VSS VDD P3.3/SCL P3.2/SCK DM VSS VDD DP P3.1/SO P3.0/SI P2.7 P2.6 P2.5/Tx VSS VDD NOTE: N.C means No - Connection. nINIT/P8.3 PPD0/P0.0 PPD1/P0.1 PPD2/P0.2 PPD3/P0.3 PPD4/P0.4 PPD5/P0.5 PPD6/P0.6 PPD7/P0.7 VDD nACK/P1.0 BUSY/P1.1 SELECT/P1.2 PERROR/P1.3 nFAULT/P1.4 TACLK/P2.0 TBCLK/P2.1 TAOUT/P2.2 BUZ/P2.3 Rx/P2.4 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 Figure 1-5. 100-QFP Pin Assignment 1-7 PRODUCT OVERVIEW S3FB42F 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 VSS VDD P6.6/nRE P6.5/nWP P6.4/R/nB P6.3/ALE P6.2/CLE P6.1/nCE1 P6.0/nCE0 VDD AVSS AVREF P5.5/ADC5/INT5 P5.4/ADC4/INT4 P5.3/ADC3/INT3 P5.2/ADC2/INT2 P5.1/ADC1/INT1 P5.0/ADC0/INT0 P4.2/nCE2 P4.1/INT8 P4.0/INT9 P9.6/MCLK VSS VSS VDD nWE/P6.7 I/O0/P7.0 I/O1/P7.1 I/O2/P7.2 I/O3/P7.3 VDD VSS I/O4/P7.4 I/O5/P7.5 I/O6/P7.6 SDAT/I/O7/P7.7 SCLK /nSLCTIN/P8.0 VDD/VDD VSS/VSS XIN XOUT VPP/TEST XTIN XT OUT RESET VDD VSS N.C FVCO/nSTROBE/P8.1 nAUTOFD/P8.2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 S3FB42F (100-TQFP-1414C) P9.5/SD1 P9.4/SCLK1 P9.3/WS1 VSS VDD P9.2/SD0 P9.1/SCLK0 P9.0/WS0 P3.7 P3.6 P3.5 P3.4/SDA VSS VDD P3.3/SCL P3.2/SCK DM VSS VDD DP P3.1/SO P3.0/SI P2.7 P2.6 P2.5/Tx NOTE: N.C means No - Connection 1-8 CP CZ VSS nINIT/P8.3 PPD0/P0.0 PPD1/P0.1 PPD2/P0.2 PPD3/P0.3 PPD4/P0.4 PPD5/P0.5 PPD6/P0.6 PPD7/P0.7 VDD nACK/P1.0 BUSY/P1.1 SELECT/P1.2 PERROR/P1.3 nFAULT/P1.4 TACK/P2.0 TBCK/P2.1 TAOUT/P2.2 BUZ/P2.3 Rx/P2.4 VDD VSS 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 Figure 1-6. 100-TQFP Pin Assignment S3FB42F PRODUCT OVERVIEW PIN DESCRIPTION Table 1-1. S3FB42F Pin Descriptions (100-TQFP) Pin Name P0.0-P0.7 Pin Type I/O Pin Description I/O port with bit programmable pins; Input or output mode selected by software; Alternately can be used as parallel port data bus pins, PPD0-PPD7. P0.0/PPD0-P0.7/PPD7: Parallel port data bus P1.0-P1.4 I/O I/O port with bit programmable pins; Push-pull output mode is selected by software; Alternately can be used as parallel port control bus pins, nACK, BUSY, SELECT, PERROR and nFAULT pin. P1.0/nACK: Not parallel port acknowledge. P1.1/BUSY: Parallel port busy. P1.2/SELECT: Parallel port select. P1.3/PERROR: Parallel port paper error P1.4/nFAULT: Not parallel port fault. P2.0-P2.7 I/O I/O port with bit programmable pins; Input and output mode are selected by software; Alternately can be used as TACLK, TBCLK, TAOUT, BUZ, Rx and Tx. P2.0/TACLK: Timer 0 clock or capture input P2.1/TBCLK: Timer 1 clock input P2.2/TAOUT: Timer 2 capture input or, PWM or toggle output P2.3/BUZ: Buzzer output P2.4/Rx: Receive input in UART P2.5/Tx: Transmit output in UART P2.6: Normal input/output pin P2.7: Normal input/output pin P3.0-P3.7 I/O I/O port with bit programmable pins; Input or output mode selected by software; Alternately can be used as SI, SO, SCK, SCL and SDA. N-channel open drains are configurable. P3.0/SI: Serial data input pin in SIO(SPI) P3.1/SO: Serial data output pin in SIO(SPI) P3.2/SCK: Serial clock pin in SIO(SPI) P3.3/SCL: Serial clock pin in I2C P3.4/SDA: Serial data pin in I2C P3.5: Normal input/output pin P3.6: Normal input/output pin P3.7: Normal input/output pin NOTE: Parentheses indicate pin number for 100-QFP package. Circuit Type 1 Pin Number 30-37 (32-39) Share Pins PPD0PPD7 1 39-43 (41-45) nACKnFAULT 4 44-48, 51-53 (46-50, 53-55) TACLK-Tx 5 54-55, 60-61, 64-67 (56-57, 62-63, 66-69) SI-SDA 1-9 PRODUCT OVERVIEW S3FB42F Table 1-1. S3FB42F Pin Descriptions (100-TQFP) (Continued) Pin Name P4.0-P4.2 Pin Type I/O Pin Description I/O port with bit programmable pins; Input and output mode are selected by software; P4.0-P4.1 can be used as inputs for external interrupts INT9-INT8. (with noise filter) and assigned pull-up by software; Alternately P4.2 can be used as CE2 for SmartMedia chip select signal. P4.0/INT9: External interrupt 9 input P4.1/INT8: External interrupt 8 input P4.2/CE2: Normal in/output pin P5.0-P5.5 I Input port with bit programmable pins; Input or ADC input mode selected by software; software assignable pull-up; Port 5 can be used as inputs for external interrupts INT0-INT5 or ADC block. P5.0/INT0/ADC0: Ext P5.1/INT1/ADC1: Ext P5.2/INT2/ADC2: Ext P5.3/INT3/ADC3: Ext P5.4/INT4/ADC4: Ext P5.5/INT5/ADC5: Ext P6.0-P6.7 I/O interrupt interrupt interrupt interrupt interrupt interrupt 0 1 2 3 4 5 or or or or or or ADC0 ADC1 ADC2 ADC3 ADC4 ADC5 input input input input input input 1, 2 92-98, 1 (94-100, 3) CE0-WE 7 83-88 (85-90) INT0/ADC0INT5/ADC5 Circuit Type 6, 3 Pin Number 80-82 (82-84) Share Pins INT9-INT8 CE2 I/O port with bit programmable pins; Alternately Port 6 can be used as CE0, CE1, CLE, ALE, WE, WP, RE and R/B for SmartMedia control signal. P6.0/CE0: Chip Select strobe output 0 for SM. P6.1/CE1: Chip Select strobe output 1 for SM. P6.2/CLE: Command latch enable output for SM. P6.3/ALE: Address latch enable output for SM. P6.4/R/B: Ready and Busy status input for SM. P6.5/WP: Write protect output for SM. P6.6/RE: Read enable strobe output for SM. P6.7/WE: Write enable strobe output for SM. P7.0-P7.7 I/O I/O port with bit programmable pins; Alternately Port 7 can be used as I/O port for SmartMedia control signal. P7.0/I/O0-P7.7/I/O7: I/O port for SmartMedia control signal. 1 2-5, 8-11 (4-7, 10-13) I/O0-I/O7 NOTE: Parentheses indicate pin number for 100-QFP package. 1-10 S3FB42F PRODUCT OVERVIEW Table 1-1. S3FB42F Pin Descriptions (100-TQFP) (Continued) Pin Name P8.0-P8.3 Pin Type I/O Pin Description I/O port with bit programmable pins; Alternately can be used as parallel port control bus pins, nSLCTIN, NsTROBE, nAUTOFD and nINIT pin. P8.0/nSLCTIN: Not select information input. P8.1/nSTROBE/FVCO: Not strobe input or FVCO output P8.2/nAUTOFD: Not auto-feed input P8.3/nINIT: Not parallel port initialization. P9.0-P9.6 I/O I/O port with bit programmable pins; Alternately can be used as serial data interface pins, WS0, SCLK0, SD0, WS1, SCLK1, SD1 and MCLK. P9.0/WS0: Word select pin in I2S0 P9.1/SCLK0: Bit serial clock pin in I2S0. P9.2/SD0: Serial data pin in I2S0 P9.3/WS1: Word select pin in I2S1. P9.4/SCLK1: Bit serial clock pin in I2S1. P9.5/SD1: Serial data pin in I2S1. P9.6/MCLK: Master Clock pin in I2S0. DM DP VDD, VDD I/O I/O - Only be used USB transceive/receive port Only be used USB transceive/receive port Power supply - - - 4 68-70, 73-76, 79 (70-72, 75-77, 79) WS0MCLK Circuit Type 4 Pin Number 12, 24, 25, 29 (14, 26, 27, 31) Share Pins nSLCTINnINIT 59 (61) 56 (58) 6, 13, 21, 26, 38, 49, 57, 62, 71, 76, 91, 99 (1, 8, 15, 23, 28, 40, 52, 59, 64, 73, 78, 93) 7, 14, 22, 27, 28, 50, 58, 63, 72, 77, 78, 100 (2, 9, 16, 24, 29, 30, 51, 60, 65, 74, 79, 80) - - - VSS, VSS - Ground - - NOTE: Parentheses indicate pin number for 100-QFP package. 1-11 PRODUCT OVERVIEW S3FB42F 1-12 S3FB42F PRODUCT OVERVIEW Table 1-1. S3FB42F Pin Descriptions (100-TQFP) (Continued) Pin Name XIN, XOUT Pin Type - Pin Description Crystal, ceramic oscillator signal for PLL reference frequency (for external clock input, use XIN and input XIN's reverse phase to XOUT) XTIN, XTOUT CP, CZ TEST RESET AVREF, AVSS SDAT SCLK VDD VSS VPP RESET NOTE: Circuit Type - Pin Number 15, 16 (17, 18) Share Pins - - - I I - Crystal, ceramic oscillator (for external clock input, use XTIN and input XT IN's reverse phase to XT OUT) Low pass filter circuit for PLL Test signal input Reset signal Power supply pin and ground pin for A/D converter. - - 9 8 - 18, 19 (20,21) 26, 27 (28, 29) 17 (19) 20 (22) 89, 90 (91, 92) 11 (13) 12 (14) 13 (15) 14 (16) 17 (19) 20 (22) - - - - - I/O I - - - I Serial data in/output pin for serial program block Serial clock input pin for serial program block Power supply pin for serial program block Ground pin for serial program block Flash Cell Power supply pin or mode selection pin for serial program block Reset pin for serial program block 1 1 - - - 8 P7.7 P8.0 - - TEST RESET Parentheses indicate pin number for 100-QFP package. 1-13 PRODUCT OVERVIEW S3FB42F PIN CIRCUIT DIAGRAMS Select VDD Port Data Alternative Signal M U X Data In/Out Output Disable Alternative Input Normal Input VSS Figure 1-7. Pin Circuit Type 1 (Port 0, P1.0-P1.4, P6.0-P6.5, and Port 7) VDD Pull-up Resistor Pull-up Enable Select VDD Port Data Alternative Signal M U X Data In/Out Output Disable Alternative Input Normal Input VSS Figure 1-8. Pin Circuit Type 2 (P6.6 and P6.7) 1-14 S3FB42F PRODUCT OVERVIEW VDD Pull-up Resistor Pull-up Enable Select VDD Port Data Alternative Signal M U X Data In/Out Output Disable Alternative Input Normal Input VSS Figure 1-9. Pin Circuit Type 3 (P4.2) 1-15 PRODUCT OVERVIEW S3FB42F Select VDD Port Data Alternative Signal M U X Data In/Out Output Disable Alternative Input Normal Input VSS Figure 1-10. Pin Circuit Type 4 (Port 2, Port 8, and Port 9) VDD Pull-up Resistor Pull-up Enable Select VDD Port Data Alternative Signal M U X Data In/Out Open-Drain Output Disable Alternative Input Normal Input VSS Figure 1-11. Pin Circuit Type 5 (Port 3) 1-16 S3FB42F PRODUCT OVERVIEW VDD Pull-up Resistor Pull-up Enable VDD Data In/Out Output Disable Input External Interrupt Input Noise Filter VSS Figure 1-12. Pin Circuit Type 6 (P4.0, and P4.1) VDD Pull-up Resistor Pull-up Resistor Enable Normal Input Mode Normal Input Noise Filter A/D C Logic + VREF In Interrupt Input Figure 1-13. Pin Circuit Type 7 (Port 5) 1-17 PRODUCT OVERVIEW S3FB42F VDD In Figure 1-14. Pin Circuit Type 8 (RESET RESET) In Figure 1-15. Pin Circuit Type 9 (TEST) 1-18 S3FB42F PRODUCT OVERVIEW NOTES 1-19 S3FB42F ADDRESS SPACE 2 OVERVIEW ADDRESS SPACE CalmRISC has 20-bit program address lines, PA[19:0], which supports up to 1M-word program memory. The 1M-word program memory space is divided into 256 pages and each page is 4K words long as shown in the next page. The upper 8 bits of the program counter, PC[19:12], points to a specific page and the lower 12 bits, PC[11:0], specify the offset address of the page. CalmRISC also has 16-bit data memory address lines, DA[15:0], which supports up to 64K-byte data memory. The 64K-byte data memory space is divided into 256 pages and each page has 256 bytes. The upper 8 bits of the data address, DA[15:8], points to a specific page and the lower 8 bits, DA[7:0], specify the offset address of the page. S3FB42F has 72K-word (144K-byte) flash ROM type program memory, 34.5K-word (69K-byte) flash ROM type data memory and 48K-byte RAM type data memory. Memory configuration in CalmRISC side Data Memory: Total size - 117K bytes (Flash ROM type, 69K bytes and SRAM type, 48K bytes) Code Memory: Total size - 144K bytes (Flash ROM type, 144K bytes) Memory configuration in MAC-2424 side Data Memory: X-Memory area - SRAM, 12K LWords (36K bytes) Y-Memory area - SRAM, 4K LWords (12K bytes) and Flash ROM, 23K LWords (69K bytes) Code Memory: Total size - 72K words (Flash ROM type, 144K byte) Memory Type Flash ROM: 213K bytes SRAM: 48K bytes 2-1 ADDRESS SPACE S3FB42F PROGRAM MEMORY (ROM) FFFH 72K-word (144K-byte) 11FFFH ~ ~ FFFH ~ ~ 72K-word Code Momory Flash ROM Memory (4K-word x 18 Page = 72K-word) 4K-word (8K-byte) 00H 00020H 0001FH 18 page 00H 00000H Vector and Option Area 16-Bit Figure 2-1. Flash Memory (Code Memory Area) From 00000H to 00004H addresses are used for the vector address of exceptions, and 0001EH, 0001FH are used for the option only. Aside from these addresses others are reserved in the vector and option area. Program memory area from the address 00020H to 11FFH can be used for normal programs. S3FB42F's program memory is 72K words (144K bytes). 2-2 S3FB42F ADDRESS SPACE DATA MEMORY ORGANIZATION The total data memory bank address space is 64 K-byte, addressed by DA[15:0], which is also divided into 256 pages, Each page consists of 256 bytes as shown below. S3FB42F has 2 data bank memory. FFH FFH 64K-Byte FFH FFH 00H 256-Byte 256-Byte 128 pages (Y-Memory) 256 pages 128 pages (X-Memory) 00H 8-Bit Bank 0 00H 8-Bit Bank 1 Figure 2-2. Data Memory Map 2-3 ADDRESS SPACE S3FB42F FFFFH YROM Bank 0 1 FFFFH YROM Bank 0 2 8KB 6KB 9KB C000H Flash ROM 1 2 16KB 12KB 18KB Flash ROM E000H DC00H E800H D000H B800H 9FFFH 8FFFH 8000H 7FFFH Page 144 SRAM 4K-byte Page 128 8000H 7FFFH SRAM 8K-byte Y-Memory Page 128 Page 127 X-Memory Blank 4000H 3FFFH SRAM Page 63 24K-byte SRAM 12K-byte 2000H 1FFFH Page 32 Page 31 7.75K-byte Page 1 1000H 0100H Blank Bank 1 Page Address Page 16 0100H Blank Bank 0 00FFH 0000H I/O Area Page 0 MAC access unit, LWord = 3-Byte Long. (1-Byte to Bank 1, and 2-Byte of Bank 0) BANK 0 XM = 2000H + MAC Offset x 2 YM = 8000H + MAC Offset x 2 BANK 1 XM = 1000H + MAC Offset YM = 8000H + MAC Offset Figure 2-3. Data Memory Map in CalmRISC Side 2-4 S3FB42F ADDRESS SPACE 7FFFH YROM Bank 0 1 2 8K-LW 9K-LW 6K-LW 6800H Flash ROM 6000H 5C00H 4FFFH SRAM 4000H 3FFFH X-Memory 4K-LWord Y-Memory SRAM 12K-LWord 1000H 0FFFH Blank 0000H Where, LWord: 3-Byte Long. (1-Byte of Bank 1, and 2-Byte of Bank 0) XM MAC Offset = MAC Address - 1000H YM MAC Offset = MAC Address - 4000H 4K-LWord Figure 2-4. Data Memory Map in MAC-2424 Side 2-5 ADDRESS SPACE S3FB42F FFFFH Flash ROM (8KB) E000H DC00H 9KB C000H 6KB E800H Flash ROM (16KB) 12KB 7FFFH 6K-LW Flash ROM (8K-LWord) 6800H 6000H 5FFFH Blank (4K-LWord) 5000H 4FFFH SRAM (8KB) SRAM (4K-LWord) 4000H 3FFFH X-Memory 9K-LW 5C00H D000H 18KB B800H 9FFFH 8FFFH 8000H SRAM (4KB) Y-Memory 8000H 7FFFH 3FFFH SRAM (12KB) 1000H Bank 1 00FFH 0000H I/O Area 2000H SRAM (24KB) SRAM (12K-LWord) 1000H Bank 0 Page 0 MAC2424 Memory Space CalmRISC Memory Space Figure 2-5. Data Memory Map 2-6 S3FB42F REGISTERS 3 OVERVIEW REGISTERS The registers of CalmRISC are grouped into 2 parts: general purpose registers and special purpose registers. Table 3-1. General and Special Purpose Registers Registers General Purpose Registers (GPR) Mnemonics R0 R1 R2 R3 Special Purpose Registers (SPR) Group 0 (SPR0) IDL0 IDL1 IDH SR0 Group 1 (SPR1) ILX ILH ILL SR1 Description General Register 0 General Register 1 General Register 2 General Register 3 Lower Byte of Index Register 0 Lower Byte of Index Register 1 Higher Byte of Index Register Status Register 0 Instruction Pointer Link Register for Extended Byte Instruction Pointer Link Register for Higher Byte Instruction Pointer Link Register for Lower Byte Status Register 1 Reset Value Unknown Unknown Unknown Unknown Unknown Unknown Unknown 00H Unknown Unknown Unknown Unknown GPR's can be used in most instructions such as ALU instructions, stack instructions, load instructions, etc (See the instruction set sections). From the programming standpoint, they have almost no restriction whatsoever. CalmRISC has 4 banks of GPR's and each bank has 4 registers, R0, R1, R2, and R3. Hence, 16 GPR's in total are available. The GPR bank switching can be done by setting an appropriate value in SR0[4:3] (See SR0 for details). The ALU operations between GPR's from different banks are not allowed. SPR's are designed for their own dedicated purposes. They have some restrictions in terms of instructions that can access them. For example, direct ALU operations cannot be performed on SPR's. However, data transfers between a GPR and an SPR are allowed and stack operations with SPR's are also possible (See the instruction sections for details). 3-1 REGISTERS S3FB42F INDEX REGISTERS: IDH, IDL0 AND IDL1 IDH in concatenation with IDL0 (or IDL1) forms a 16-bit data memory address. Note that CalmRISC's data memory address space is 64K bytes (addressable by 16-bit addresses). Basically, IDH points to a page index and IDL0 (or IDL1) corresponds to an offset of the page. Like GPR's, the index registers are 2-way banked. There are 2 banks in total, each of which has its own index registers, IDH, IDL0 and IDL1. The banks of index registers can be switched by setting an appropriate value in SR0[2] (See SR0 for details). Normally, programmers can reserve an index register pair, IDH and IDL0 (or IDL1), for software stack operations. LINK REGISTERS: ILX, ILH AND ILL The link registers are specially designed for link-and-branch instructions (See LNK and LRET instructions in the instruction sections for details). When an LNK instruction is executed, the current PC[19:0] is saved into ILX, ILH and ILL registers, i.e., PC[19:16] into ILX[3:0], PC[15:8] into ILH [7:0], and PC[7:0] into ILL[7:0], respectively. When an LRET instruction is executed, the return PC value is recovered from ILX, ILH, and ILL, i.e., ILX[3:0] into PC[19:16], ILH[7:0] into PC[15:8] and ILL[7:0] into PC[7:0], respectively. These registers are used to access program memory by LDC/LDC+ instructions. When an LDC or LDC+ instruction is executed, the (code) data residing at the program address specified by ILX:ILH:ILL will be read into TBH:TBL. LDC+ also increments ILL after accessing the program memory. There is a special core input pin signal, nP64KW, which is reserved for indicating that the program memory address space is only 64 K word. By grounding the signal pin to zero, the upper 4 bits of PC, PC[19:16], is deactivated and therefore the upper 4 bits , PA[19:16], of the program memory address signals from CalmRISC core are also deactivated. By doing so, power consumption due to manipulating the upper 4 bits of PC can be totally eliminated (See the core pin description section for details). From the programmer's standpoint, when nP64KW is tied to the ground level, then PC[19:16] is not saved into ILX for LNK instructions and ILX is not read back into PC[19:16] for LRET instructions. Therefore, ILX is totally unused in LNK and LRET instructions when nP64KW = 0. 3-2 S3FB42F REGISTERS STATUS REGISTER 0: SR0 SR0 is mainly reserved for system control functions and each bit of SR0 has its own dedicated function. Table 3-2. Status Register 0: SR0 Flag Name eid ie idb grb[1:0] exe ie0 ie1 Bit 0 1 2 4,3 5 6 7 Description Data memory page selection in direct addressing Global interrupt enable Index register banking selection GPR bank selection Stack overflow/underflow exception enable Interrupt 0 enable Interrupt 1 enable Reset Value 1 x 0 00 x x x SR0[0] (or eid) selects which page index is used in direct addressing. If eid = 0, then page 0 (page index = 0) is used. Otherwise (eid = 1), IDH of the current index register bank is used for page index. SR0[1] (or ie) is the global interrupt enable flag. As explained in the interrupt/exception section, CalmRISC has 3 interrupt sources (nonmaskable interrupt, interrupt 0, and interrupt 1) and 1 stack exception. Both interrupt 0 and interrupt 1 are masked by setting SR0[1] to 0 (i.e., ie = 0). When an interrupt is serviced, the global interrupt enable flag ie is automatically cleared. The execution of an IRET instruction (return from an interrupt service routine) automatically sets ie = 1. SR0[2] (or idb) and SR0[4:3] (or grb[1:0]) selects an appropriate bank for index registers and GPR's, respectively as shown below: R3 R2 R1 R0 R3 R3 R2 R3 R2 R1 R2 R1 R0 R1 R0 Bank 3 Bank 2 R0 Bank 1 Bank 0 grb [1:0] idb 11 10 01 00 1 0 IDH IDH IDL0 IDL0 IDL1 IDL1 Figure 3-1. Bank Selection by Setting of GRB Bits and IDB Bit SR0[5] (or exe) enables the stack exception, that is, the stack overflow/underflow exception. If exe = 0, the stack exception is disabled. The stack exception can be used for program debugging in the software development stage. SR0[6] (or ie0) and SR0[7] (or ie1) are enabled, by setting them to 1. Even though ie0 or ie1 are enabled, the interrupts are ignored (not serviced) if the global interrupt enable flag ie is set to 0. 3-3 REGISTERS S3FB42F STATUS REGISTER 1: SR1 SR1 is the register for status flags such as ALU execution flag and stack full flag. Table 3-3. Status Register 1: SR1 Flag Name C V Z N SF - Bit 0 1 2 3 4 5,6,7 Carry flag Overflow flag Zero flag Negative flag Stack Full flag Reserved Description SR1[0] (or C) is the carry flag of ALU executions. SR1[1] (or V) is the overflow flag of ALU executions. It is set to 1 if and only if the carry-in into the 8-th bit position of addition/subtraction differs from the carry-out from the 8-th bit position. SR1[2] (or Z) is the zero flag, which is set to 1 if and only if the ALU result is zero. SR1[3] (or N) is the negative flag. Basically, the most significant bit (MSB) of ALU results becomes N flag. Note a load instruction into a GPR is considered an ALU instruction. However, if an ALU instruction touches the overflow flag (V) like ADD, SUB, CP, etc, N flag is updated as exclusive-OR of V and the MSB of the ALU result. This implies that even if an ALU operation results in overflow, N flag is still valid. SR1[4] (or SF) is the stack overflow flag. It is set when the hardware stack is overflowed or underflowed. Programmers can check if the hardware stack has any abnormalities by the stack exception or testing if SF is set (See the hardware stack section for great details). NOTE: When an interrupt occur SR0 and SR1 are not saved by hardware, so the SR1 register values must be saved by software. 3-4 S3FB42F MEMORY MAP 4 MEMORY MAP OVERVIEW To support the control of peripheral hardware, the address for peripheral control registers are memory-mapped to page 0 of the RAM. Memory mapping lets you use a mnemonic as the operand of an instruction in place of the specific memory location. In this section, detailed descriptions of the S3FB42F control registers are presented in an easy-to-read format. You can use this section as a quick-reference source when writing application programs. This memory area can be accessed with the whole method of data memory access. -- If SR0 bit 0 is "0" then the accessed register area is always page 0. -- If SR0 bit 0 is "1" then the accessed register page is controlled by the proper IDH register's value. So if you want to access the memory map area, clear the SR0.0 and use the direct addressing mode. This method is used for most cases. This control register is divided into five areas. Here, the system control register area is same in every device. Control Register FFH ~ ~ 80H 7FH 70H 6FH Reserved Area (1 x 16 or 2 x 8) ~ ~ Peripheral Control Register (1 x 16 or 2 x 8) Specially in S3FB42F the area from 60H-7FH can be used for external device. So if you want to use some peripheral externally, then you can control that by means of this special area. Peripheral Control Register (4 x 8) 40H 3FH Port Control Register Area (4 x 8) 20H 1FH Port Data Register Area 10H 0FH System Control Register Area 00H Standard area Standard exhortative area Figure 4-1. Memory Map Area 4-1 MEMORY MAP S3FB42F Table 4-1. Registers Register Name Mnemonic Decimal Hex Reset R/W Location 1AH-1FH are not mapped Port 9 data register Port 8 data register Port 7 data register Port 6 data register Port 5 data register Port 4 data register Port 3 data register Port 2 data register Port 1 data register Port 0 data register Watchdog timer control register Watchdog timer enable register Basic timer counter Basic timer control register Interrupt ID register 1 Interrupt priority register 1 Interrupt mask register 1 Interrupt request register 1 Interrupt ID register 0 Interrupt priority register 0 Interrupt mask register 0 Interrupt request register 0 Oscillator control register Power control register (stop or idle mode) P9 P8 P7 P6 P5 P4 P3 P2 P1 P0 WDTCON WDTEN BTCNT BTCON IIR1 IPR1 IMR1 IRQ1 IIR0 IPR0 IMR0 IRQ0 OSCCON PCON 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 19H 18H 17H 16H 15H 14H 13H 12H 11H 10H 0FH 0EH 0DH 0CH 0BH 0AH 09H 08H 07H 06H 05H 04H 03H 02H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H - 00H 00H - - 00H 00H 00H 04H R/W R/W R/W R/W R R/W R/W R/W R/W R/W R/W R/W R R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W Locations 00H-01H are not mapped NOTES: 1. '-' means underlined. 2. If you want to clear the bit of IRQx, then write the number which you want to clear to IIRx. For example, when clear IRQ0.4 then LD R0, #04H and LD IIR0, R0. 4-2 S3FB42F MEMORY MAP Table 4-1. Registers (Continued) Register Name Port 0 control register Port 1 control register Port 2 control register low Port 2 control register high Port 3 control register low Port 3 control register high Port 3 pull-up resistor Mnemonic P0CON P1CON P2CONL P2CONH P3CONL P3CONH P3PUR Decimal 32 33 34 35 36 37 38 Hex 20H 21H 22H 23H 24H 25H 26H Reset 00H 00H 00H 30H 00H 00H 00H R/W R/W R/W R/W R/W R/W R/W R/W Location 27H is not mapped Port 5 control register Port 5 pull-up resistor Port 5 Int. control register Port 5 Int. mode register low Port 5 Int. mode register High External Int. pending register P5CON P5PUR P5INTCON P5INTMODL P5INTMODH EINTPND 40 41 42 43 44 45 28H 29H 2AH 2BH 2CH 2DH 00H 00H 00H 00H 00H 00H R/W R/W R/W R/W R/W R/W Locations 2E-2FH are not mapped Port 4 control register Port 4 Int. control register Port 4 Int. mode register P4CON P4INTCON P4INTMOD 48 49 50 30H 31H 32H 00H 00H 00H R/W R/W R/W Location 33H is not mapped Port 6 control register Port 7 control register Port 8 control register Port 9 control register P6CON P7CON P8CON P9CON 52 53 54 55 34H 35H 36H 37H 00H 00H 00H 00H R/W R/W R/W R/W Locations 38H-3FH are not mapped Timer A control register Timer A data register Timer A counter TACON TADATA TACNT 64 65 66 40H 41H 42H 00H 00H - R/W R/W R Location 43H is not mapped Timer B control register Timer B data register Timer B counter TBCON TBDATA TBCNT 68 69 70 44H 45H 46H 00H 00H - R/W R/W R Locations 47H-4BH are not mapped Watch timer control register WTCON 76 4CH 00H R/W Locations 4DH-4FH are not mapped 4-3 MEMORY MAP S3FB42F Table 4-1. Registers (Continued) Register Name Serial I/O control register Serial I/O pre-scale register Serial I/O data register Mnemonic SIOCON SIOPS SIODATA Decimal 80 81 82 Hex 50H 51H 52H Reset 00H 00H 00H R/W R/W R/W R/W Location 53H is not mapped A/D C control register A/D conversion result data register ADCON ADDATA 84 85 54H 55H 00H - R/W R Locations 56H-57H are not mapped IIS control register 0 IIS mode register 0 IIS buffer pointer register 0 IISCON0 IISMODE0 IISPTR0 88 89 90 58H 59H 5AH 00H 00H 00H R/W R/W R/W Location 5BH is not mapped IIS control register 1 IIS mode register 1 IIS buffer pointer register 1 IISCON1 IISMODE1 IISPTR1 92 93 94 5CH 5DH 5EH 00H 00H 00H R/W R/W R/W Location 5FH is not mapped Parallel port data register Parallel port command data register Parallel port status control register Parallel port status register Parallel port control register low Parallel port control register high Parallel port int. control register low Parallel port int. control register high Parallel port int. pending register low Parallel port int. pending register high Parallel port ack. width data register PPDATA PPCDATA PPSCON PPSTAT PPCONL PPCONH PPINTCONL PPINTCONH PPINTPNDL PPINTPNDH PPACKD 96 97 98 99 100 101 102 103 104 105 106 60H 61H 62H 63H 64H 65H 66H 67H 68H 69H 6AH 00H 00H 08H 3FH 00H 00H 00H 00H 00H 00H xxH R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W Locations 6BH-6FH are not mapped SmartMedia control register ECC counter ECC data register low ECC data register high ECC data register extension ECC result register low SMCON ECCNT ECCL ECCH ECCX ECCRSTL 112 113 114 115 116 117 70H 71H 72H 73H 74H 75H 00H 00H 00H 00H 00H 00H R/W R/W R/W R/W R/W R/W 4-4 S3FB42F MEMORY MAP Table 4-1. Registers (Continued) Register Name ECC result register high ECC clear register Flash memory control register Mnemonic ECCRSTH ECCCLR FMCON Decimal 118 119 120 Hex 76H 77H 78H Reset 00H - 00H R/W R/W W R/W Location 79H is not mapped Flash user programming serial clock register Flash user programming serial data register FSCLK FSDAT 122 123 7AH 7BH 00H 00H R/W R/W Locations 7CH-7FH are not mapped Function address register Power management register Frame number LO register Frame number HI register Interrupt pending register Interrupt enable register Endpoint index register FUNADDR PWRMAN FRAMELO FRAMEHI INTREG INTENA EPINDEX 128 129 130 131 132 133 134 80H 81H 82H 83H 84H 85H 86H 00H 00H 00H 00H 00H 00H 00H R R R R R/W R/W R/W Locations 87H-88H are not mapped Endpoint direction register IN control status register OUT control status register IN MAX packet register OUT MAX packet register Write counter LO register Write counter HI register Endpoint 0 FIFO register Endpoint 1 FIFO register Endpoint 2 FIFO register Endpoint 3 FIFO register EPDIR INCSR OUTCSR INMAXP OUTMAXP WRTCNTLO WRTCNTHI EP0FIFO EP1FIFO EP2FIFO EP3FIFO 137 138 139 140 141 142 143 144 145 146 147 89H 8AH 8BH 8CH 8DH 8EH 8FH 90H 91H 92H 93H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H 00H W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W 4-5 MEMORY MAP S3FB42F Table 4-1. Registers (Continued) Register Name Control register for random number generator 8-bit linear feedback shift register 16-bit linear feedback shift register lower 16-bit linear feedback shift register higher PLL data register lower PLL data register higher PLL control register Mnemonic RANCON LFSR8 LFSR16L LFSR16H PLLDATAL PLLDATAH PLLCON Decimal 168 169 170 171 172 173 174 Hex A8H A9H AAH ABH ACH ADH AEH Reset - - - - - - 0 R/W R/W R/W R/W R/W R/W R/W R/W Location AFH is not mapped UART line control register UART control register UART status register UART transmit buffer register UART receive buffer register UART band rate divisor register UART interrupt pending register LCON UCON USSR TBR RBR UBRDR UPEND 176 177 178 179 180 181 182 B0H B1H B2H B3H B4H B5H B6H 00H 00H C0H - - 00H 00 R/W R/W R W R R/W R/W Location BFH is not mapped IIC control register IIC status register IIC data register IIC address register IIC pre-scaler register IIC pre-scaler count register for test IICCON IICSR IICDATA IICADDR IICPS IICCNT 184 185 186 187 188 189 B8H B9H BAH BBH BCH BDH 00H 00H - - FFH - R/W R/W R/W R/W R/W R Locations BEH-BFH is not mapped 64-byte IIS I/O buffer BUF64 C0H FFH - R/W 4-6 S3FB42F HARDWARE STACK 5 HARDWARE STACK OVERVIEW The hardware stack in CalmRISC has two usages: -- To save and restore the return PC[19:0] on LCALL, CALLS, RET, and IRET instructions. -- Temporary storage space for registers on PUSH and POP instructions. When PC[19:0] is saved into or restored from the hardware stack, the access should be 20 bits wide. On the other hand, when a register is pushed into or popped from the hardware stack, the access should be 8 bits wide. Hence, to maximize the efficiency of the stack usage, the hardware stack is divided into 3 parts: the extended stack bank (XSTACK, 4-bits wide), the odd bank (8-bits wide), and the even bank (8-bits wide). Hardware Stack 5 3 Level 0 Level 1 Level 2 0 7 0 7 0 Stack Pointer SPTR [5:0] 1 0 Stack Level Pointer Odd or Even Bank Selector Level 14 Level 15 XSTACK Odd Bank Even Bank Figure 5-1. Hardware Stack 5-1 HARDWARE STACK S3FB42F The top of the stack (TOS) is pointed to by a stack pointer, called sptr[5:0]. The upper 5 bits of the stack pointer, sptr[5:1], points to the stack level into which either PC[19:0] or a register is saved. For example, if sptr[5:1] is 5H or TOS is 5, then level 5 of XSTACK is empty and either level 5 of the odd bank or level 5 of the even bank is empty. In fact, sptr[0], the stack bank selection bit, indicates which bank(s) is empty. If sptr[0] = 0, both level 5 of the even and the odd banks are empty. On the other hand, if sptr[0] = 1, level 5 of the odd bank is empty, but level 5 of the even bank is occupied. This situation is well illustrated in the figure below. Level 0 Level 1 Level 2 Level 3 Level 4 Level 5 SPTR [5:0] 5 10 001010 Stack Level Pointer Bank Selector Level 15 XSTACK Odd Bank Even Bank Level 0 Level 1 Level 2 Level 3 Level 4 Level 5 SPTR [5:0] 5 10 001011 Stack Level Pointer Bank Selector Level 15 XSTACK Odd Bank Even Bank Figure 5-2. Even and Odd Bank Selection Example As can be seen in the above example, sptr[5:1] is used as the hardware stack pointer when PC[19:0] is pushed or popped and sptr[5:0] as the hardware stack pointer when a register is pushed or popped. Note that XSTACK is used only for storing and retrieving PC[19:16]. Let us consider the cases where PC[19:0] is pushed into the hardware stack (by executing LCALL/CALLS instructions or by interrupts/exceptions being served) or is retrieved from the hardware stack (by executing RET/IRET instructions). Regardless of the stack bank selection bit (sptr[0]), TOS of the even bank and the odd bank store or return PC[7:0] or PC[15:8], respectively. This is illustrated in the following figures. 5-2 S3FB42F HARDWARE STACK Level 0 SPTR [5:0] 5 10 001010 Stack Level Pointer Level 0 SPTR [5:0] 5 10 001011 Stack Level Pointer Level 5 Level 6 Bank Selector Level 5 Level 6 Bank Selector Level 15 XSTACK Odd Bank Even Bank by Executing CALL, CALLS or Interrupts/Exceptions Level 15 XSTACK Odd Bank Even Bank by Executing CALL, CALLS or Interrupts/Exceptions by Executing RET, IRET by Executing RET, IRET Level 0 SPTR [5:0] 5 10 001100 Stack Level Pointer Level 0 SPTR [5:0] 5 10 001101 Stack Level Pointer Level 5 PC[19:16] Level 6 PC[15:8] PC[7:0] Level 5 PC[19:16] Bank Selector Level 6 PC[7:0] PC[15:8] Bank Selector Level 15 XSTACK Odd Bank Even Bank Level 15 XSTACK Odd Bank Even Bank Figure 5-3. Stack Operation with PC [19:0] As can be seen in the figures, when stack operations with PC[19:0] are performed, the stack level pointer sptr[5:1] (not sptr[5:0]) is either incremented by 1 (when PC[19:0] is pushed into the stack) or decremented by 1 (when PC[19:0] is popped from the stack). The stack bank selection bit (sptr[0]) is unchanged. If a CalmRISC core input signal nP64KW is 0, which signifies that only PC[15:0] is meaningful, then any access to XSTACK is totally deactivated from the stack operations with PC. Therefore, XSTACK has no meaning when the input pin signal, nP64KW, is tied to 0. In that case, XSTACK doesn't have to even exist. As a matter of fact, XSTACK is not included in CalmRISC core itself and it is interfaced through some specially reserved core pin signals (nPUSH, nSTACK, XHSI[3:0], XSHO[3:0]), if the program address space is more than 64K words (See the core pin signal section for details). With regards to stack operations with registers, a similar argument can be made. The only difference is that the data written into or read from the stack are a byte. Hence, the even bank and the odd bank are accessed alternately as shown below. 5-3 HARDWARE STACK S3FB42F Level 0 SPTR [5:0] 5 10 001010 Stack Level Pointer Level 0 SPTR [5:0] 5 10 001011 Stack Level Pointer Level 5 Level 6 Bank Selector Level 5 Level 6 Bank Selector Level 15 XSTACK Odd Bank Even Bank Level 15 XSTACK Odd Bank Even Bank POP Register PUSH Register POP Register PUSH Register Level 0 SPTR [5:0] 5 10 001011 Stack Level Pointer Level 0 SPTR [5:0] 5 10 001100 Stack Level Pointer Level 5 Level 6 Register Level 5 Bank Selector Level 6 Register Bank Selector Level 15 XSTACK Odd Bank Even Bank Level 15 XSTACK Odd Bank Even Bank Figure 5-4. Stack Operation with Registers When the bank selection bit (sptr[0]) is 0, then the register is pushed into the even bank and the bank selection bit is set to 1. In this case, the stack level pointer is unchanged. When the bank selection bit (sptr[0]) is 1, then the register is pushed into the odd bank, the bank selection bit is set to 0, and the stack level pointer is incremented by 1. Unlike the push operations of PC[19:0], any data are not written into XSTACK in the register push operations. This is illustrated in the example figures. When a register is pushed into the stack, sptr[5:0] is incremented by 1 (not the stack level pointer sptr[5:1]). The register pop operations are the reverse processes of the register push operations. When a register is popped out of the stack, sptr[5:0] is decremented by 1 (not the stack level pointer sptr[5:1]). Hardware stack overflow/underflow happens when the MSB of the stack level pointer, sptr[5], is 1. This is obvious from the fact that the hardware stack has only 16 levels and the following relationship holds for the stack level pointer in a normal case. Suppose the stack level pointer sptr[5:1] = 15 (or 01111B in binary format) and the bank selection bit sptr[0] = 1. Here if either PC[19:0] or a register is pushed, the stack level pointer is incremented by 1. Therefore, sptr[5:1] = 16 (or 10000B in binary format) and sptr[5] = 1, which implies that the stack is overflowed. The situation is depicted in the following. 5-4 S3FB42F HARDWARE STACK SPTR [5:0] 5 10 011111 Level 0 Level 1 Level 14 Level 15 XSTACK Odd Bank Even Bank PUSH Register SPTR [5:0] 5 10 100000 Level 0 Level 1 PUSH PC [19:0] SPTR [5:0] 5 10 100001 Level 0 Level 1 PC[7:0] Level 14 Level 15 Register XSTACK Odd Bank Even Bank Level 14 Level 15 PC[19:16] PC[15:8] XSTACK Odd Bank Even Bank Figure 5-5. Stack Overflow The first overflow happens due to a register push operation. As explained earlier, a register push operation increments sptr[5:0] (not sptr[5:1]) , which results in sptr[5] = 1, sptr[4:1] = 0 and sptr[0] = 0. As indicated by sptr[5] = 1, an overflow happens. Note that this overflow doesn't overwrite any data in the stack. On the other hand, when PC[19:0] is pushed, sptr[5:1] is incremented by 1 instead of sptr[5:0], and as expected, an overflow results. Unlike the first overflow, PC[7:0] is pushed into level 0 of the even bank and the data that has been there before the push operation is overwritten. A similar argument can be made about stack underflows. Note that any stack operation, which causes the stack to overflow or underflow, doesn't necessarily mean that any data in the stack are lost, as is observed in the first example. In SR1, there is a status flag, SF (Stack Full Flag), which is exactly the same as sptr[5]. In other words, the value of sptr[5] can be checked by reading SF (or SR1[4]). SF is not a sticky flag in the sense that if there was a stack overflow/underflow but any following stack access instructions clear sptr[5] to 0, then SF = 0 and programmers cannot tell whether there was a stack overflow/underflow by reading SF. For example, if a program pushes a register 64 times in a row, sptr[5:0] is exactly the same as sptr[5:0] before the push sequence. Therefore, special attention should be paid. 5-5 HARDWARE STACK S3FB42F Another mechanism to detect a stack overflow/underflow is through a stack exception. A stack exception happens only when the execution of any stack access instruction results in SF = 1 (or sptr[5] = 1). Suppose a register push operation makes SF = 1 (the SF value before the push operation doesn't matter). Then the stack exception due to the push operation is immediately generated and served If the stack exception enable flag (exe of SR0) is 1. If the stack exception enable flag is 0, then the generated interrupt is not served but pending. Sometime later when the stack exception enable flag is set to 1, the pending exception request is served even if SF = 0. More details are available in the stack exception section. 5-6 S3FB42F EXCEPTIONS 6 OVERVIEW EXCEPTIONS Exceptions in CalmRISC are listed in the table below. Exception handling routines, residing at the given addresses in the table, are invoked when the corresponding exception occurs. The starting address of each exception routine is specified by concatenating 0H (leading 4 bits of 0) and the 16-bit data in the exception vector listed in the table. For example, the interrupt service routine for NMI starts from 0H:PM[00001H]. Note that ":" means concatenation and PM[*] stands for the 16-bit content at the address * of the program memory. Aside from the exception due to reset release, the current PC is pushed in the stack on an exception. When an exception is executed due to NMI/IRQ[1:0]/IEXP, the global interrupt enable flag, ie bit (SR0[1]), is set to 0, whereas ie is set to 1 when IRET or an instruction that explicitly sets ie is executed. Table 6-1. Exceptions Name Reset NMI IRQ[0] IRQ[1] IEXP - - - NOTE: Address 00000H 00001H 00002H 00003H 00004H 00005H 00006H 00007H Priority 1 st 2 nd 4 th 5 th 3 rd - - - Exception due to reset release. Description Exception due to nNMI signal. Non-maskable. Exception due to nIRQ[0] signal. Maskable by setting ie/ie0. Exception due to nIRQ[1] signal. Maskable by setting ie/ie1. Exception due to stack full. Maskable by setting exe. Reserved. Reserved. Reserved. Break mode due to BKREQ has a higher priority than all the exceptions above. That is, when BKREQ is active, even the exception due to reset release is not executed. HARDWARE RESET When Hardware Reset is active (the reset input signal pin nRES = 0), the control pins in the CalmRISC core are initialized to be disabled, and SR0 and sptr (the hardware stack pointer) are initialized to be 0. Additionally, the interrupt sensing block is cleared. When Hardware Reset is released (nRES = 1), the reset exception is executed by loading the JP instruction in IR (Instruction Register) and 0h:0000h in PC. Therefore, when Hardware Reset is released, the "JP {0h:PM[00000h]}" instruction is executed. When the reset exception is executed, a core output signal nEXPACK is generated to acknowledge the exception. 6-1 EXCEPTIONS S3FB42F NMI EXCEPTION (EDGE SENSITIVE) On the falling edge of a core input signal nNMI, the NMI exception is executed by loading the CALL instruction in IR and 0h:0001h in PC. Therefore, when NMI exception is activated, the "CALL {0h:PM[00001h]}" instruction is executed. When the NMI exception is executed, the ie bit (SR0[1]) becomes 0 and a core output signal nEXPACK is generated to acknowledge the exception. IRQ[0] EXCEPTION (LEVEL-SENSITIVE) When a core input signal nIRQ[0] is low, SR0[6] (ie0) is high, and SR0[1] (ie) is high, IRQ[0] exception is generated, and this will load the CALL instruction in IR (Instruction Register) and 0h:0002h in PC. Therefore, on an IRQ[0] exception, the "CALL {0h:PM[00002h]}" instruction is executed. When the IRQ[0] exception is executed, SR0[1] (ie) is set to 0 and a core output signal nEXPACK is generated to acknowledge the exception. IRQ[1] EXCEPTION (LEVEL-SENSITIVE) When a core input signal nIRQ[1] is low, SR0[7] (ie1) is high, and SR0[1] (ie) is high, IRQ[1] exception is generated, and this will load the CALL instruction in IR (Instruction Register) and 0h:0003h in PC. Therefore, on an IRQ[1] exception, the "CALL {0h:PM[00003h]}" instruction is executed. When the IRQ[1] exception is executed, SR0[1] (ie) is set to 0 and a core output signal nEXPACK is generated to acknowledge the exception. HARDWARE STACK FULL EXCEPTION A Stack Full exception occurs when a stack operation is performed and as a result of the stack operation sptr[5] (SF) is set to 1. If the stack exception enable bit, exe (SR0[5]), is 1, the Stack Full exception is served. One exception to this rule is when nNMI causes a stack operation that sets sptr[5] (SF), since it has higher priority. Handling a Stack Full exception may cause another Stack Full exception. In this case, the new exception is ignored. On a Stack Full exception, the CALL instruction is loaded in IR (Instruction Register) and 0h:0004h in PC. Therefore, when the Stack Full exception is activated, the "CALL {0h:PM[00004h]}" instruction is executed. When the exception is executed, SR0[1] (ie) is set to 0, and a core output signal nEXPACK is generated to acknowledge the exception. BREAK EXCEPTION Break exception is reserved only for an in-circuit debugger. When a core input signal, BKREQ, is high, the CalmRISC core is halted or in the break mode, until BKREQ is deactivated. Another way to drive the CalmRISC core into the break mode is by executing a break instruction, BREAK. When BREAK is fetched, it is decoded in the fetch cycle (IF stage) and the CalmRISC core output signal nBKACK is generated in the second cycle (ID/MEM stage). An in-circuit debugger generates BKREQ active by monitoring nBKACK to be active. BREAK instruction is exactly the same as the NOP (no operation) instruction except that it does not increase the program counter and activates nBKACK in the second cycle (or ID/MEM stage of the pipeline). There, once BREAK is encountered in the program execution, it falls into a deadlock. BREAK instruction is reserved for in-circuit debuggers only, so it should not be used in user programs. 6-2 S3FB42F EXCEPTIONS EXCEPTIONS (or INTERRUPTS) Level Reset NMI Vector 0000H 0001H Source Reset or WDT overflow Non-maskable interrupt WT INT IVEC0 0002H TB INT TA INT Ext INT 8 IIS1 INT IIS0 INT IVEC1 0003H Ext INT 4 Ext INT 5 Ext INT 0 Ext INT 1 Ext INT 2 Ext INT 3 BT SIO INT IIC INT UART Rx/Error/Tx INT USB/PPIC INT Ext INT 9 SF_EXCEP 0004H Stack Full Exception Reset (Clear) H/W H/W H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W (S/W) H/W NOTES: 1. NMI has the highest priority for an interrupt level, followed by SF_EXCEP, IVEC0 and IVEC1. 2. In the case of IVEC0 and IVEC1, one interrupt vector has several interrupt sources. The priority of the sources is controlled by setting the IPR register. 3. External interrupts are triggered by a rising or falling edge, depending on the corresponding control register setting, Ext INT0-Ext INT5 have no interrupt pending bit but have an enable bit. 4. After system reset, IIS0 INT has the highest priority in the IVEC0 level, followed by IIS1 INT and other interrupt sources. 5. The interrupt priority can be changed by setting of IPR register. 6. The pending bit is cleared by hardware when CPU reads the IIR register value. Figure 6-1. Interrupt Structure 6-3 EXCEPTIONS S3FB42F Clear (when writing clear bit value to bit .2 .1 .0) exmp) LD R0, #05H LD IIR0, R0 IRQ.5 is cleared IIR0 IIS0 INT IIS1 INT Ext INT8 IRQ0.0 IRQ0.1 IRQ0.2 IRQ0.3 IRQ0.4 IMR0 Logic IPR0 Logic TA INT TB INT NT INT IRQ0.5 IRQ0.6 IRQ0.7 IMR0 IPR0 IVEC0 STOP & IDLE Release CPU Ext INT9 USB INT PPIC INT UART_Rx INT UART_Err INT UART_Tx INT IIC INT SIO INT BT INT Ext INT0 Ext INT1 Ext INT2 Ext INT3 Ext INT4 Ext INT5 IRQ1.0 IRQ1.1 IRQ1.2 IRQ1.3 IRQ1.4 IRQ1.5 IRQ1.6 IRQ1.7 IMR1 IRP1 IVEC1 IMR1 Logic IPR1 Logic IIR1 Clear (when writing clear bit value to bit .2 .1 .0) exmp) LD R0, #02H LD IIR1, R0 IRQ1.2 is cleared NOTE: The IRQ register value is cleared by H/W when the IIR register is read by the programmer in an interrupt service routine. However, if you want to clear by S/W, then write the proper value to the IIR register like above examples. For clear all the bits of IRQx register at one time write "#08h" to the IIRx register. Figure 6-2. Interrupt Structure 6-4 S3FB42F EXCEPTIONS INTERRUPT MASK REGISTERS Interrupt Mask Register0 (IMR0) 05H, R/W .7 .6 .5 .4 .3 .2 .1 .0 IRQ0.4 IRQ0.5 IRQ0.6 IRQ0.7 IRQ0.3 IRQ0.2 IRQ0.1 IRQ0.0 Interrupt Mask Register1 (IMR1) 09H, R/W .7 .6 .5 .4 .3 .2 .1 .0 IRQ1.4 IRQ1.5 IRQ1.6 IRQ1.7 IRQ1.3 IRQ1.2 IRQ1.1 IRQ1.0 Interrupt request enable bits: 0 = Disable interrupt request 1 = Enable interrupt request NOTE: If you want to change the value of the IMR register, then you first make disable global INT by DI instruction, and change the value of the IMR register. Figure 6-3. Interrupt Mask Register 6-5 EXCEPTIONS S3FB42F INTERRUPT PRIORITY REGISTER IPR GROUP A IPR GROUP B IPR GROUP C IRQ0 IRQ1 IRQ2 IRQ3 IRQ4 IRQ5 IRQ6 IRQ7 Interrupt Priority Registers (IPR0:06H,IPR1:0AH, R/W ) .7 .6 .5 .4 .3 .2 .1 .0 Group priority: .7 .4 .1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 Not used B>C>A A>B>C B>A>C C>A>B C>B>A A>C>B Not used GROUP A 0 = IRQ0 > IRQ1 1 = IRQ1 > IRQ0 GROUP B 0 = IRQ2 > (IRQ3,IRQ4) 1 = (IRQ3,IRQ4) > IRQ2 SUBGROUP B 0 = IRQ3 > IRQ4 1 = IRQ4 > IRQ3 GROUP C 0 = IRQ5 > (IRQ6,IRQ7) 1 = (IRQ6,IRQ7) > IRQ5 SUBGROUP C 0 = IRQ6 > IRQ7 1 = IRQ7 > IRQ6 NOTE: If you want to change the value of the IPR register, then you first make disable global INT by DI instruction, and change the value of the IPR register. Figure 6-4. Interrupt Priority Register 6-6 S3FB42F EXCEPTIONS F PROGRAMMING TIP -- Interrupt Programming Tip 1 Jumped from vector 2 PUSH SR1 PUSH R0 AND SR0, #0FEh LD R0, IIR0 CP R0, #03h JR ULE, LTE03 CP R0, #05h JR ULE, LTE05 CP R0, #06h JP EQ, IRQ6_srv JP IRQ7_srv CP R0, #04h JP EQ, IRQ4_srv JP IRQ5_srv CP R0, #01h JR ULE, LTE01 CP R0, #02h JP EQ, IRQ2_srv JP IRQ3_srv CP R0, #00h JP EQ, IRQ0_srv JP IRQ1_srv service for IRQ0 * * LTE05 LTE03 LTE01 IRQ0_srv IRQ1_srv POP R0 POP SR1 IRET service for IRQ1 * * POP POP IRET * * R0 SR1 IRQ7_srv service for IRQ7 * * POP POP IRET NOTE: R0 SR1 If the SR0 register is changed in the interrupt service routine, then the SR0 register must be pushed and poped in the interrupt service routine. 6-7 EXCEPTIONS S3FB42F F PROGRAMMING TIP -- Interrupt Programming Tip 2 Jumped from vector 2 PUSH SR1 PUSH R0 PUSH R1 LD R0, IIR0 SL R0 LD R1, # < TBL_INTx ADD R0, # > TBL_INTx PUSH R0 PUSH R1 RET LJP IRQ0_svr LJP IRQ1_svr LJP IRQ2_svr LJP IRQ3_svr LJP IRQ4_svr LJP IRQ5_svr LJP IRQ6_svr LJP IRQ7_svr service for IRQ0 * * TBL_INTx IRQ0_srv IRQ1_srv POP R1 POP R0 POP SR1 IRET service for IRQ1 * * POP POP POP IRET * * R1 R0 SR1 IRQ7_srv service for IRQ7 * * POP POP POP IRET R1 R0 SR1 NOTES: 1. If the SR0 register is changed in the interrupt service routine, then the SR0 register must be pushed and poped in the interrupt service routine. 2. Above example is assumed that the ROM size is less than 64Kword and all the LJP instructions which is in the jump table (TBL-INTx) is in the same page. 6-8 S3FB42F COPROCESSOR INTERFACE 7 OVERVIEW COPROCESSOR INTERFACE CalmRISC supports an efficient and seamless interface with coprocessors. By integrating a MAC (multiply and accumulate) DSP coprocessor engine with the CalmRISC core, not only the microcontroller functions but also complex digital signal processing algorithms can be implemented in a single development platform (or MDS). CalmRISC has a set of dedicated signal pins, through which data/command/status are exchanged to and from a coprocessor. Figure 7-1 depicts the coprocessor signal pins and the interface between two processors. Data RAM [23:0] Data Bus [7:0] SYSCP [11:0] nCOPID Program ROM CalmRISC nCLDID Coprocessor CLDWR EC[2:0] Figure 7-1. Coprocessor Interface Diagram [23:0] [7:0] 7-1 COPROCESSOR INTERFACE S3FB42F As shown in the coprocessor interface diagram above, the coprocessor interface signals of CalmRISC are: SYSCP[11:0], nCOPID, nCLDID, nCLDWR, and EC[2:0]. The data are exchanged through data buses, DI[7:0] and DO[7:0]. A command is issued from CalmRISC to a coprocessor through SYSCP[11:0] in COP instructions. The status of a coprocessor can be sent back to CalmRISC through EC[2:0] and these flags can be checked in the condition codes of branch instructions. The coprocessor instructions are listed in the following table Table 7-1. Coprocessor instructions Mnemonic COP CLD CLD JP(or JR) CALL LNK Op 1 #imm:12 GPR imm:8 EC2-EC0 Op 2 - imm:8 GPR label Coprocessor operation Data transfer from coprocessor into GPR Data transfer of GPR to coprocessor Conditional branch with coprocessor status flags Description The coprocessor of CalmRISC does not have its own program memory (i.e., it is a passive coprocessor) as shown in Figure 7 -1. In fact, the coprocessor instructions are fetched and decoded by CalmRISC, and CalmRISC issues the command to the coprocessor through the interface signals. For example, if "COP #imm:12" instruction is fetched, then the 12-bit immediate value (imm:12) is loaded on SYSCP[11:0] signal with nCOPID active in ID/MEM stage, to request the coprocessor to perform the designated operation. The interpretation of the 12-bit immediate value is totally up to the coprocessor. By arranging the 12-bit immediate field, the instruction set of the coprocessor is determined. In other words, CalmRISC only provides a set of generic coprocessor instructions, and its installation to a specific coprocessor instruction set can differ from one coprocessor to another. CLD Write instructions ("CLD imm:8, GPR") put the content of a GPR register of CalmRISC on the data bus (DO[7:0] ) and issue the address(imm:8) of the coprocessor internal register on SYSCP[7:0] with nCLDID active and CLDWR active. CLD Read instructions ("CLD GPR, imm:8" in Table 7-1) work similarly, except that the content of the coprocessor internal register addressed by the 8-bit immediate value is read into a GPR register through DI[7:0] with nCLDID active and CLDWR deactivated. The timing diagram given below is a coprocessor instruction pipeline and shows when the coprocessor performs the required operations. Suppose I2 is a coprocessor instruction. First, it is fetched and decoded by CalmRISC (at t = T(i1)). Once it is identified as a coprocessor instruction, CalmRISC indicates to the coprocessor the appropriate command through the coprocessor interface signals (at t = T(i)). Then the coprocessor performs the designated tasks at t = T(i) and t = T(i+1). Hence IF from CalmRISC and then ID/MEM and EX from the coprocessor constitute the pipeline for I2. Similarly, if I3 is a coprocessor instruction, the coprocessor's ID/MEM and EX stages replace the corresponding stages of CalmRISC. 7-2 S3FB42F COPROCESSOR INTERFACE CalmRISC T (i -1) T (i) T (i +1) I1: Normal Instruction I2: Coprocessor Instruction I3: Coprocessor Instruction Coprocessor Interface Signals IF ID/MEM IF EX ID/MEM IF EX ID/MEM EX For I2 For I3 Coprocessor I2: I3: ID/MEM EX ID/MEM EX Figure 7-2. Coprocessor Instruction Pipeline In a multi-processor system, the data transfer between processors is an important factor to determine the efficiency of the overall system. Suppose an input data stream is accepted by a processor, in order for the data to be shared by another processors. There should be some efficient mechanism to transfer the data to the processors. In CalmRISC, data transfers are accomplished through a single shared data memory. The shared data memory in a multi-processor has some inherent problems such as data hazards and deadlocks. However, the coprocessor in CalmRISC accesses the shared data memory only at the designated time by CalmRISC at which time CalmRISC is guaranteed not to access the data memory, and therefore there is no contention over the shared data memory. Another advantage of the scheme is that the coprocessor can access the data memory in its own bandwidth. 7-3 COPROCESSOR INTERFACE S3FB42F NOTES 7-4 S3FB42F INSTRUCTION SET 8 OVERVIEW GLOSSARY INSTRUCTION SET This chapter describes the CalmRISC instruction set and the details of each instruction are listed in alphabetical order. The following notations are used for the description. Table 8-1. Instruction Notation Conventions Notation Interpretation Operand N. N can be omitted if there is only one operand. Typically, As additional note, only the affected flags are described in the tables in this section. That is, if a flag is not affected by an operation, it is NOT specified. 8-1 INSTRUCTION SET S3FB42F INSTRUCTION SET MAP Table 8-2. Overall Instruction Set Map IR [15:13,7:2] 000 xxxxxx 001 xxxxxx [12:10]000 ADD GPR, #imm:8 ADD GPR, @idm ADD GPR, adr:8 ADC GPR, adr:8 ADD GPR, GPR ADC GPR, GPR invalid AND GPR, GPR SLA/SL/ RLC/RL/ SRA/SR/ RRC/RR/ GPR 001 SUB GPR, #imm:8 SUB GPR, @idm SUB GPR, adr:8 SBC GPR, adr:8 SUB GPR, GPR SBC GPR, GPR invalid OR GPR, GPR INC/INCC/ DEC/ DECC/ COM/ COM2/ COMC GPR LD GPR, SPR 010 CP GPR, #imm8 CP GPR, @idm CP GPR, adr:8 CPC GPR, adr:8 CP GPR, GPR CPC GPR, GPR invalid XOR GPR, GPR invalid 011 LD GPR, #imm:8 LD GPR, @idm LD GPR, adr:8 LD adr:8, GPR 100 TM GPR, #imm:8 LD @idm, GPR 101 AND GPR, #imm:8 AND GPR, @idm 110 OR GPR, #imm:8 OR GPR, @idm 111 XOR GPR, #imm:8 XOR GPR, @idm 010 xxxxxx BITT adr:8.bs BITS adr:8.bs 011 xxxxxx BITR adr:8.bs BITC adr:8.bs 100 000000 BMS/BMC LD SPR0, #imm:8 invalid AND GPR, adr:8 OR GPR, adr:8 XOR GPR, adr:8 100 000001 100 000010 100 000011 invalid invalid 100 00010x invalid 100 00011x LD SPR, GPR SWAP GPR, SPR invalid LD GPR, GPR LD TBH/TBL, GPR invalid LD GPR, TBH/TBL 100 00100x 100 001010 PUSH SPR POP SPR PUSH GPR POP GPR 8-2 S3FB42F INSTRUCTION SET Table 8-2. Overall Instruction Set Map (Continued) IR 100 001011 [12:10]000 POP 001 invalid 010 LDC 011 invalid 100 LD SPR0, #imm:8 101 AND GPR, adr:8 110 OR GPR, adr:8 111 XOR GPR, adr:8 100 00110x RET/LRET/I RET/NOP/ BREAK invalid LD GPR:bank, GPR:bank invalid invalid invalid invalid 100 00111x 100 01xxxx invalid AND SR0, #imm:8 invalid invalid OR SR0, #imm:8 invalid invalid BANK #imm:2 invalid 100 100000 100 110011 100 1101xx 100 1110xx 100 1111xx [15:10] 101 xxx 110 0xx 110 1xx 111 xxx NOTE: LCALL cc:4, imm:20 (2-word instruction) LLNK cc:4, imm:20 (2-word instruction) LJP cc:4, imm:20 (2-word instruction) JR cc:4, imm:9 CALLS imm:12 LNKS imm:12 CLD GPR, imm:8 / CLD imm:8, GPR / JNZD GPR, imm:8 / SYS #imm:8 / COP #imm:12 "invalid" - invalid instruction. 8-3 INSTRUCTION SET S3FB42F Table 8-3. Instruction Encoding Instruction ADD GPR, #imm:8 SUB GPR, #imm:8 CP GPR, #imm:8 LD GPR, #imm:8 TM GPR, #imm:8 AND GPR, #imm:8 OR GPR, #imm:8 XOR GPR, #imm:8 ADD GPR, @idm SUB GPR, @idm CP GPR, @idm LD GPR, @idm LD @idm, GPR AND GPR, @idm OR GPR, @idm XOR GPR, @idm ADD GPR, adr:8 SUB GPR, adr:8 CP GPR, adr:8 LD GPR, adr:8 BITT adr:8.bs BITS adr:8.bs ADC GPR, adr:8 SBC GPR, adr:8 CPC GPR, adr:8 LD adr:8, GPR BITR adr:8.bs BITC adr:8.bs 011 010 001 15 14 000 13 12 11 000 001 010 011 100 101 110 111 000 001 010 011 100 101 110 111 000 001 010 011 10 11 000 001 010 011 10 11 bs GPR adr[7:0] bs GPR adr[7:0] GPR idx mod offset[4:0] 10 9 8 7 6 5 4 3 2 1 0 GPR imm[7:0] 8-4 S3FB42F INSTRUCTION SET Table 8-3. Instruction Encoding (Continued) Instruction ADD GPRd, GPRs SUB GPRd, GPRs CP GPRd, GPRs BMS/BMC ADC GPRd, GPRs SBC GPRd, GPRs CPC GPRd, GPRs invalid invalid AND GPRd, GPRs OR GPRd, GPRs XOR GPRd, GPRs invalid ALUop1 ALUop2 invalid LD SPR, GPR LD GPR, SPR SWAP GPR, SPR LD TBL, GPR LD TBH, GPR PUSH SPR POP SPR invalid PUSH GPR POP GPR LD GPRd, GPRs LD GPR, TBL LD GPR, TBH POP LDC @IL LDC @IL+ Invalid NOTE: "x" means not applicable. 15 14 100 13 12 11 000 001 010 011 000 001 010 011 ddd 000 001 010 011 000 001 10 9 8 7 6 5 4 3 2 1 0 GPRd 000000 GPRs 000001 000010 000011 GPR GPR xx GPR GPR GPR GPR 00010 ALUop1 ALUop2 xxx 010-011 000 001 010 011 00011 SPR SPR SPR x x 0 1 SPR SPR xxx x x 000 001 010-011 000 001 010 011 xx xx xx GPR GPR GPRd GPR 00100 001010 GPR GPR GPRs 0 1 x x xx 0 1 x x xx 000 010 xx 001011 001, 011 8-5 INSTRUCTION SET S3FB42F Table 8-3. Instruction Encoding (Concluded) Instruction MODop1 Invalid Invalid AND SR0, #imm:8 OR SR0, #imm:8 BANK #imm:2 15-13 100 12 11 000 001-011 000 001 010 011 10 9 xx xx xx imm[7:6] imm[7:6] xx x imm [1:0] Invalid LCALL cc, imm:20 LLNK cc, imm:20 LJP cc, imm:20 LD SPR0, #imm:8 AND GPR, adr:8 OR GPR, adr:8 XOR GPR, adr:8 JR cc, imm:9 101 imm [8] 8 7 6 5 00110 4 3 2 1 MODop1 xxx 0 2nd word - 01 xxxxxx imm[5:0] xxx 0 xxxx cc 10000000-11001111 1101 imm[19:16] imm[15:0] 1 00 01 10 11 cc SPR0 GPR IMM[7:0] ADR[7:0] - imm[7:0] CALLS imm:12 LNKS imm:12 CLD GPR, imm:8 CLD imm:8, GPR JNZD GPR, imm:8 SYS #imm:8 COP #imm:12 110 0 1 imm[11:0] 111 0 00 01 10 11 GPR GPR GPR xx imm[11:0] imm[7:0] 1 NOTES: 1. "x" means not applicable. 2. There are several MODop1 codes that can be used, as described in table 8-9. 3. The operand 1(GPR) of the instruction JNZD is Bank 3's register. 8-6 S3FB42F INSTRUCTION SET Table 8-4. Index Code Information ("idx") Symbol ID0 ID1 Code 0 1 Index 0 IDH:IDL0 Index 1 IDH:IDL1 Description Table 8-5. Index Modification Code Information ("mod") Symbol @IDx + offset:5 @[IDx - offset:5] Code 00 01 Function DM[IDx], IDx IDx + offset DM[IDx + (2's complement of offset:5)], IDx IDx + (2's complement of offset:5) @[IDx + offset:5]! @[IDx - offset:5]! NOTE: 10 11 DM[IDx + offset], IDx IDx DM[IDx + (2's complement of offset:5)], IDx IDx Carry from IDL is propagated to IDH. In case of @[IDx - offset:5] or @[IDx - offset:5]!, the assembler should convert offset:5 to the 2's complement format to fill the operand field (offset[4:0]). Furthermore, @[IDx - 0] and @[IDx - 0]! are converted to @[IDx + 0] and @[IDx + 0]!, respectively. Table 8-6. Condition Code Information ("cc") Symbol (cc:4) Blank NC or ULT C or UGE Z or EQ NZ or NE OV ULE UGT ZP MI PL ZN SF EC0-EC2 NOTE: Code 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101-1111 always Function C = 0, unsigned less than C = 1, unsigned greater than or equal to Z = 1, equal to Z = 0, not equal to V = 1, overflow - signed value ~C | Z, unsigned less than or equal to C & ~Z, unsigned greater than N = 0, signed zero or positive N = 1, signed negative ~N & ~Z, signed positive Z | N, signed zero or negative Stack Full EC[0] = 1/EC[1] = 1/EC[2] = 1 EC[2:0] is an external input (CalmRISC core's point of view) and used as a condition. 8-7 INSTRUCTION SET S3FB42F Table 8-7. "ALUop1" Code Information Symbol SLA SL RLC RL SRA SR RRC RR Code 000 001 010 011 100 101 110 111 arithmetic shift left shift left rotate left with carry rotate left arithmetic shift right shift right rotate right with carry rotate right Function Table 8-8. "ALUop2" Code Information Symbol INC INCC DEC DECC COM COM2 COMC - Code 000 001 010 011 100 101 110 111 increment increment with carry decrement decrement with carry 1's complement 2's complement 1's complement with carry reserved Function Table 8-9. "MODop1" Code Information Symbol LRET RET IRET NOP BREAK - - - Code 000 001 010 011 100 101 110 111 return by IL return by HS return from interrupt (by HS) no operation reserved for debugger use only reserved reserved reserved Function 8-8 S3FB42F INSTRUCTION SET QUICK REFERENCE Operation AND OR XOR ADD SUB CP ADC SBC CPC TM BITS BITR BITC BITT BMS/BMC PUSH POP PUSH POP POP SLA SL RLC RL SRA SR RRC RR INC INCC DEC DECC COM COM2 COMC op1 GPR op2 adr:8 #imm:8 GPR @idm GPR GPR adr:8 GPR R3 #imm:8 adr:8.bs Function op1 op1 & op2 op1 op1 | op2 op1 op1 ^ op2 op1 op1 + op2 op1 op1 + ~op2 + 1 op1 + ~op2 + 1 op1 op1 + op2 + c op1 op1 + ~op2 + c op1 + ~op2 + c op1 & op2 op1 (op2[bit] 1) op1 (op2[bit] 0) op1 ~(op2[bit]) z ~(op2[bit]) TF 1 / 0 HS[sptr] GPR, (sptr sptr + 1) GPR HS[sptr - 1], (sptr sptr - 1) HS[sptr] SPR, (sptr sptr + 1) SPR HS[sptr - 1], (sptr sptr - 1) sptr sptr - 2 c op1[7], op1 {op1[6:0], 0} c op1[7], op1 {op1[6:0], 0} c op1[7], op1 {op1[6:0], c} c op[7], op1 {op1[6:0], op1[7]} c op[0], op1 {op1[7],op1[7:1]} c op1[0], op1 {0, op1[7:1]} c op1[0], op1 {c, op1[7:1]} c op1[0], op1 {op1[0], op1[7:1]} p1 op1 + 1 op1 op1 + c op1 op1 + 0FFh op1 op1 + 0FFh + c op1 ~op1 op1 ~op1 + 1 op1 ~op1 + c Flag z,n z,n z,n c,z,v,n c,z,v,n c,z,v,n c,z,v,n c,z,v,n c,z,v,n z,n z z z z - - z,n - - c,z,v,n c,z,n c,z,n c,z,n c,z,n c,z,n c,z,n c,z,n c,z,v,n c,z,v,n c,z,v,n c,z,v,n z,n c,z,v,n c,z,v,n # of word / cycle 1W1C - GPR SPR - GPR - - - - - 8-9 INSTRUCTION SET S3FB42F QUICK REFERENCE (Continued) Operation LD LD LD op1 GPR :bank SPR0 GPR op2 GPR :bank #imm:8 GPR SPR adr:8 @idm #imm:8 TBH/TBL GPR GPR GPR - #imm:8 op1 op2 op1 op2 op1 op2 Function Flag z,n - z,n # of word / cycle 1W1C LD LD LD LDC AND OR BANK SWAP LCALL cc SPR TBH/TBL adr:8 @idm @IL @IL+ SR0 op1 op2 op1 op2 op1 op2 (TBH:TBL) PM[(ILX:ILH:ILL)], ILL++ if @IL+ SR0 SR0 & op2 SR0 SR0 | op2 SR0[4:3] op2 op1 op2, op2 op1 (excluding SR0/SR1) If branch taken, push XSTACK, HS[15:0] {PC[15:12],PC[11:0] + 2} and PC op1 else PC[11:0] PC[11:0] + 2 If branch taken, IL[19:0] {PC[19:12], PC[11:0] + 2} and PC op1 else PC[11:0] PC[11:0] + 2 push XSTACK, HS[15:0] {PC[15:12], PC[11:0] + 1} and PC[11:0] op1 IL[19:0] {PC[19:12], PC[11:0] + 1} and PC[11:0] op1 if (Rn == 0) PC PC[delay slot] - 2's complement of imm:8, Rn-else PC PC[delay slot]++, Rn-If branch taken, PC op1 else PC[11:0] < PC[11:0] + 2 If branch taken, PC[11:0] PC[11:0] + op1 else PC[11:0] PC[11:0] + 1 - - - - - 1W2C 1W1C #imm:2 GPR imm:20 - SPR - - - - 2W2C LLNK cc imm:20 - - CALLS LNKS JNZD imm:12 imm:12 Rn - - imm:8 - - - 1W2C LJP cc imm:20 - - 2W2C JR cc imm:9 - - 1W2C NOTE: op1 - operand1, op2 - operand2, 1W1C - 1-Word 1-Cycle instruction, 1W2C - 1-Word 2-Cycle instruction, 2W2C 2-Word 2-Cycle instruction. The Rn of instruction JNZD is Bank 3's GPR. 8-10 S3FB42F INSTRUCTION SET QUICK REFERENCE (Concluded) Operation LRET RET IRET NOP BREAK SYS CLD CLD COP op1 - op2 - Function PC IL[19:0] PC HS[sptr - 2], (sptr sptr - 2) PC HS[sptr - 2], (sptr sptr - 2) no operation no operation and hold PC no operation but generates SYSCP[7:0] and nSYSID op1 op2, generates SYSCP[7:0], nCLDID, and CLDWR op1 op2, generates SYSCP[7:0], nCLDID, and CLDWR generates SYSCP[11:0] and nCOPID Flag - # of word / cycle 1W2C 1W2C 1W2C 1W1C 1W1C 1W1C #imm:8 imm:8 GPR #imm:12 - GPR imm:8 - - - z,n - NOTES: 1. op1 - operand1, op2 - operand2, sptr - stack pointer register, 1W1C - 1-Word 1-Cycle instruction, 1W2C - 1-Word 2-Cycle instruction 2. Pseudo instructions -- SCF/RCF Carry flag set or reset instruction -- STOP/IDLE MCU power saving instructions -- EI/DI Exception enable and disable instructions -- JP/LNK/CALL If JR/LNKS/CALLS commands (1 word instructions) can access the target address, there is no conditional code in the case of CALL/LNK, and the JP/LNK/CALL commands are assembled to JR/LNKS/CALLS in linking time, or else the JP/LNK/CALL commands are assembled to LJP/LLNK/LCALL (2 word instructions) instructions. 8-11 INSTRUCTION SET S3FB42F INSTRUCTION GROUP SUMMARY ALU INSTRUCTIONS "ALU instructions" refer to the operations that use ALU to generate results. ALU instructions update the values in Status Register 1 (SR1), namely carry (C), zero (Z), overflow (V), and negative (N), depending on the operation type and the result. ALUop GPR, adr:8 Performs an ALU operation on the value in GPR and the value in DM[adr:8] and stores the result into GPR. ALUop = ADD, SUB, CP, AND, OR, XOR For SUB and CP, GPR+(not DM[adr:8])+1 is performed. adr:8 is the offset in a specific data memory page. The data memory page is 0 or the value of IDH (Index of Data Memory Higher Byte Register), depending on the value of eid in Status Register 0 (SR0). Operation GPR GPR ALUop DM[00h:adr:8] if eid = 0 GPR GPR ALUop DM[IDH:adr8] if eid = 1 Note that this is an 8-bit operation. Example ADD R0, 80h // Assume eid = 1 and IDH = 01H // R0 R0 + DM[0180h] ALUop GPR, #imm:8 Stores the result of an ALU operation on GPR and an 8-bit immediate value into GPR. ALUop = ADD, SUB, CP, AND, OR, XOR For SUB and CP, GPR+(not #imm:8)+1 is performed. #imm:8 is an 8-bit immediate value. Operation GPR GPR ALUop #imm:8 Example ADD R0, #7Ah // R0 R0 + 7Ah 8-12 S3FB42F INSTRUCTION SET ALUop GPRd, GPRs Store the result of ALUop on GPRs and GPRd into GPRd. ALUop = ADD, SUB, CP, AND, OR, XOR For SUB and CP, GPRd + (not GPRs) + 1 is performed. GPRs and GPRd need not be distinct. Operation GPRd GPRd ALUop GPRs GPRd - GPRs when ALUop = CP (comparison only) Example ADD R0, R1 ALUop GPR, @idm Performs ALUop on the value in GPR and DM[ID] and stores the result into GPR. Index register ID is IDH:IDL (IDH:IDL0 or IDH:IDL1). ALUop = ADD, SUB, CP, AND, OR, XOR For SUB and CP, GPR+(not DM[idm])+1 is performed. idm = IDx+off:5, [IDx-offset:5], [IDx+offset:5]!, [IDx-offset:5]! (IDx = ID0 or ID1) Operation GPR - DM[idm] when ALUop = CP (comparison only) GPR GPR ALUop DM[IDx], IDx IDx + offset:5 when idm = IDx + offset:5 GPR GPR ALUop DM[IDx - offset:5], IDx IDx - offset:5 when idm = [IDx - offset:5] GPR GPR ALUop DM[IDx + offset:5] when idm = [IDx + offset:5]! GPR GPR ALUop DM[IDx - offset:5] when idm = [IDx - offset:5]! When carry is generated from IDL (on a post-increment or pre-decrement), it is propagated to IDH. Example ADD R0, @ID0+2 ADD R0, @[ID0-2] ADD R0, @[ID1+2]! ADD R0, @[ID1-2]! // assume ID0 = 02FFh // R0 R0 + DM[02FFh], IDH 03h and IDL0 01h // assume ID0 = 0201h // R0 R0 + DM[01FFh], IDH 01h and IDL0 FFh // assume ID1 = 02FFh // R0 R0 + DM[0301], IDH 02h and IDL1 FFh // assume ID1 = 0200h // R0 R0 + DM[01FEh], IDH 02h and IDL1 00h // R0 R0 + R1 8-13 INSTRUCTION SET S3FB42F ALUopc GPRd, GPRs Performs ALUop with carry on GPRd and GPRs and stores the result into GPRd. ALUopc = ADC, SBC, CPC GPRd and GPRs need not be distinct. Operation GPRd GPRd + GPRs + C when ALUopc = ADC GPRd GPRd + (not GPRs) + C when ALUopc = SBC GPRd + (not GPRs) + C when ALUopc = CPC (comparison only) Example ADD R0, R2 ADC R1, R3 SUB R0, R2 SBC R1, R3 CP R0, R2 CPC R1, R3 ALUopc GPR, adr:8 Performs ALUop with carry on GPR and DM[adr:8]. Operation GPR GPR + DM[adr:8] + C when ALUopc = ADC GPR GPR + (not DM[adr:8]) + C when ALUopc = SBC GPR + (not DM[adr:8]) + C when ALUopc = CPC (comparison only) CPLop GPR (Complement Operations) CPLop = COM, COM2, COMC Operation COM GPR COM2 GPR COMC GPR Example COM2 R0 COMC R1 // assume R1:R0 is a 16-bit signed number. // COM2 and COMC can be used to get the 2's complement of it. not GPR (logical complement) not GPR + 1 (2's complement of GPR) not GPR + C (logical complement of GPR with carry) // assume R1:R0 and R3:R2 are 16-bit signed or unsigned numbers. // to add two 16-bit numbers, use ADD and ADC. // assume R1:R0 and R3:R2 are 16-bit signed or unsigned numbers. // to subtract two 16-bit numbers, use SUB and SBC. // assume both R1:R0 and R3:R2 are 16-bit unsigned numbers. // to compare two 16-bit unsigned numbers, use CP and CPC. 8-14 S3FB42F INSTRUCTION SET IncDec GPR (Increment/Decrement Operations) IncDec = INC, INCC, DEC, DECC Operation INC GPR INCC GPR DEC GPR DECC GPR Example INC R0 INCC R1 DEC R0 DECC R1 // assume R1:R0 is a 16-bit number // to increase R1:R0, use INC and INCC. // assume R1:R0 is a 16-bit number // to decrease R1:R0, use DEC and DECC. Increase GPR, i.e., GPR GPR + 1 Increase GPR if carry = 1, i.e., GPR GPR + C Decrease GPR, i.e., GPR GPR + FFh Decrease GPR if carry = 0, i.e., GPR GPR + FFh + C 8-15 INSTRUCTION SET S3FB42F SHIFT/ROTATE INSTRUCTIONS Shift (Rotate) instructions shift (rotate) the given operand by 1 bit. Depending on the operation performed, a number of Status Register 1 (SR1) bits, namely Carry (C), Zero (Z), Overflow (V), and Negative (N), are set. SL GPR Operation 7 C GPR 0 0 Carry (C) is the MSB of GPR before shifting, Negative (N) is the MSB of GPR after shifting. Overflow (V) is not affected. Zero (Z) will be 1 if the result is 0. SLA GPR Operation 7 C GPR 0 0 Carry (C) is the MSB of GPR before shifting, Negative (N) is the MSB of GPR after shifting. Overflow (V) will be 1 if the MSB of the result is different from C. Z will be 1 if the result is 0. RL GPR Operation 7 C GPR 0 Carry (C) is the MSB of GPR before rotating. Negative (N) is the MSB of GPR after rotatin/g. Overflow (V) is not affected. Zero (Z) will be 1 if the result is 0. RLC GPR Operation 7 0 GPR C Carry (C) is the MSB of GPR before rotating, Negative (N) is the MSB of GPR after rotating. Overflow (V) is not affected. Zero (Z) will be 1 if the result is 0. 8-16 S3FB42F INSTRUCTION SET SR GPR Operation 7 0 GPR 0 C Carry (C) is the LSB of GPR before shifting, Negative (N) is the MSB of GPR after shifting. Overflow (V) is not affected. Zero (Z) will be 1 if the result is 0. SRA GPR Operation 7 0 C GPR Carry (C) is the LSB of GPR before shifting, Negative (N) is the MSB of GPR after shifting. Overflow (V) is not affected. Z will be 1 if the result is 0. RR GPR Operation 7 GPR 0 C Carry (C) is the LSB of GPR before rotating. Negative (N) is the MSB of GPR after rotating. Overflow (V) is not affected. Zero (Z) will be 1 if the result is 0. RRC GPR Operation 7 0 GPR C Carry (C) is the LSB of GPR before rotating, Negative (N) is the MSB of GPR after rotating. Overflow (V) is not affected. Zero (Z) will be 1 if the result is 0. 8-17 INSTRUCTION SET S3FB42F LOAD INSTRUCTIONS Load instructions transfer data from data memory to a register or from a register to data memory, or assigns an immediate value into a register. As a side effect, a load instruction placing a value into a register sets the Zero (Z) and Negative (N) bits in Status Register 1 (SR1), if the placed data is 00h and the MSB of the data is 1, respectively. LD GPR, adr:8 Loads the value of DM[adr:8] into GPR. Adr:8 is offset in the page specified by the value of eid in Status Register 0 (SR0). Operation GPR DM[00h:adr:8] if eid = 0 GPR DM[IDH:adr:8] if eid = 1 Note that this is an 8-bit operation. Example LD R0, 80h // assume eid = 1 and IDH= 01H // R0 DM[0180h] LD GPR, @idm Loads a value from the data memory location specified by @idm into GPR. idm = IDx+off:5, [IDx-offset:5], [IDx+offset:5]!, [IDx-offset:5]! (IDx = ID0 or ID1) Operation GPR GPR GPR GPR DM[IDx], IDx IDx + offset:5 when idm = IDx + offset:5 DM[IDx - offset:5], IDx IDx - offset:5 when idm = [IDx - offset:5] DM[IDx + offset:5] when idm = [IDx + offset:5]! DM[IDx - offset:5] when idm = [IDx - offset:5]! When carry is generated from IDL (on a post-increment or pre-decrement), it is propagated to IDH. Example LD R0, @[ID0 + 03h]! // assume IDH:IDL0 = 0270h // R0 DM[0273h], IDH:IDL0 0270h 8-18 S3FB42F INSTRUCTION SET LD REG, #imm:8 Loads an 8-bit immediate value into REG. REG can be either GPR or an SPR0 group register - IDH (Index of Data Memory Higher Byte Register), IDL0 (Index of Data Memory Lower Byte Register)/ IDL1, and Status Register 0 (SR0). #imm:8 is an 8-bit immediate value. Operation REG #imm:8 Example LD R0 #7Ah LD IDH, #03h LD GPR:bs:2, GPR:bs:2 Loads a value of a register from a specified bank into another register in a specified bank. Example LD R0:1, R2:3 LD GPR, TBH/TBL Loads the value of TBH or TBL into GPR. TBH and TBL are 8-bit long registers used exclusively for LDC instructions that access program memory. Therefore, after an LDC instruction, LD GPR, TBH/TBL instruction will usually move the data into GPRs, to be used for other operations. Operation GPR TBH (or TBL) Example LDC @IL LD R0, TBH LD R1, TBL LD TBH/TBL, GPR Loads the value of GPR into TBH or TBL. These instructions are used in pair in interrupt service routines to save and restore the values in TBH/TBL as needed. Operation TBH (or TBL) GPR LD GPR, SPR Loads the value of SPR into GPR. Operation GPR SPR Example LD R0, IDH // R0 IDH // gets a program memory item residing @ ILX:ILH:ILL // R0 in bank 1, R2 in bank 3 // R0 7Ah // IDH 03h 8-19 INSTRUCTION SET S3FB42F LD SPR, GPR Loads the value of GPR into SPR. Operation SPR GPR Example LD IDH, R0 LD adr:8, GPR Stores the value of GPR into data memory (DM). adr:8 is offset in the page specified by the value of eid in Status Register 0 (SR0). Operation DM[00h:adr:8] GPR if eid = 0 DM[IDH:adr:8] GPR if eid = 1 Note that this is an 8-bit operation. Example LD 7Ah, R0 // assume eid = 1 and IDH = 02h. // DM[027Ah] R0 // IDH R0 LD @idm, GPR Loads a value into the data memory location specified by @idm from GPR. idm = IDx+off:5, [IDx-offset:5], [IDx+offset:5]!, [IDx-offset:5]! (IDx = ID0 or ID1) Operation DM[IDx] GPR, IDx IDx + offset:5 when idm = IDx + offset:5 DM[IDx - offset:5] GPR, IDx IDx - offset:5 when idm = [IDx - offset:5] DM[IDx + offset:5] GPR when idm = [IDx + offset:5]! DM[IDx - offset:5] GPR when idm = [IDx - offset:5]! When carry is generated from IDL (on a post-increment or pre-decrement), it is propagated to IDH. Example LD @[ID0 + 03h]!, R0 // assume IDH:IDL0 = 0170h // DM[0173h] R0, IDH:IDL0 0170h 8-20 S3FB42F INSTRUCTION SET BRANCH INSTRUCTIONS Branch instructions can be categorized into jump instruction, link instruction, and call instruction. A jump instruction does not save the current PC, whereas a call instruction saves ("pushes") the current PC onto the stack and a link instruction saves the PC in the link register IL. Status registers are not affected. Each instruction type has a 2-word format that supports a 20-bit long jump. JR cc:4, imm:9 imm:9 is a signed number (2's complement), an offset to be added to the current PC to compute the target (PC[19:12]:(PC[11:0] + imm:9)). Operation PC[11:0] PC[11:0] + imm:9 PC[11:0] PC[11:0] + 1 Example L18411: JR Z, 107h LJP cc:4, imm:20 Jumps to the program address specified by imm:20. If program size is less than 64K word, PC[19:16] is not affected. Operation PC[15:0] imm[15:0] if branch taken and program size is less than 64K word PC[19:0] imm[19:0] if branch taken and program size is equal to 64K word or more PC [11:0] PC[11:0] + 1 otherwise Example L18411: LJP Z, 10107h JNZD Rn, imm:8 Jumps to the program address specified by imm:8 if the value of the bank 3 register Rn is not zero. JNZD performs only backward jumps, with the value of Rn automatically decreased. There is one delay slot following the JNZD instruction that is always executed, regardless of whether JNZD is taken or not. Operation If (Rn == 0) PC PC[delay slot] (-) 2's complement of imm:8, Rn Rn - 1 else PC PC[delay slot] + 1, Rn Rn - 1. // assume current PC = 18411h. // next instruction's PC is 10107h If Zero (Z) bit is set // assume current PC = 18411h. // next PC is 18518 (18411h + 107h) if Zero (Z) bit is set. if branch taken (i.e., cc:4 resolves to be true) otherwise 8-21 INSTRUCTION SET S3FB42F Example LOOP_A: * * * // start of loop body JNZD R0, LOOP_A ADD R1, #2 CALLS imm:12 // jump back to LOOP_A if R0 is not zero // delay slot, always executed (you must use one cycle instruction only) Saves the current PC on the stack ("pushes" PC) and jumps to the program address specified by imm:12. The current page number PC[19:12] is not changed. Since this is a 1-word instruction, the return address pushed onto the stack is (PC + 1). If nP64KW is low when PC is saved, PC[19:16] is not saved in the stack. Operation HS[sptr][15:0] current PC + 1 and sptr sptr + 2 (push stack) HS[sptr][19:0] current PC + 1 and sptr sptr + 2 (push stack) PC[11:0] imm:12 Example L18411: CALLS 107h // assume current PC = 18411h. // call the subroutine at 18107h, with the current PC pushed // onto the stack (HS 18412h) if nP64KW = 1. if nP64KW = 0 if nP64KW = 1 LCALL cc:4, imm:20 Saves the current PC onto the stack (pushes PC) and jumps to the program address specified by imm:20. Since this is a 2-word instruction, the return address saved in the stack is (PC + 2). If nP64KW, a core input signal is low when PC is saved, 0000111111PC[19:16] is not saved in the stack and PC[19:16] is not set to imm[19:16]. Operation HS[sptr][15:0] current PC + 2 and sptr + 2 (push stack) if branch taken and nP64KW = 0 HS[sptr][19:0] current PC + 2 and sptr + 2 (push stack) if branch taken and nP64KW = 1 PC[15:0] imm[15:0] if branch taken and nP64KW = 0 PC[19:0] imm[19:0] if branch taken and nP64KW = 1 PC[11:0] PC[11:0] + 2 otherwise Example L18411: LCALL NZ, 10h:107h // assume current PC = 18411h. // call the subroutine at 10107h with the current PC pushed // onto the stack (HS 18413h) 8-22 S3FB42F INSTRUCTION SET LNKS imm:12 Saves the current PC in IL and jumps to the program address specified by imm:12. The current page number PC[19:12] is not changed. Since this is a 1-word instruction, the return address saved in IL is (PC + 1). If the program size is less than 64K word when PC is saved, PC[19:16] is not saved in ILX. Operation IL[15:0] current PC + 1 IL[19:0] current PC + 1 PC[11:0] imm:12 Example L18411: LNKS 107h // assume current PC = 18411h. // call the subroutine at 18107h, with the current PC saved // in IL (IL[19:0] 18412h) if program size is 64K word or more. if program size is less than 64K word if program size is equal to 64K word or more LLNK cc:4, imm:20 Saves the current PC in IL and jumps to the program address specified by imm:20. Since this is a 2-word instruction, the return address saved in IL is (PC + 2). If the program size is less than 64K word when PC is saved, PC[19:16] is not saved in ILX. Operation IL[15:0] current PC + 2 if branch taken and program size is less than 64K word IL[19:0] current PC + 2 if branch taken and program size is 64K word or more PC[15:0] imm[15:0] if branch taken and program size is less than 64K word PC[19:0] imm[19:0] if branch taken and program size is 64K word or more PC[11:0] PC[11:0] + 2 otherwise Example L18411: LLNK NZ, 10h:107h // assume current PC = 18411h. // call the subroutine at 10107h with the current PC saved // in IL (IL[19:0] 18413h) if program size is 64K word or more RET, IRET Returns from the current subroutine. IRET sets ie (SR0[1]) in addition. If the program size is less than 64K word, PC[19:16] is not loaded from HS[19:16]. Operation PC[15:0] HS[sptr - 2] and sptr sptr - 2 (pop stack) if program size is less than 64K word PC[19:0] HS[sptr - 2] and sptr sptr - 2 (pop stack) if program size is 64K word or more Example RET // assume sptr = 3h and HS[1] = 18407h. // the next PC will be 18407h and sptr is set to 1h 8-23 INSTRUCTION SET S3FB42F LRET Returns from the current subroutine, using the link register IL. If the program size is less than 64K word, PC[19:16] is not loaded from ILX. Operation PC[15:0] IL[15:0] PC[19:0] IL[19:0] Example LRET // assume IL = 18407h. // the next instruction to execute is at PC = 18407h // if program size is 64K word or more if program size is less than 64K word if program size is 64K word or more JP/LNK/CALL JP/LNK/CALL instructions are pseudo instructions. If JR/LNKS/CALLS commands (1 word instructions) can access the target address, there is no conditional code in the case of CALL/LNK and the JP/LNK/CALL commands are assembled to JR/LNKS/CALLS in linking time or else the JP/LNK/CALL commands are assembled to LJP/LLNK/LCALL (2 word instructions) instructions. 8-24 S3FB42F INSTRUCTION SET BIT MANIPULATION INSTRUCTIONS BITop adr:8.bs Performs a bit operation specified by op on the value in the data memory pointed by adr:8 and stores the result into R3 of current GPR bank or back into memory depending on the value of TF bit. BITop = BITS, BITR, BITC, BITT BITS: bit set BITR: bit reset BITC: bit complement BITT: bit test (R3 is not touched in this case) bs: bit location specifier, 0 - 7. Operation R3 DM[00h:adr:8] BITop bs if eid = 0 R3 DM[IDH:adr:8] BITop bs if eid = 1 (no register transfer for BITT) Set the Zero (Z) bit if the result is 0. Example BITS 25h.3 BITT 25h.3 BMC/BMS Clears or sets the TF bit, which is used to determine the destination of BITop instructions. When TF bit is clear, the result of BITop instructions will be stored into R3 (fixed); if the TF bit is set, the result will be written back to memory. Operation TF 0 TF 1 TM GPR, #imm:8 Performs AND operation on GPR and imm:8 and sets the Zero (Z) and Negative (N) bits. No change in GPR. Operation Z, N flag GPR & #imm:8 BITop GPR.bs Performs a bit operation on GPR and stores the result in GPR. Since the equivalent functionality can be achieved using OR GPR, #imm:8, AND GPR, #imm:8, and XOR GPR, #imm:8, this instruction type doesn't have separate op codes. (BMC) (BMS) // assume eid = 0. set bit 3 of DM[00h:25h] and store the result in R3. // check bit 3 of DM[00h:25h] if eid = 0. 8-25 INSTRUCTION SET S3FB42F AND SR0, #imm:8/OR SR0, #imm:8 Sets/resets bits in SR0 and stores the result back into SR0. Operation SR0 SR0 & #imm:8 SR0 SR0 | #imm:8 BANK #imm:2 Loads SR0[4:3] with #imm[1:0]. Operation SR0[4:3] #imm[1:0] MISCELLANEOUS INSTRUCTION SWAP GPR, SPR Swaps the values in GPR and SPR. SR0 and SR1 can NOT be used for this instruction. No flag is updated, even though the destination is GPR. Operation temp SPR SPR GPR GPR temp Example SWAP R0, IDH // assume IDH = 00h and R0 = 08h. // after this, IDH = 08h and R0 = 00h. PUSH REG Saves REG in the stack (Pushes REG into stack). REG = GPR, SPR Operation HS[sptr][7:0] REG and sptr sptr + 1 Example PUSH R0 // assume R0 = 08h and sptr = 2h // then HS[2][7:0] 08h and sptr 3h 8-26 S3FB42F INSTRUCTION SET POP REG Pops stack into REG. REG = GPR, SPR Operation REG HS[sptr-1][7:0] and sptr sptr - 1 Example POP R0 // assume sptr = 3h and HS[2] = 18407h // R0 07h and sptr 2h POP Pops 2 bytes from the stack and discards the popped data. NOP Does no work but increase PC by 1. BREAK Does nothing and does NOT increment PC. This instruction is for the debugger only. When this instruction is executed, the processor is locked since PC is not incremented. Therefore, this instruction should not be used under any mode other than the debug mode. SYS #imm:8 Does nothing but increase PC by 1 and generates SYSCP[7:0] and nSYSID signals. CLD GPR, imm:8 GPR (imm:8) and generates SYSCP[7:0], nCLDID, and nCLDWR signals. CLD imm:8, GPR (imm:8) GPR and generates SYSCP[7:0], nCLDID, and nCLDWR signals. COP #imm:12 Generates SYSCP[11:0] and nCOPID signals. 8-27 INSTRUCTION SET S3FB42F LDC Loads program memory item into register. Operation [TBH:TBL] PM[ILX:ILH:ILL] [TBH:TBL] PM[ILX:ILH:ILL], ILL++ (LDC @IL) (LDC @IL+) TBH and TBL are temporary registers to hold the transferred program memory items. These can be accessed only by LD GPR and TBL/TBH instruction. Example LD ILX, R1 LD ILH, R2 LD ILL, R3 LDC @IL // assume R1:R2:R3 has the program address to access // get the program data @(ILX:ILH:ILL) into TBH:TBL 8-28 S3FB42F INSTRUCTION SET PSEUDO INSTRUCTIONS EI/DI Exceptions enable and disable instruction. Operation SR0 OR SR0,#00000010b SR0 AND SR0,#11111101b (EI) (DI) Exceptions are enabled or disabled through this instruction. If there is an EI instruction, the SR0.1 is set and reset, when DI instruction. Example DI * * * EI SCF/RCF Carry flag set and reset instruction. Operation CP R0,R0 AND R0,R0 (SCF) (RCF) Carry flag is set or reset through this instruction. If there is an SCF instruction, the SR1.0 is set and reset, when RCF instruction. Example SCF RCF STOP/IDLE MCU power saving instruction. Operation SYS #0Ah SYS #05h (STOP) (IDLE) The STOP instruction stops the both CPU clock and system clock and causes the microcontroller to enter STOP mode. The IDLE instruction stops the CPU clock while allowing system clock oscillation to continue. Example STOP(or IDLE) NOP NOP NOP * * 8-29 INSTRUCTION SET S3FB42F ADC -- Add with Carry Format: ADC Operation: Flags: . Example: ADC R0, 80h // If eid = 0, R0 R0 + DM[0080h] + C // If eid = 1, R0 R0 + DM[IDH:80h] + C // R0 R0 + R1 + C ADC ADD ADC R0, R1 R0, R2 R1, R3 In the last two instructions, assuming that register pair R1:R0 and R3:R2 are 16-bit signed or unsigned numbers. Even if the result of "ADD R0, R2" is not zero, Z flag can be set to `1' if the result of "ADC R1,R3" is zero. Note that zero (Z) flag do not exactly reflect result of 16-bit operation. Therefore when programming 16-bit addition, take care of the change of Z flag. 8-30 S3FB42F INSTRUCTION SET ADD -- Add Format: ADD . Example: Given: IDH:IDL0 = 80FFh, eid = 1 ADD ADD ADD ADD ADD ADD ADD R0, 80h R0, #12h R1, R2 R0, @ID0 + 2 R0, @[ID0 - 3] R0, @[ID0 + 2]! R0, @[ID0 - 2]! // R0 R0 + DM[8080h] // R0 R0 + 12h // R1 R1 + R2 // R0 // R0 // R0 // R0 R0 + DM[80FFh], IDH 81h, IDL0 01h R0 + DM[80FCh], IDH 80h, IDL0 FCh R0 + DM[8101h], IDH 80h, IDL0 FFh R0 + DM[80FDh], IDH 80h, IDL0 FFh In the last two instructions, the value of IDH:IDL0 is not changed. Refer to Table 8-5 for more detailed explanation about this addressing mode. idm = IDx+offset:5, [IDx-offset:5], [IDx+offset:5]!, [IDx-offset:5]! (IDx = ID0 or ID1) 8-31 INSTRUCTION SET S3FB42F AND -- Bit-wise AND Format: AND Example: In the first instruction, if eid bit in SR0 is zero, register R0 has garbage value because data memory DM[0051h-007Fh] are not mapped in S3CB018/S3FB018. In the last two instructions, the value of IDH:IDL0 is not changed. Refer to Table 8-5 for more detailed explanation about this addressing mode. idm = IDx+offset:5, [IDx-offset:5], [IDx+offset:5]!, [IDx-offset:5]! (IDx = ID0 or ID1) 8-32 S3FB42F INSTRUCTION SET AND SR0 -- Bit-wise AND with SR0 Format: Operation: AND SR0, #imm:8 SR0 SR0 & imm:8 AND SR0 performs the bit-wise AND operation on the value of SR0 and imm:8 and stores the result in SR0. Flags: Example: - Given: SR0 = 11000010b nIE nIE0 nIE1 EQU EQU EQU AND AND ~02h ~40h ~80h SR0, #nIE | nIE0 | nIE1 SR0, #11111101b In the first example, the statement "AND SR0, #nIE|nIE0|nIE1" clear all of bits of the global interrupt, interrupt 0 and interrupt 1. On the contrary, cleared bits can be set to `1' by instruction "OR SR0, #imm:8". Refer to instruction OR SR0 for more detailed explanation about enabling bit. In the second example, the statement "AND SR0, #11111101b" is equal to instruction DI, which is disabling interrupt globally. 8-33 INSTRUCTION SET S3FB42F BANK -- GPR Bank selection Format: Operation: Flags: NOTE: BANK #imm:2 SR0[4:3] imm:2 - For explanation of the CalmRISC banked register file and its usage, please refer to chapter 3. Example: BANK LD BANK LD #1 R0, #11h #2 R1, #22h // Select register bank 1 // Bank1's R0 11h // Select register bank 2 // Bank2's R1 22h 8-34 S3FB42F INSTRUCTION SET BITC -- Bit Complement Format: BITC adr:8.bs bs: 3-digit bit specifier Operation: R3 ((adr:8) ^ (2**bs)) (adr:8) ((adr:8) ^ (2**bs)) if (TF == 0) if (TF == 1) BITC complements the specified bit of a value read from memory and stores the result in R3 or back into memory, depending on the value of TF. TF is set or clear by BMS/BMC instruction. Flags: NOTE: Z: set if result is zero. Reset if not. Since the destination register R3 is fixed, it is not specified explicitly. Given: IDH = 01, DM[0180h] = FFh, eid = 1 BMC BITC BMS BITC // TF 0 // R3 FEh, DM[0180h] = FFh // TF 1 // DM[0180h] FDh Example: 80h.0 80h.1 8-35 INSTRUCTION SET S3FB42F BITR -- Bit Reset Format: BITR adr:8.bs bs: 3-digit bit specifier Operation: R3 ((adr:8) & ((11111111)2 - (2**bs))) (adr:8) ((adr:8) & ((11111111)2 - (2**bs))) if (TF == 0) if (TF == 1) BITR resets the specified bit of a value read from memory and stores the result in R3 or back into memory, depending on the value of TF. TF is set or clear by BMS/BMC instruction. Flags: NOTE: Z: set if result is zero. Reset if not. Since the destination register R3 is fixed, it is not specified explicitly. Given: IDH = 01, DM[0180h] = FFh, eid = 1 BMC BITR BMS BITR // TF 0 // R3 FDh, DM[0180h] = FFh // TF 1 // DM[0180h] FBh Example: 80h.1 80h.2 8-36 S3FB42F INSTRUCTION SET BITS -- Bit Set Format: BITS adr:8.bs bs: 3-digit bit specifier. Operation: R3 ((adr:8) | (2**bs)) (adr:8) ((adr:8) | (2**bs)) if (TF == 0) if (TF == 1) BITS sets the specified bit of a value read from memory and stores the result in R3 or back into memory, depending on the value of TF. TF is set or clear by BMS/BMC instruction. Flags: NOTE: Z: set if result is zero. Reset if not. Since the destination register R3 is fixed, it is not specified explicitly. Given: IDH = 01, DM[0180h] = F0h, eid = 1 BMC BITS BMS BITS // TF 0 // R3 0F2h, DM[0180h] = F0h // TF 1 // DM[0180h] F4h Example: 80h.1 80h.2 8-37 INSTRUCTION SET S3FB42F BITT -- Bit Test Format: BITT adr:8.bs bs: 3-digit bit specifier. Operation: Z ~((adr:8) & (2**bs)) BITT tests the specified bit of a value read from memory. Flags: Example: Z: set if result is zero. Reset if not. Given: DM[0080h] = F7h, eid = 0 BITT JR * * * 80h.3 Z, %1 // Z flag is set to `1' // Jump to label %1 because condition is true. %1 BITS NOP * * * 80h.3 8-38 S3FB42F INSTRUCTION SET BMC/BMS - TF bit clear/set Format: Operation: BMS/BMC BMC/BMS clears (sets) the TF bit. TF 0 if BMC TF 1 if BMS TF is a single bit flag which determines the destination of bit operations, such as BITC, BITR, and BITS. Flags: NOTE: - BMC/BMS are the only instructions that modify the content of the TF bit. // TF 1 81h.1 // TF 0 81h.2 R0, R3 Example: BMS BITS BMC BITR LD 8-39 INSTRUCTION SET S3FB42F CALL -- Conditional Subroutine Call (Pseudo Instruction) Format: CALL cc:4, imm:20 CALL imm:12 If CALLS can access the target address and there is no conditional code (cc:4), CALL command is assembled to CALLS (1-word instruction) in linking time, else the CALL is assembled to LCALL (2-word ins truction). Operation: Example: CALL * * * C, Wait // HS[sptr][15:0] current PC + 2, sptr sptr + 2 // 2-word instruction // HS[sptr][15:0] current PC + 1, sptr sptr + 2 // 1-word instruction CALL * * * 0088h Wait: NOP NOP NOP NOP NOP RET // Address at 0088h 8-40 S3FB42F INSTRUCTION SET CALLS -- Call Subroutine Format: Operation: CALLS imm:12 HS[sptr][15:0] current PC + 1, sptr sptr + 2 if the program size is less than 64K word. HS[sptr][19:0] current PC + 1, sptr sptr + 2 if the program size is equal to or over 64K word. PC[11:0] imm:12 CALLS unconditionally calls a subroutine residing at the address specified by imm:12. Flags: Example: CALLS * * * - Wait Wait: NOP NOP NOP RET Because this is a 1-word instruction, the saved returning address on stack is (PC + 1). 8-41 INSTRUCTION SET S3FB42F CLD -- Load into Coprocessor Format: CLD imm:8, * * * - 00h 01h 02h 03h CLD CLD CLD CLD AH, R0 AL, R1 BH, R2 BL, R3 // A[15:8] R0 // A[7:0] R1 // B[15:8] R2 // B[7:0] R3 The registers A[15:0] and B[15:0] are Arithmetic Unit (AU) registers of MAC816. Above instructions generate SYSCP[7:0], nCLDID and CLDWR signals to access MAC816. 8-42 S3FB42F INSTRUCTION SET CLD -- Load from Coprocessor Format: CLD Example: AH AL BH BL EQU EQU EQU EQU * * * 00h 01h 02h 03h CLD CLD CLD CLD R0, AH R1, AL R2, BH R3, BL // R0 A[15:8] // R1 A[7:0] // R2 B[15:8] // R3 B[7:0] The registers A[15:0] and B[15:0] are Arithmetic Unit (AU) registers of MAC816. Above instructions generate SYSCP[7:0], nCLDID and CLDWR signals to access MAC816. 8-43 INSTRUCTION SET S3FB42F COM -- 1's or Bit-wise Complement Format: COM Example: 8-44 S3FB42F INSTRUCTION SET COM2 -- 2's Complement Format: COM2 Example: Given: R0 = 00h, R1 = 5Ah COM2 COM2 R0 R1 // R0 00h, Z and C flags are set to `1'. // R1 A6h, N flag is set to `1'. 8-45 INSTRUCTION SET S3FB42F COMC -- Bit-wise Complement with Carry Format: COMC Example: If register pair R1:R0 is a 16-bit number, then the 2's complement of R1:R0 can be obtained by COM2 and COMC as following. COM2 COMC R0 R1 Note that Z flag do not exactly reflect result of 16-bit operation. For example, if 16-bit register pair R1: R0 has value of FF01h, then 2's complement of R1: R0 is made of 00FFh by COM2 and COMC. At this time, by instruction COMC, zero (Z) flag is set to `1' as if the result of 2's complement for 16bit number is zero. Therefore when programming 16-bit comparison, take care of the change of Z flag. 8-46 S3FB42F INSTRUCTION SET COP -- Coprocessor Format: Operation: Flags: Example: COP COP #0D01h #0234h // generate 1 word instruction code(FD01h) // generate 1 word instruction code(F234h) COP #imm:12 COP passes imm:12 to the coprocessor by generating SYSCP[11:0] and nCOPID signals. - The above two instructions are equal to statement "ELD A, #1234h" for MAC816 operation. The microcode of MAC instruction "ELD A, #1234h" is "FD01F234", 2-word instruction. In this, code `F' indicates `COP' instruction. 8-47 INSTRUCTION SET S3FB42F CP -- Compare Format: CP Example: Given: R0 = 73h, R1 = A5h, IDH:IDL0 = 0123h, DM[0123h] = A5, eid = 1 CP CP CP CP CP CP CP R0, 80h R0, #73h R0, R1 R1, @ID0 R1, @[ID0 - 5] R2, @[ID0 + 7]! R2, @[ID0 - 2]! // C flag is set to `1' // Z and C flags are set to `1' // V flag is set to `1' // Z and C flags are set to `1' In the last two instructions, the value of IDH:IDL0 is not changed. Refer to Table 8-5 for more detailed explanation about this addressing mode. idm = IDx+offset:5, [IDx-offset:5], [IDx+offset:5]!, [IDx-offset:5]! (IDx = ID0 or ID1) 8-48 S3FB42F INSTRUCTION SET CPC -- Compare with Carry Format: CPC Example: If register pair R1:R0 and R3:R2 are 16-bit signed or unsigned numbers, then use CP and CPC to compare two 16-bit numbers as follows. CP CPC R0, R1 R2, R3 Because CPC considers C when comparing 8-49 INSTRUCTION SET S3FB42F DEC -- Decrement Format: DEC Example: Given: R0 = 80h, R1 = 00h DEC DEC R0 R1 // R0 7Fh, C, V and N flags are set to `1' // R1 FFh, N flags is set to `1' 8-50 S3FB42F INSTRUCTION SET DECC -- Decrement with Carry Format: DECC Example: If register pair R1:R0 is 16-bit signed or unsigned number, then use DEC and DECC to decrement 16-bit number as follows. DEC DECC R0 R1 Note that zero (Z) flag do not exactly reflect result of 16-bit operation. Therefore when programming 16-bit decrement, take care of the change of Z flag. 8-51 INSTRUCTION SET S3FB42F DI -- Disable Interrupt (Pseudo Instruction) Format: Operation: DI Disables interrupt globally. It is same as "AND SR0, #0FDh" . DI instruction sets bit1 (ie: global interrupt enable) of SR0 register to "0" - Given: SR0 = 03h DI // SR0 SR0 & 11111101b Flags: Example: DI instruction clears SR0[1] to `0', disabling interrupt processing. 8-52 S3FB42F INSTRUCTION SET EI -- Enable Interrupt (Pseudo Instruction) Format: Operation: EI Enables interrupt globally. It is same as "OR SR0, #02h" . EI instruction sets the bit1 (ie: global interrupt enable) of SR0 register to "1" - Given: SR0 = 01h EI // SR0 SR0 | 00000010b Flags: Example: The statement "EI" sets the SR0[1] to `1', enabling all interrupts. 8-53 INSTRUCTION SET S3FB42F IDLE -- Idle Operation (Pseudo Instruction) Format: Operation: IDLE The IDLE instruction stops the CPU clock while allowing system clock oscillation to continue. Idle mode can be released by an interrupt or reset operation. The IDLE instruction is a pseudo instruction. It is assembled as "SYS #05H", and this generates the SYSCP[7-0] signals. Then these signals are decoded and the decoded signals execute the idle operation. - The next instruction of IDLE instruction is executed, so please use the NOP instruction after the IDLE instruction. Flags: NOTE: Example: IDLE NOP NOP NOP * * * The IDLE instruction stops the CPU clock but not the system clock. 8-54 S3FB42F INSTRUCTION SET INC -- Increment Format: INC Example: Given: R0 = 7Fh, R1 = FFh INC INC R0 R1 // R0 80h, V flag is set to `1' // R1 00h, Z and C flags are set to `1' 8-55 INSTRUCTION SET S3FB42F INCC -- Increment with Carry Format: INCC Example: If register pair R1:R0 is 16-bit signed or unsigned number, then use INC and INCC to increment 16-bit number as following. INC INCC R0 R1 Assume R1:R0 is 0010h, statement "INC R0" increase R0 by one without carry and statement "INCC R1" set zero (Z) flag to `1' as if the result of 16-bit increment is zero. Note that zero (Z) flag do not exactly reflect result of 16-bit operation. Therefore when programming 16-bit increment, take care of the change of Z flag. 8-56 S3FB42F INSTRUCTION SET IRET -- Return from Interrupt Handling Format: Operation: IRET PC HS[sptr - 2], sptr sptr - 2 IRET pops the return address (after interrupt handling) from the hardware stack and assigns it to PC. The ie (i.e., SR0[1]) bit is set to allow further interrupt generation. Flags: NOTE: - The program size (indicated by the nP64KW signal) determines which portion of PC is updated. When the program size is less than 64K word, only the lower 16 bits of PC are updated (i.e., PC[15:0] HS[sptr - 2]). When the program size is 64K word or more, the action taken is PC[19:0] HS[sptr - 2]. Example: SF_EXCEP: NOP * * * // Stack full exception service routine IRET 8-57 INSTRUCTION SET S3FB42F JNZD -- Jump Not Zero with Delay slot Format: JNZD NOTE: - Typically, the delay slot will be filled with an instruction from the loop body. It is noted, however, that the chosen instruction should be "dead" outside the loop for it executes even when the loop is exited (i.e., JNZD is not taken). Given: IDH = 03h, eid = 1 BANK LD LD LD JNZD LD * * * Example: %1 #3 R0, #0FFh R1, #0 IDL0, R0 R0, %B1 @ID0, R1 // R0 is used to loop counter // If R0 of bank3 is not zero, jump to %1. // Clear register pointed by ID0 This example can be used for RAM clear routine. The last instruction is executed even if the loop is exited. 8-58 S3FB42F INSTRUCTION SET JP -- Conditional Jump (Pseudo Instruction) Format: JP cc:4 imm:20 JP cc:4 imm:9 If JR can access the target address, JP command is assembled to JR (1 word instruction) in linking time, else the JP is assembled to LJP (2 word instruction) instruction. There are 16 different conditions that can be used, as described in table 8-6. Operation: Example: %1 LD * * * R0, #10h // Assume address of label %1 is 020Dh JP JP * * * Z, %B1 C, %F2 // Address at 0264h // Address at 0265h %2 LD * * * R1, #20h // Assume address of label %2 is 089Ch In the above example, the statement "JP Z, %B1" is assembled to JR instruction. Assuming that current PC is 0264h and condition is true, next PC is made by PC[11:0] PC[11:0] + offset, offset value is "64h + A9h" without carry. `A9' means 2's complement of offset value to jump backward. Therefore next PC is 020Dh. On the other hand, statement "JP C, %F2" is assembled to LJP instruction because offset address exceeds the range of imm:9. 8-59 INSTRUCTION SET S3FB42F JR -- Conditional Jump Relative Format: JR cc:4 imm:9 cc:4: 4-bit condition code Operation: PC[11:0] PC[11:0] + imm:9 if condition is true. imm:9 is a signed number, which is signextended to 12 bits when added to PC. There are 16 different conditions that can be used, as described in table 8-6. - Unlike LJP, the target address of JR is PC-relative. In the case of JR, imm:9 is added to PC to compute the actual jump address, while LJP directly jumps to imm:20, the target. Flags: NOTE: Example: JR * * * Z, %1 // Assume current PC = 1000h %1 LD * * * R0, R1 // Address at 10A5h After the first instruction is executed, next PC has become 10A5h if Z flag bit is set to `1'. The range of the relative address is from +255 to -256 because imm:9 is signed number. 8-60 S3FB42F INSTRUCTION SET LCALL -- Conditional Subroutine Call Format: Operation: LCALL cc:4, imm:20 HS[sptr][15:0] current PC + 2, sptr sptr + 2, PC[15:0] imm[15:0] if the condition holds and the program size is less than 64K word. HS[sptr][19:0] current PC + 2, sptr sptr + 2, PC[19:0] imm:20 if the condition holds and the program size is equal to or over 64K word. PC[11:0] PC[11:0] + 2 otherwise. LCALL instruction is used to call a subroutine whose starting address is specified by imm:20. Flags: Example: LCALL LCALL L1 C, L2 - Label L1 and L2 can be allocated to the same or other section. Because this is a 2-word instruction, the saved returning address on stack is (PC + 2). 8-61 INSTRUCTION SET S3FB42F LD adr:8 -- Load into Memory Format: LD adr:8, If eid bit of SR0 is zero, the statement "LD 80h, R0" load value of R0 into DM[0080h], else eid bit was set to `1', the statement "LD 80h, R0" load value of R0 into DM[0180h] 8-62 S3FB42F INSTRUCTION SET LD @idm -- Load into Memory Indexed Format: LD @idm, In the last two instructions, the value of IDH:IDL0 is not changed. Refer to Table 8-5 for more detailed explanation about this addressing mode. idm = IDx+offset:5, [IDx-offset:5], [IDx+offset:5]!, [IDx-offset:5]! (IDx = ID0 or ID1) 8-63 INSTRUCTION SET S3FB42F LD -- Load Register Format: LD Example: In the last two instructions, the value of IDH:IDL0 is not changed. Refer to Table 8-5 for more detailed explanation about this addressing mode. idm = IDx+offset:5, [IDx-offset:5], [IDx+offset:5]!, [IDx-offset:5]! (IDx = ID0 or ID1) 8-64 S3FB42F INSTRUCTION SET LD -- Load GPR:bankd, GPR:banks Format: LD Example: LD LD R2:1, R0:3 R0:0, R0:2 8-65 INSTRUCTION SET S3FB42F LD -- Load GPR, TBH/TBL Format: LD Example: 8-66 S3FB42F INSTRUCTION SET LD -- Load TBH/TBL, GPR Format: LD 8-67 INSTRUCTION SET S3FB42F LD SPR Format: -- Load SPR LD Operation: Flags: Example: - Given: register pair R1:R0 = 1020h LD LD ILH, R1 ILL, R0 // ILH 10h // ILL 20h 8-68 S3FB42F INSTRUCTION SET LD SPR0 -- Load SPR0 Immediate Format: Operation: LD SPR0, #imm:8 SPR0 imm:8 LD SPR0 loads an 8-bit immediate value into SPR0. Flags: Example: - Given: eid = 1, idb = 0 (index register bank 0 selection) LD LD LD LD IDH, #80h IDL1, #44h IDL0, #55h SR0, #02h // IDH point to page 80h The last instruction set ie (global interrupt enable) bit to `1'. Special register group 1 (SPR1) registers are not supported in this addressing mode. 8-69 INSTRUCTION SET S3FB42F LDC -- Load Code Format: LDC // Loads value of PM[ILX:ILH:ILL] into TBH:TBL // Move data in TBH:TBL to GPRs for further processing The statement "LDC @IL" do not increase, but if you use statement "LDC @IL+", ILL register is increased by one after instruction execution. 8-70 S3FB42F INSTRUCTION SET LJP -- Conditional Jump Format: LJP cc:4, imm:20 cc:4: 4-bit condition code Operation: PC[15:0] imm[15:0] if condition is true and the program size is less than 64K word. If the program is equal to or larger than 64K word, PC[19:0] imm[19:0] as long as the condition is true. There are 16 different conditions that can be used, as described in table 8-6. - LJP cc:4 imm:20 is a 2-word instruction whose immediate field directly specifies the target address of the jump. Flags: NOTE: Example: LJP * * * C, %1 // Assume current PC = 0812h %1 LD * * * R0, R1 // Address at 10A5h After the first instruction is executed, LJP directly jumps to address 10A5h if condition is true. 8-71 INSTRUCTION SET S3FB42F LLNK -- Linked Subroutine Call Conditional Format: LLNK cc:4, imm:20 cc:4: 4-bit condition code Operation: If condition is true, IL[19:0] {PC[19:12], PC[11:0] + 2}. Further, when the program is equal to or larger than 64K word, PC[19:0] imm[19:0] as long as the condition is true. If the program is smaller than 64K word, PC[15:0] imm[15:0]. There are 16 different conditions that can be used, as described in table 8-6. Flags: NOTE: - LLNK is used to conditionally to call a subroutine with the return address saved in the link register (IL) without stack operation. This is a 2-word instruction. Example: LLNK NOP * * * Z, %1 // Address at 005Ch, ILX:ILH:ILL 00:00:5Eh // Address at 005Eh %1 LD * * * R0, R1 LRET 8-72 S3FB42F INSTRUCTION SET LNK -- Linked Subroutine Call (Pseudo Instruction) Format: LNK cc:4, imm:20 LNK imm:12 If LNKS can access the target address and there is no conditional code (cc:4), LNK command is assembled to LNKS (1 word instruction) in linking time, else the LNK is assembled to LLNK (2 word instruction). Operation: Example: LNK LNK NOP * * * Z, Link1 Link2 // Equal to "LLNK Z, Link1" // Equal to "LNKS Link2" Link2: NOP * * * LRET Subroutines section CODE, ABS 0A00h Subroutines Link1: NOP * * * LRET 8-73 INSTRUCTION SET S3FB42F LNKS -- Linked Subroutine Call Format: Operation: LNKS imm:12 IL[19:0] {PC[19:12], PC[11:0] + 1} and PC[11:0] imm:12 LNKS saves the current PC in the link register and jumps to the address specified by imm:12. - LNKS is used to call a subroutine with the return address saved in the link register (IL) without stack operation. Flags: NOTE: Example: LNKS NOP * * * Link1 // Address at 005Ch, ILX:ILH:ILL 00:00:5Dh // Address at 005Dh Link1: NOP * * * LRET 8-74 S3FB42F INSTRUCTION SET LRET -- Return from Linked Subroutine Call Format: Operation: LRET PC IL[19:0] LRET returns from a subroutine by assigning the saved return address in IL to PC. - Flags: Example: Link1: LNK NOP * * * Link1 LRET ; PC[19:0] ILX:ILH:ILL 8-75 INSTRUCTION SET S3FB42F NOP -- No Operation Format: Operation: NOP No operation. When the instruction NOP is executed in a program, no operation occurs. Instead, the instruction time is delayed by approximately one machine cycle per each NOP instruction encountered. Flags: Example: - NOP 8-76 S3FB42F INSTRUCTION SET OR -- Bit-wise OR Format: OR Flags: Example: In the last two instructions, the value of IDH:IDL0 is not changed. Refer to Table 8-5 for more detailed explanation about this addressing mode. idm = IDx+offset:5, [IDx-offset:5], [IDx+offset:5]!, [IDx-offset:5]! (IDx = ID0 or ID1) 8-77 INSTRUCTION SET S3FB42F OR SR0 -- Bit-wise OR with SR0 Format: Operation: OR SR0, #imm:8 SR0 SR0 | imm:8 OR SR0 performs the bit-wise OR operation on SR0 and imm:8 and stores the result in SR0. Flags: Example: - Given: SR0 = 00000000b EID IE IDB1 IE0 IE1 EQU EQU EQU EQU EQU OR OR 01h 02h 04h 40h 80h SR0, #IE | IE0 | IE1 SR0, #00000010b In the first example, the statement "OR SR0, #EID|IE|IE0" set global interrupt(ie), interrupt 0(ie0) and interrupt 1(ie1) to `1' in SR0. On the contrary, enabled bits can be cleared with instruction "AND SR0, #imm:8". Refer to instruction AND SR0 for more detailed explanation about disabling bit. In the second example, the statement "OR SR0, #00000010b" is equal to instruction EI, which is enabling interrupt globally. 8-78 S3FB42F INSTRUCTION SET POP -- POP Format: Operation: POP sptr sptr - 2 POP decrease sptr by 2. The top two bytes of the hardware stack are therefore invalidated. Flags: Example: - Given: sptr[5:0] = 001010b POP This POP instruction decrease sptr[5:0] by 2. Therefore sptr[5:0] is 001000b. 8-79 INSTRUCTION SET S3FB42F POP -- POP to Register Format: POP Example: POP POP R0 IDH In the first instruction, value of HS[sptr-1] is loaded to R0 and the second instruction "POP IDH" load value of HS[sptr-1] to register IDH. Refer to chapter 5 for more detailed explanation about POP operations for hardware stack. 8-80 S3FB42F INSTRUCTION SET PUSH -- Push Register Format: PUSH In the first instruction, value of register R0 is loaded to HS[sptr-1] and the second instruction "PUSH IDH" load value of register IDH to HS[sptr-1]. Current HS pointed by stack point sptr[5:0] be emptied. Refer to chapter 5 for more detailed explanation about PUSH operations for hardware stack. 8-81 INSTRUCTION SET S3FB42F RET -- Return from Subroutine Format: Operation: RET PC HS[sptr - 2], sptr sptr - 2 RET pops an address on the hardware stack into PC so that control returns to the subroutine call site. Flags: Example: - Given: sptr[5:0] = 001010b CALLS * * * Wait // Address at 00120h Wait: NOP NOP NOP NOP NOP RET // Address at 01000h After the first instruction CALLS execution, "PC+1", 0121h is loaded to HS[5] and hardware stack pointer sptr[5:0] have 001100b and next PC became 01000h. The instruction RET pops value 0121h on the hardware stack HS[sptr-2] and load to PC then stack pointer sptr[[5:0] became 001010b. 8-82 S3FB42F INSTRUCTION SET RL -- Rotate Left Format: RL Example: 8-83 INSTRUCTION SET S3FB42F RLC -- Rotate Left with Carry Format: RLC Example: In the second example, assuming that register pair R1:R0 is 16-bit number, then RL and RLC are used for 16-bit rotate left operation. But note that zero (Z) flag do not exactly reflect result of 16-bit operation. Therefore when programming 16-bit decrement, take care of the change of Z flag. 8-84 S3FB42F INSTRUCTION SET RR -- Rotate Right Format: RR Example: 8-85 INSTRUCTION SET S3FB42F RRC -- Rotate Right with Carry Format: RRC Example: In the second example, assuming that register pair R1:R0 is 16-bit number, then RR and RRC are used for 16-bit rotate right operation. But note that zero (Z) flag do not exactly reflect result of 16-bit operation. Therefore when programming 16-bit decrement, take care of the change of Z flag. 8-86 S3FB42F INSTRUCTION SET SBC -- Subtract with Carry Format: SBC Example: SBC R0, 80h // If eid = 0, R0 R0 + ~DM[0080h] + C // If eid = 1, R0 R0 + ~DM[IDH:80h] + C // R0 R0 + ~R1 + C SBC SUB SBC R0, R1 R0, R2 R1, R3 In the last two instructions, assuming that register pair R1:R0 and R3:R2 are 16-bit signed or unsigned numbers. Even if the result of "ADD R0, R2" is not zero, zero (Z) flag can be set to `1' if the result of "SBC R1,R3" is zero. Note that zero (Z) flag do not exactly reflect result of 16-bit operation. Therefore when programming 16-bit addition, take care of the change of Z flag. 8-87 INSTRUCTION SET S3FB42F SL -- Shift Left Format: SL Example: 8-88 S3FB42F INSTRUCTION SET SLA -- Shift Left Arithmetic Format: SLA |